branch: externals/hyperbole
commit 721ab10894825bf725de4de909602e499080541f
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    hsys-flymake.el improvements; hyrolo-tests.el improvements
    
    *HyRolo* buffer {n} and {p} improvements across file headers but
    not fully finished.
---
 ChangeLog            |  21 ++++++++
 hibtypes.el          |   8 +--
 hsys-flymake.el      |  66 +++++++++++++++--------
 hui-mouse.el         |   3 +-
 hyrolo.el            | 108 +++++++++++++++++++++++++------------
 man/hyperbole.texi   |   6 +--
 test/hyrolo-tests.el | 146 +++++++++++++++++++++++++--------------------------
 7 files changed, 216 insertions(+), 142 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b6f5e6b1ee..82e0c02ec3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2024-01-04  Bob Weiner  <r...@gnu.org>
+
+* hyrolo.el (hyrolo-org-mode): Force font-lock-mode off in this major mode for 
speed.
+
+* hui-mouse.el (hsys-flymake): Move loading of this library here from 
"hibtypes.el".
+  hsys-flymake.el (hsys-flymake-issue-at-point, 
hsys-flymake-issue-at-point:help):
+    Remove this ibtype and its :help function.  Hyperbole uses 'hkey-alist' 
Smart
+    Key invocations of functions from this file instead now.
+    Also, add documentation of all commands and key bindings.
+
+* test/hyrolo-tests.el: Changed all 'header' to 'heading'.
+    (hyrolo-tests--generate-heading-contents-for-tests): Generalized to take
+    a 'heading-prefix-char' argument, to allow for markdown outline generation
+    as well.
+
+* hyrolo.el (hyrolo-hdr-move-after-p): Fix and improve to handle point
+    anywhere within a file header, not just on delim or loc lines.
+            (hyrolo-outline-next-visible-heading,
+             hyrolo-outline-previous-visible-heading): Fix to handle file
+    headers properly when moving more than one entry at a time.
+
 2024-01-03  Bob Weiner  <r...@gnu.org>
 
 * hui-mouse.el (smart-eolp): Change 'hsys-flymake-get-issue-at-point' to
diff --git a/hibtypes.el b/hibtypes.el
index e1e9bee453..b32db16f28 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    19-Sep-91 at 20:45:31
-;; Last-Mod:      3-Jan-24 at 23:34:58 by Mats Lidell
+;; Last-Mod:      4-Jan-24 at 22:48:49 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -88,12 +88,6 @@
 ;; them.  Use load instead to ensure are reloaded when resetting
 ;; ibtype priorities.
 
-;;; ========================================================================
-;;; Keymap with repeat and source buffer control for flymake code linter
-;;; ========================================================================
-
-(load "hsys-flymake")
-
 ;;; ========================================================================
 ;;; Jumps to source line from Python traceback lines
 ;;; ========================================================================
diff --git a/hsys-flymake.el b/hsys-flymake.el
index 09e96159e2..10d167972f 100644
--- a/hsys-flymake.el
+++ b/hsys-flymake.el
@@ -7,7 +7,7 @@
 ;; E-mail:       r...@gnu.org
 ;;
 ;; Orig-Date:    31-Dec-23 at 13:54:08
-;; Last-Mod:      4-Jan-24 at 10:18:18 by Mats Lidell
+;; Last-Mod:      4-Jan-24 at 22:51:11 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -21,15 +21,51 @@
 ;;    These functions all work in the source code buffer, not the flymake
 ;;    diagnostics buffer.
 ;;
