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

    +* hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): Fixes.
    
    (hyrolo-to-entry-end): Remove unused arg '_curr-entry-level-len'.
    (hyrolo-grep-file): Remove unneeded passing of 'curr-entry-level-len' arg to
    (hyrolo-outline-previous-visible-heading, hyrolo-next-visible-heading): Fix
       doc strings to mention stops at match buffer headers.
---
 ChangeLog | 10 ++++++++++
 hyrolo.el | 48 +++++++++++++++++++++++++++---------------------
 2 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 08dd6266e3..dc7107fd43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-12-18  Bob Weiner  <r...@gnu.org>
+
+* hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): If FUNC is a lambda
+    (not a function symbol), then temporarily narrow to the current match 
buffer
+     before applying FUNC.
+     (hyrolo-to-entry-end): Remove unused arg '_curr-entry-level-len'.
+     (hyrolo-grep-file): Remove unneeded passing of 'curr-entry-level-len' arg 
to
+     (hyrolo-outline-previous-visible-heading, hyrolo-next-visible-heading): 
Fix
+     doc strings to mention stops at match buffer headers.
+
 2023-12-17  Bob Weiner  <r...@gnu.org>
 
 * hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): If on a kotl-mode 
entry,
diff --git a/hyrolo.el b/hyrolo.el
index cf9f4964e2..73936d410b 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:     17-Dec-23 at 21:16:02 by Bob Weiner
+;; Last-Mod:     18-Dec-23 at 11:20:19 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1674,7 +1674,7 @@ Return number of matching entries found."
                          (unless (re-search-forward hyrolo-entry-regexp nil t)
                            (goto-char (line-end-position)))
                          (setq curr-entry-level-len (length 
(buffer-substring-no-properties entry-start (point))))
-                         (unless (hyrolo-to-entry-end t curr-entry-level-len)
+                         (unless (hyrolo-to-entry-end t)
                            ;; If at the end of a line, move to the next line;
                            ;; otherwise, move forward a character if possible.
                            (if (eolp)
@@ -1853,10 +1853,11 @@ When found, return the mnatch starting position."
     (match-beginning 0)))
 
 (defun hyrolo-next-visible-heading (arg)
-  "Move to the next visible heading line.
+  "Move to the next visible heading or match buffer header.
 With ARG, repeats or can move backward if negative.
-A heading line is one that starts with a `*' (or that
-`outline-regexp' matches)."
+
+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))
 
@@ -1984,10 +1985,11 @@ A heading line is one that starts with a `*' (or that
   (hyrolo-funcall-match #'outline-previous-heading))
 
 (defun hyrolo-outline-previous-visible-heading (arg)
-  "Move to the previous heading line.
+  "Move to the previous visible heading or match buffer header.
 With ARG, repeats or can move forward if negative.
-A heading line is one that starts with a `*' (or that
-`outline-regexp' matches)."
+
+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))
 
@@ -2128,17 +2130,13 @@ beginning of the highest ancestor level.  Return final 
point."
         (outline-up-heading 80))))
    include-sub-entries))
 
-(defun hyrolo-to-entry-end (&optional include-sub-entries 
_curr-entry-level-len)
+(defun hyrolo-to-entry-end (&optional include-sub-entries)
   "Move point past the end of the current entry.
-oWith optional prefix arg INCLUDE-SUB-ENTRIES non-nil, move past
+With optional prefix arg INCLUDE-SUB-ENTRIES non-nil, move past
 the end of the entire subtree.  Return final point.
 
-CURR-ENTRY-LEVEL-LEN is the integer length of the last entry
-header found.  If INCLUDE-SUB-ENTRIES is nil,
-CURR-ENTRY-LEVEL-LEN is not needed.
-
-When called interactively, leave point one character earlier, before
-the final newline of the entry.
+When called interactively, leave point one character earlier,
+before the final newline of the entry.
 
 Return current point."
   (interactive "P")
@@ -2147,8 +2145,8 @@ Return current point."
      (if (not include-sub-entries)
         (outline-next-heading)
        (outline-end-of-subtree)
-       (goto-char (1+ (point)))))
-   include-sub-entries)
+       (goto-char (1+ (point))))
+     include-sub-entries))
   (when (called-interactively-p 'any)
     (goto-char (1- (point))))
   (point))
@@ -2318,7 +2316,7 @@ Any non-nil value returned is a cons of (<entry-name> . 
<entry-source>)."
   ;; Don't actually derive from org-mode to avoid its costly setup but
   ;; set its parent mode property to org-mode so can `derived-mode-p'
   ;; checks will pass.
-  (put hyrolo-org-mode 'derived-mode-parent 'org-mode)
+  (put 'hyrolo-org-mode 'derived-mode-parent 'org-mode)
   (setq-local outline-regexp org-outline-regexp
              outline-level #'hyrolo-org-outline-level)
   (use-local-map org-mode-map)
@@ -2469,11 +2467,16 @@ Return final point."
        (when (> (point) opoint)
         (goto-char opoint))
        (when (derived-mode-p 'kotl-mode)
-        (kotl-mode:to-valid-position)))))
+        (kotl-mode:to-valid-position)))
+     ;; Narrow to current match buffer when given a lambda func.
+     (not (symbolp func))))
   (point))
 
 (defun hyrolo-move-forward (func &rest args)
   "Move forward past any file header and apply FUNC to ARGS.
+If FUNC is a lambda (not a function symbol), then temporarily
+narrow to the current match buffer before applying FUNC.
+
 Return final point."
   (hyrolo-hdr-to-last-line-p)
   (condition-case nil
@@ -2481,7 +2484,9 @@ Return final point."
        (lambda ()
         (apply func args)
         (when (derived-mode-p 'kotl-mode)
-          (kotl-mode:to-valid-position))))
+          (kotl-mode:to-valid-position)))
+       ;; Narrow to current match buffer when given a lambda func.
+       (not (symbolp func)))
     ;; Prevent error and move past file header.
     (error (hyrolo-hdr-move-after-p)))
   (point))
@@ -2756,6 +2761,7 @@ Add `hyrolo-hdr-regexp' to `hyrolo-entry-regexp' and 
`outline-regexp'."
         (substitute-key-definition otl-cmd hyrolo-cmd hyrolo-mode-map)))
      outline-mode-prefix-map)))
 
+
 (provide 'hyrolo)
 
 ;;; hyrolo.el ends here

Reply via email to