branch: externals/hyperbole
commit c81ab1b11457bfca7d5869bd0f0ec27b5c5bb123
Author: bw <[email protected]>
Commit: bw <[email protected]>
hyrolo-outline-next-visible-heading - Fix forward/backward movement
hyrolo-hdr-to-first-line-p, hyrolo-hdr-move-after-p - Return t only if point
is left on a visible, non-hidden character to fix next and previous entry
movement.
hyrolo-hdr-in-p - Rewrite with 'hyrolo-hdr-to-first-line-p' instead of
'hyrolo-hdr-move-after-p' since that can return nil when it
leaves point at a hidden/invisible position.
---
ChangeLog | 11 +++++++++--
hyrolo.el | 37 +++++++++++++++++++++++++------------
test/hyrolo-tests.el | 4 ++--
3 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 630061e8c2..f9a0d3eb8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
2026-04-05 Bob Weiner <[email protected]>
* hyrolo.el (hyrolo-hdr-to-first-line-p): Handle black lines and @loc> after
- two lines of 'hyrolo-hdr-regexp'.
+ two lines of 'hyrolo-hdr-regexp'. Move by visible lines.
(hyrolo-outline-next-visible-heading): Fix moving when in a file
- hdr but not at the start of a line.
+ hdr but not at the start of a line. Fix forward and backward movement
+ when entries are hidden.
+ (hyrolo-hdr-to-first-line-p, hyrolo-hdr-move-after-p): Return t
+ only if point is left on a visible, non-hidden character to fix next
+ and previous entry movement.
+ (hyrolo-hdr-in-p): Rewrite with 'hyrolo-hdr-to-first-line-p'
+ instead of 'hyrolo-hdr-move-after-p' since that can return nil when it
+ leaves point at a hidden/invisible position.
2026-04-04 Bob Weiner <[email protected]>
diff --git a/hyrolo.el b/hyrolo.el
index b18f81df47..b7c8a96bf8 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: 5-Apr-26 at 00:34:28 by Bob Weiner
+;; Last-Mod: 5-Apr-26 at 02:34:12 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1977,13 +1977,13 @@ The header includes lines matching both
`hyrolo-hdr-regexp' and
;; Skip back over blank lines
(when (looking-at "^[ \t]*$")
(skip-chars-backward " \t\n\r"))
- (beginning-of-line)
+ (forward-visible-line 0)
(if (if (zerop (% (count-matches hyrolo-hdr-regexp (point-min) (point)) 2))
(cond ((looking-at hyrolo-hdr-regexp)
;; Now at the start of the first line of a file header
t)
((looking-at hbut:source-prefix)
- (forward-line -1)
+ (forward-visible-line -1)
(hyrolo-hdr-to-first-line-p))
(t
;; Not within a file header
@@ -1991,8 +1991,10 @@ The header includes lines matching both
`hyrolo-hdr-regexp' and
;; If in a file header, past the first line
(and (hyrolo-hdr-move-after-p)
(re-search-backward hyrolo-hdr-regexp nil t 2)
- t))
- (/= (point) opoint)
+ (progn (forward-visible-line 0)
+ t)))
+ (and (/= (point) opoint)
+ (not (outline-invisible-p)))
(goto-char opoint)
nil)))
@@ -2008,7 +2010,9 @@ The header includes lines matching both
`hyrolo-hdr-regexp' and
(defun hyrolo-hdr-in-p ()
"If point is within a file header, return t, else nil."
- (save-excursion (hyrolo-hdr-move-after-p)))
+ (save-excursion (when (looking-at hyrolo-hdr-regexp)
+ (goto-char (1+ (point))))
+ (hyrolo-hdr-to-first-line-p)))
(defun hyrolo-hdr-move-after-p ()
"If point is within a file header, move past the hdr and blank lines.
@@ -2051,7 +2055,8 @@ Return non-nil if point moves, else return nil."
(if (> (point) opoint)
(progn (while (looking-at-p "^[ \t]*$")
(forward-line 1))
- result)
+ (unless (outline-invisible-p)
+ result))
(goto-char opoint)
nil)))
@@ -2584,9 +2589,13 @@ A match buffer header is one that starts with
`hyrolo-hdr-regexp'."
(or (previous-single-property-change
(point) :hyrolo-level)
(point)))
- (forward-line 0)
- (and (< (point) last-point)
- (outline-invisible-p)))))
+ (while (and (< (point) last-point)
+ (outline-invisible-p)
+ (progn
+ (forward-visible-line 0)
+ (hyrolo-hdr-to-first-line-p)
+ (> (point)
+
(hyrolo-to-entry-beginning))))))))
(to-next-entry ()
(while (progn
;; Skip over hidden sub-entries in tree
@@ -2597,8 +2606,12 @@ A match buffer header is one that starts with
`hyrolo-hdr-regexp'."
(or (next-single-property-change
(point) :hyrolo-level)
(point)))
- (and (> (point) last-point)
- (outline-invisible-p))))))
+ (while (and (> (point) last-point)
+ (outline-invisible-p)
+ (progn
+ (end-of-visible-line)
+ (hyrolo-hdr-to-first-line-p)
+ (< (point)
(hyrolo-to-entry-end)))))))))
;; Move to the start of -argth previous entry when arg < 0
(while (and (not (bobp)) (< arg 0))
(unless (bobp)
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index 74a5c58816..65bb5b686d 100644
--- a/test/hyrolo-tests.el
+++ b/test/hyrolo-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 19-Jun-21 at 22:42:00
-;; Last-Mod: 14-Mar-26 at 15:23:53 by Mats Lidell
+;; Last-Mod: 5-Apr-26 at 02:24:43 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -825,7 +825,7 @@ optional DEPTH the number of sub cells are created to that
depth."
(should (get-char-property (point) 'invisible))))
(defun hyrolo-tests--verify-not-hidden-line ()
- "Verify that a line is hidden."
+ "Verify that a line is not hidden."
(save-excursion
(end-of-line)
(should-not (get-char-property (point) 'invisible))))