-;;    We want to load this so the implicit button type defined herein
-;;    takes effect, but we don't require `flymake-mode' or
-;;    `repeat-mode'.  Instead we leave it to each function to check
-;;    whether it is enabled and active in the current buffer.  This way,
-;;    if the user never uses `flymake-mode' that library is never loaded
-;;    and the implicit button type never triggers.
+;;    This library defines the following key bindings and associated functions.
+;;
+;;    {C-c C-l t} - `hsys-flymake-toggle' - Global binding to toggle whether
+;;    flymake minor mode is enabled in the current buffer.
+;;
+;;    The rest of these key bindings are local and enabled only when flymake
+;;    minor mode is enabled.
+;;
+;;    {C-c C-l d} - `flymake-show-buffer-diagnostics' - Display list of flymake
+;;    issues with this buffer.
+;;
+;;    {C-c C-l g} - `hsys-flymake-display-this-or-next-issue' - Display issue 
at
+;;    point or if no issue there, move to next issue location and display it.
+;;
+;;    {C-c C-l i} - `hsys-flymake-insert-issue-at-point' - Insert issue at 
point
+;;    on a separate new line below the current line so that its text can be
+;;    utilized.
+;;
+;;    {C-c C-l l} - `flymake-switch-to-log-buffer' - For developers of new
+;;    language flymake backends: Jump to a log of internal flymake processing.
+;;
+;;    {C-c C-l n} - `flymake-goto-next-error' - In source buffer, move to next
+;;    flymake issue.  Wrap around at the end of the buffer if
+;;    `flymake-wrap-around' is non-nil.  Repeat with {n}.
+;;
+;;    {C-c C-l p} - `flymake-goto-prev-error' - In source buffer, move to
+;;    previous flymake issue.  Wrap around at the beginning of the buffer
+;;    if `flymake-wrap-around' is non-nil.  Repeat with {p}.
+;;
+;;    {C-c C-l s} - `flymake-start' - Force a run of flymake to update issues
+;;    with the current buffer.
+;;
+;;    {C-c C-l w} - `hsys-flymake-toggle-wraparound' - Toggle whether next
+;;    and previous issue commands wrap around at the end and beginning of the
+;;    buffer.  Repeat with {w}.
 ;;
 ;;; Code:
 
+;;    Don't require `flymake-mode' or `repeat-mode' here.  Instead we
+;;    leave it to each function to check whether `flymake-mode' is
+;;    enabled and active in the current buffer.  This way, if the user
+;;    never uses `flymake-mode' that library is never loaded and the
+;;    Smart Key context from `hkey-alist' in "hui-mouse.el" that invokes
+;;    functions from herein, never triggers.
+
 (require 'hbut)
 
 ;;; ************************************************************************
@@ -46,22 +82,6 @@
 ;;; Public functions
 ;;; ************************************************************************
 
-(defib hsys-flymake-issue-at-point ()
-  "Display the flymake diagnostic issue at source buffer point, if any."
-  (let ((issue (hsys-flymake-get-issue-at-position)))
-    (when issue
-      (ibut:label-set issue)
-      (hact 'message issue))))
-
-(defun hsys-flymake-issue-at-point:help (ibut)
-  "With flymake enabled and point on its highlighted text, insert the issue."
-  (interactive)
-  (let ((issue (car (hattr:get ibut 'args))))
-    (when issue
-      (save-excursion
-       (end-of-visible-line)
-       (insert "\n" issue "\n")))))
-
 (defun hsys-flymake-display-issue-at-point ()
   "Display the flymake diagnostic issue at source buffer point, if any."
   (interactive)
diff --git a/hui-mouse.el b/hui-mouse.el
index 7781a6a650..3c9affdb67 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Feb-89
-;; Last-Mod:      3-Jan-24 at 23:43:10 by Mats Lidell
+;; Last-Mod:      4-Jan-24 at 22:51:41 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -40,6 +40,7 @@
 ;;; ************************************************************************
 
 (require 'ert-results nil t) ;; Action Key support in ERT result buffers
+(require 'hsys-flymake)
 (require 'hload-path)
 (require 'hsys-org)
 (require 'hbut)
diff --git a/hyrolo.el b/hyrolo.el
index 07f21d3abe..37d78dd560 100644
--- a/hyrolo.el
+++ b/hyrolo.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:     7-Jun-89 at 22:08:29
-;; Last-Mod:      4-Jan-24 at 00:12:17 by Mats Lidell
+;; Last-Mod:      4-Jan-24 at 22:51:55 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1606,7 +1606,7 @@ Stop at the first and last subheadings of a superior 
heading."
   (hyrolo-move-forward #'outline-forward-same-level arg))
 
 (defun hyrolo-hdr-to-first-line-p ()
-  "If point is on a file hdr single text/sep/loc line, go to its first line.
+  "If point is within a file header, go to its first line.
 Return t in such cases.  Otherwise, don't move and return nil.
 
 The header includes lines matching both `hyrolo-hdr-regexp' and
@@ -1616,7 +1616,7 @@ The header includes lines matching both 
`hyrolo-hdr-regexp' and
     t))
 
 (defun hyrolo-hdr-to-last-line-p ()
-  "If point is on a file hdr single text/sep/loc line, go to its last line.
+  "If point is within a file header, go to its last line.
 Return t in such cases.  Otherwise, don't move and return nil.
 
 The header includes lines matching both `hyrolo-hdr-regexp' and
@@ -1626,37 +1626,42 @@ The header includes lines matching both 
`hyrolo-hdr-regexp' and
     t))
 
 (defun hyrolo-hdr-in-p ()
-  "If point is on a file hdr single text/separator/loc line, return t, else 
nil."
+  "If point is within a file header, return t, else nil."
   (save-excursion (hyrolo-hdr-move-after-p)))
 
 (defun hyrolo-hdr-move-after-p ()
-  "If point is on a file hdr separator/loc line, move past the hdr and return 
t.
+  "If point is within a file header, move past the hdr and return non-nil.
 Otherwise, don't move and return nil."
-  (let ((opoint (point))
-       (hdr-delim-count 0)
-       (loc-count 0))
-    (while (save-excursion
-            (beginning-of-line)
-            (or (when (looking-at hyrolo-hdr-regexp)
-                  (cl-incf hdr-delim-count))
+  (let (result)
+    (if (save-excursion
+         (beginning-of-line)
+         (zerop (% (count-matches hyrolo-hdr-regexp (point-min) (point)) 2)))
+       (cond ((save-excursion
+               (beginning-of-line)
+               (looking-at hyrolo-hdr-regexp))
+              (setq result t)
+              ;; On the first line of a file header pair
+              (beginning-of-line)
+              (when (re-search-forward hyrolo-hdr-regexp nil t 2)
+                (forward-line 1)
                 (when (looking-at hbut:source-prefix)
-                  (cl-incf loc-count))
-                ;; Handle textual single line between header delimiter lines
-                (when (and (forward-line -1)
-                           (looking-at hyrolo-hdr-regexp)
-                           (forward-line 2)
-                           (looking-at hyrolo-hdr-regexp))
-                  (forward-line -1)
-                  (cl-incf loc-count))))
-      (forward-line 1))
-    (when (and (/= (point) opoint) (< hdr-delim-count 2) (zerop loc-count))
-      (if (looking-at hyrolo-hdr-regexp)
-         (forward-line 1)
-       (when (re-search-forward hyrolo-hdr-regexp nil t)
-          (forward-line 1)
-         (when (looking-at hbut:source-prefix)
-           (forward-line 1)))))
-    (/= (point) opoint)))
+                  ;; @loc> line after header
+                  (forward-line 1))))
+             ((save-excursion
+               (beginning-of-line)
+               (looking-at hbut:source-prefix))
+              ;; @loc> line after header
+              (setq result t)
+              (forward-line 1)))
+      ;; Within a file header pair,
+      (beginning-of-line)
+      (when (re-search-forward hyrolo-hdr-regexp nil t)
+       (setq result t)
+       (forward-line 1)
+       (when (looking-at hbut:source-prefix)
+         ;; @loc> line after header
+         (forward-line 1))))
+    result))
 
 ;;;###autoload
 (defun hyrolo-grep-directories (file-regexp &rest dirs)
@@ -2054,7 +2059,43 @@ With ARG, repeats or can move backward if negative.
 A heading is one that starts with an `outline-regexp' match.
 A match buffer header is one that starts with `hyrolo-hdr-regexp'."
   (interactive "p")
-  (hyrolo-move-forward #'outline-next-visible-heading arg))
+  (condition-case nil
+      (progn
+       (if (< arg 0)
+           (beginning-of-line)
+         (end-of-line))
+       (let ((found-heading-p)
+             (opoint (point)))
+         (while (and (not (bobp)) (< arg 0))
+           (while (and (not (bobp))
+                       (progn (hyrolo-hdr-to-first-line-p)
+                              (hyrolo-funcall-match
+                               (lambda ()
+                                 (setq found-heading-p
+                                       (re-search-backward
+                                        (concat "^\\(?:" outline-regexp "\\)")
+                                        nil 'move)))))
+                       (progn (hyrolo-hdr-to-first-line-p)
+                              (outline-invisible-p))))
+           (setq arg (1+ arg)))
+         (while (and (not (eobp)) (> arg 0))
+           (while (and (not (eobp))
+                       (progn (hyrolo-hdr-move-after-p)
+                              (hyrolo-funcall-match
+                               (lambda ()
+                                 (setq found-heading-p
+                                       (re-search-forward
+                                        (concat "^\\(?:" outline-regexp "\\)")
+                                        nil 'move)))))
+                       (outline-invisible-p (match-beginning 0))))
+           (setq arg (1- arg)))
+         (if found-heading-p (beginning-of-line))))
+    ;; Prevent error and move to start or end of file header at point,
+    ;; if any
+    (error (if (>= arg 0)
+              (hyrolo-hdr-move-after-p)
+            (hyrolo-hdr-to-first-line-p))))
+  (point))
 
 (defun hyrolo-outline-previous-heading ()
   "Move to the previous (possibly invisible) heading line."
@@ -2068,7 +2109,7 @@ With ARG, repeats or can move forward if negative.
 A heading is one that starts with an `outline-regexp' match.
 A match buffer header is one that starts with `hyrolo-hdr-regexp'."
   (interactive "p")
-  (hyrolo-move-backward #'outline-previous-visible-heading arg))
+  (hyrolo-outline-next-visible-heading (- arg)))
 
 (defun hyrolo-outline-promote (&optional which)
   "Promote headings higher up the tree.
@@ -2554,6 +2595,7 @@ Any non-nil value returned is a cons of (<entry-name> . 
<entry-source>)."
              outline-regexp (concat hyrolo-hdr-prefix-regexp "^\\(\\*+\\)\\( 
\\)")
              outline-level #'hyrolo-org-outline-level)
   (use-local-map org-mode-map)
+  (font-lock-mode -1) ;; Never font-lock in this mode to keep it fast
   ;; Modify a few syntax entries
   (modify-syntax-entry ?\" "\"")
   (modify-syntax-entry ?\\ "_")
@@ -2806,8 +2848,8 @@ prior to applying FUNC."
 
 (defun hyrolo-funcall-match (func &optional narrow-flag)
   "Apply FUNC with no arguments to the entry at point.
-If on a display match entry, set the appropriate major mode based
-on its source location prior to applying FUNC.
+If on a display match entry or file header, set the appropriate
+major mode based on its source location prior to applying FUNC.
 
 With point in the HyRolo display matches buffer and optional
 NARROW-FLAG non-nil, narrow to the current file of matches
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 0e56f171cd..8b4dbcd8c2 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7,7 +7,7 @@
 @c Author:       Bob Weiner
 @c
 @c Orig-Date:     6-Nov-91 at 11:18:03
-@c Last-Mod:      3-Jan-24 at 13:55:25 by Bob Weiner
+@c Last-Mod:      4-Jan-24 at 13:12:14 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -10420,7 +10420,7 @@ buffer or not.
 @kindex C-c C-l d
 @kitem C-c C-l d
 @code{flymake-show-buffer-diagnostics} - Display list of flymake
-issues for this buffer.
+issues with this buffer.
 
 @findex hsys-flymake-display-this-or-next-issue
 @kindex C-c C-l g
@@ -10459,7 +10459,7 @@ flymake issue.  Wrap around at the beginning of the 
buffer if
 @findex flymake-start
 @kindex C-c C-l s
 @kitem C-c C-l s
-@code{flymake-start} - Force a run of flymake to update issues for the
+@code{flymake-start} - Force a run of flymake to update issues with the
 current buffer.
 
 @cindex key binding, C-c C-l t
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index 9856a93147..f35e9405ad 100644
--- a/test/hyrolo-tests.el
+++ b/test/hyrolo-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <ma...@gnu.org>
 ;;
 ;; Orig-Date:    19-Jun-21 at 22:42:00
-;; Last-Mod:      1-Jan-24 at 22:38:40 by Mats Lidell
+;; Last-Mod:      4-Jan-24 at 13:19:35 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -487,73 +487,75 @@ sequence up to depth starting from 2.
                       (number-to-string (+ 1 d))))))
     result))
 
-(defun hyrolo-tests--generate-header-contents-for-tests (header section body 
depth)
-  "Generate the HEADER and BODY contents for the SECTION with DEPTH."
+(defun hyrolo-tests--generate-heading-contents-for-tests (heading-prefix-char 
heading section body depth)
+  "Generate the HEADING and BODY contents for the SECTION with DEPTH."
   (let (result)
     (dotimes (d depth)
       (setq result
             (concat result
-                    (make-string (1+ d) ?*) " " header " " 
(hyrolo-tests--level-number section (1+ d)) "\n"
+                    (make-string (1+ d) heading-prefix-char)
+                   " " heading " " (hyrolo-tests--level-number section (1+ d)) 
"\n"
                     body " " (hyrolo-tests--level-number section (1+ d)) 
"\n")))
     result))
 
-(defun hyrolo-tests--gen-outline (header sections body depth)
+(defun hyrolo-tests--gen-outline (heading-prefix-char heading sections body 
depth)
   "Generate an outline structure suitable for hyrolo outline test.
 
-The contents is constructed with an outline HEADER and BODY text.
-Each is repeated in SECTIONS with one set of hierarchical headers
-to the specified DEPTH.
+The contents is constructed with an outline HEADING-PREFIX-CHAR,
+HEADING and BODY text.  Each is repeated in SECTIONS with one set
+of hierarchical headings to the specified DEPTH.
 
 Example:
-   * header 1
+   * heading 1
    body 1
-   ** header 2
+   ** heading 2
    body 1.2
    [...]
-   * header <sections>
+   * heading <sections>
    body <sections>
-   ** header <sections>.2
+   ** heading <sections>.2
    body <section>.2
    [...]"
   (let (result)
     (dotimes (section sections)
       (setq result
             (concat result
-                    (hyrolo-tests--generate-header-contents-for-tests header 
(1+ section) body depth))))
+                    (hyrolo-tests--generate-heading-contents-for-tests
+                    heading-prefix-char heading (1+ section) body depth))))
     result))
 
-(ert-deftest hyrolo-tests--outline-next-visible-header ()
-  "Verify movement to next visible header."
+(ert-deftest hyrolo-tests--outline-next-visible-heading ()
+  "Verify movement to next visible heading."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
-                                   (hyrolo-tests--gen-outline "header" 2 
"body" 2)))
+                                   (hyrolo-tests--gen-outline ?* "heading" 2 
"body" 2)))
          (hyrolo-file-list (list org-file)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
           ;; Move down
           (should (looking-at-p "==="))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\* header 1"))
+          (should (looking-at-p "^\\* heading 1"))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\*\\* header 1\\.2"))
+          (should (looking-at-p "^\\*\\* heading 1\\.2"))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\* header 2"))
+          (should (looking-at-p "^\\* heading 2"))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\*\\* header 2\\.2"))
+          (should (looking-at-p "^\\*\\* heading 2\\.2"))
           (should (hact 'kbd-key "n"))
           (should (eobp))
 
           ;; Move back up
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\*\\* header 2\\.2"))
+          (should (looking-at-p "^\\*\\* heading 2\\.2"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\* header 2"))
+          (should (looking-at-p "^\\* heading 2"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\*\\* header 1\\.2"))
+          (should (looking-at-p "^\\*\\* heading 1\\.2"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\* header 1"))
+          (should (looking-at-p "^\\* heading 1"))
           (should (hact 'kbd-key "p"))
 
           ;; BUG: This fails in Emacs 29 and 30
@@ -563,87 +565,81 @@ Example:
           ;; This is what we get
           (should (looking-at-p "@loc>"))
           (should (= 2 (line-number-at-pos))))
-      (kill-buffer "*HyRolo*")
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
-(ert-deftest hyrolo-tests--outline-up-header ()
-  "Verify movement from sub header to next header one level above."
+(ert-deftest hyrolo-tests--outline-up-heading ()
+  "Verify movement from sub heading to next heading one level above."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
-                                   (hyrolo-tests--gen-outline "header" 2 
"body" 3)))
+                                   (hyrolo-tests--gen-outline ?* "heading" 2 
"body" 3)))
          (hyrolo-file-list (list org-file)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
-          ;; Move to last header
+          ;; Move to last heading
           (goto-char (point-max))
           (forward-line -2)
-          (should (looking-at-p "^\\*\\*\\* header 2\\.2\\.3$"))
+          (should (looking-at-p "^\\*\\*\\* heading 2\\.2\\.3$"))
           (should (hact 'kbd-key "u"))
-          (should (looking-at-p "^\\*\\* header 2\\.2$"))
+          (should (looking-at-p "^\\*\\* heading 2\\.2$"))
           (should (hact 'kbd-key "u"))
-          (should (looking-at-p "^\\* header 2$"))
+          (should (looking-at-p "^\\* heading 2$"))
           (should-error (hact 'kbd-key "u")))
-      (kill-buffer "*HyRolo*")
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
-(ert-deftest hyrolo-tests--outline-next-visible-header-two-sections ()
-  "Verify movement to next visible header with two sections."
+(ert-deftest hyrolo-tests--outline-next-visible-heading-two-sections ()
+  "Verify movement to next visible heading with two sections."
   (let* ((org-file1 (make-temp-file "hypb" nil ".org"
-                                    (hyrolo-tests--gen-outline "header-a" 1 
"body-a" 2)))
-         (org-file2 (make-temp-file "hypb" nil ".org"
-                                    (hyrolo-tests--gen-outline "header-b" 1 
"body-b" 2)))
-         (hyrolo-file-list (list org-file1 org-file2)))
+                                    (hyrolo-tests--gen-outline ?* "heading-a" 
1 "body-a" 2)))
+         (md-file1 (make-temp-file "hypb" nil ".md"
+                                    (hyrolo-tests--gen-outline ?# "heading-b" 
1 "body-b" 2)))
+         (hyrolo-file-list (list org-file1 md-file1)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
           ;; Move down
           (should (looking-at-p "==="))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\* header-a 1$"))
-          (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\*\\* header-a 1\\.2$"))
+          (should (looking-at-p "^\\* heading-a 1$"))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\* header-b 1$"))
+          (should (looking-at-p "^\\*\\* heading-a 1\\.2$"))
+          (should (hact 'kbd-key "nn"))
+          (should (looking-at-p "^# heading-b 1$"))
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^\\*\\* header-b 1\\.2$"))
+          (should (looking-at-p "^## heading-b 1\\.2$"))
           (should (hact 'kbd-key "n"))
           (should (eobp))
 
           ;; Move back up
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\*\\* header-b 1\\.2$"))
+          (should (looking-at-p "^## heading-b 1\\.2$"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\* header-b 1$"))
+          (should (looking-at-p "^# heading-b 1$"))
+          (should (hact 'kbd-key "pp"))
+          (should (looking-at-p "^\\*\\* heading-a 1\\.2$"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\*\\* header-a 1\\.2$"))
+          (should (looking-at-p "^\\* heading-a 1$"))
           (should (hact 'kbd-key "p"))
-          (should (looking-at-p "^\\* header-a 1$"))
-          (should (hact 'kbd-key "p"))
-
-          ;; BUG: This fails in Emacs 29 and 30
-          ;; This is the expected behavior that works in Emacs 27 and 28.
-          ;; (should (looking-at-p "==="))
-          ;; (should (bobp))
-          ;; This is what we get
-          (should (looking-at-p "@loc>"))
-          (should (= 2 (line-number-at-pos))))
-      (kill-buffer "*HyRolo*")
+          (should (looking-at-p "==="))
+          (should (= 1 (line-number-at-pos))))
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file1)
-      (hy-delete-file-and-buffer org-file2))))
+      (hy-delete-file-and-buffer md-file1))))
 
 (ert-deftest hyrolo-tests--outline-hide-show-heading ()
-  "Verify hiding and showing headers."
+  "Verify hiding and showing headings."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
-                                   (hyrolo-tests--gen-outline "header" 2 
"body" 2)))
+                                   (hyrolo-tests--gen-outline ?* "heading" 2 
"body" 2)))
          (hyrolo-file-list (list org-file)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
           ;; Hide first line hides whole section
           (should (looking-at-p "==="))
@@ -655,27 +651,27 @@ Example:
           (should (looking-at-p "^===+$"))
 
           (should (hact 'kbd-key "n"))
-          (should (looking-at-p "^* header 1$"))
+          (should (looking-at-p "^* heading 1$"))
           ;; BUG: This gives an unexpected error when trying to hide
           ;; org-fold-region: Calling ‘org-fold-core-region’ with missing SPEC
           (should-error (hact 'kbd-key "h"))
-          ;; Expected is not to fail on hiding the header.
+          ;; Expected is not to fail on hiding the heading.
           ;; Seems to be version dependent for 29 and 30!?
 
           ;; TBC - When bug above is resolved or understood better.
           )
-      (kill-buffer "*HyRolo*")
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
 (ert-deftest hyrolo-tests--tab-through-matches ()
   "Verify tabbing through search matches."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
-                                   (hyrolo-tests--gen-outline "header" 2 
"body" 2)))
+                                   (hyrolo-tests--gen-outline ?* "heading" 2 
"body" 2)))
          (hyrolo-file-list (list org-file)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
           ;; Search Down
           (should (looking-at-p "==="))
@@ -698,18 +694,18 @@ Example:
           (should (hact 'kbd-key "<backtab>"))
           (should (looking-at-p "^body 1$"))
           (should-error (hact 'kbd-key "<backtab>")))
-      (kill-buffer "*HyRolo*")
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
 (ert-deftest hyrolo-tests--edit-entry ()
   "Verify {e} brings up entry in new window."
   (let* ((org-file (make-temp-file "hypb" nil ".org"
-                                   (hyrolo-tests--gen-outline "header" 1 
"body" 2)))
+                                   (hyrolo-tests--gen-outline ?* "heading" 1 
"body" 2)))
          (hyrolo-file-list (list org-file)))
     (unwind-protect
         (progn
           (hyrolo-grep "body")
-          (should (string= "*HyRolo*" (buffer-name)))
+          (should (string= hyrolo-display-buffer (buffer-name)))
 
           ;; Search Down
           (should (looking-at-p "==="))
@@ -724,14 +720,14 @@ Example:
           (should (looking-at-p "^body 1$"))
 
           ;; Edit next record
-          (switch-to-buffer "*HyRolo*")
+          (switch-to-buffer hyrolo-display-buffer)
           (should (hact 'kbd-key "TAB"))
           (should (looking-at-p "^body 1\\.2$"))
           (should (hact 'kbd-key "e"))
           (should (string= (buffer-name) (file-name-nondirectory org-file)))
           (should (looking-at-p "^body 1\\.2$"))
           )
-      (kill-buffer "*HyRolo*")
+      (kill-buffer hyrolo-display-buffer)
       (hy-delete-file-and-buffer org-file))))
 
 (provide 'hyrolo-tests)

Reply via email to