Skip to content

Commit c81ab1b

Browse files
committed
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.
1 parent 18c3361 commit c81ab1b

3 files changed

Lines changed: 36 additions & 16 deletions

File tree

ChangeLog

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
2026-04-05 Bob Weiner <rsw@gnu.org>
22

33
* hyrolo.el (hyrolo-hdr-to-first-line-p): Handle black lines and @loc> after
4-
two lines of 'hyrolo-hdr-regexp'.
4+
two lines of 'hyrolo-hdr-regexp'. Move by visible lines.
55
(hyrolo-outline-next-visible-heading): Fix moving when in a file
6-
hdr but not at the start of a line.
6+
hdr but not at the start of a line. Fix forward and backward movement
7+
when entries are hidden.
8+
(hyrolo-hdr-to-first-line-p, hyrolo-hdr-move-after-p): Return t
9+
only if point is left on a visible, non-hidden character to fix next
10+
and previous entry movement.
11+
(hyrolo-hdr-in-p): Rewrite with 'hyrolo-hdr-to-first-line-p'
12+
instead of 'hyrolo-hdr-move-after-p' since that can return nil when it
13+
leaves point at a hidden/invisible position.
714

815
2026-04-04 Bob Weiner <rsw@gnu.org>
916

hyrolo.el

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 7-Jun-89 at 22:08:29
6-
;; Last-Mod: 5-Apr-26 at 00:34:28 by Bob Weiner
6+
;; Last-Mod: 5-Apr-26 at 02:34:12 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1977,22 +1977,24 @@ The header includes lines matching both `hyrolo-hdr-regexp' and
19771977
;; Skip back over blank lines
19781978
(when (looking-at "^[ \t]*$")
19791979
(skip-chars-backward " \t\n\r"))
1980-
(beginning-of-line)
1980+
(forward-visible-line 0)
19811981
(if (if (zerop (% (count-matches hyrolo-hdr-regexp (point-min) (point)) 2))
19821982
(cond ((looking-at hyrolo-hdr-regexp)
19831983
;; Now at the start of the first line of a file header
19841984
t)
19851985
((looking-at hbut:source-prefix)
1986-
(forward-line -1)
1986+
(forward-visible-line -1)
19871987
(hyrolo-hdr-to-first-line-p))
19881988
(t
19891989
;; Not within a file header
19901990
nil))
19911991
;; If in a file header, past the first line
19921992
(and (hyrolo-hdr-move-after-p)
19931993
(re-search-backward hyrolo-hdr-regexp nil t 2)
1994-
t))
1995-
(/= (point) opoint)
1994+
(progn (forward-visible-line 0)
1995+
t)))
1996+
(and (/= (point) opoint)
1997+
(not (outline-invisible-p)))
19961998
(goto-char opoint)
19971999
nil)))
19982000

@@ -2008,7 +2010,9 @@ The header includes lines matching both `hyrolo-hdr-regexp' and
20082010

20092011
(defun hyrolo-hdr-in-p ()
20102012
"If point is within a file header, return t, else nil."
2011-
(save-excursion (hyrolo-hdr-move-after-p)))
2013+
(save-excursion (when (looking-at hyrolo-hdr-regexp)
2014+
(goto-char (1+ (point))))
2015+
(hyrolo-hdr-to-first-line-p)))
20122016

20132017
(defun hyrolo-hdr-move-after-p ()
20142018
"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."
20512055
(if (> (point) opoint)
20522056
(progn (while (looking-at-p "^[ \t]*$")
20532057
(forward-line 1))
2054-
result)
2058+
(unless (outline-invisible-p)
2059+
result))
20552060
(goto-char opoint)
20562061
nil)))
20572062

@@ -2584,9 +2589,13 @@ A match buffer header is one that starts with `hyrolo-hdr-regexp'."
25842589
(or (previous-single-property-change
25852590
(point) :hyrolo-level)
25862591
(point)))
2587-
(forward-line 0)
2588-
(and (< (point) last-point)
2589-
(outline-invisible-p)))))
2592+
(while (and (< (point) last-point)
2593+
(outline-invisible-p)
2594+
(progn
2595+
(forward-visible-line 0)
2596+
(hyrolo-hdr-to-first-line-p)
2597+
(> (point)
2598+
(hyrolo-to-entry-beginning))))))))
25902599
(to-next-entry ()
25912600
(while (progn
25922601
;; Skip over hidden sub-entries in tree
@@ -2597,8 +2606,12 @@ A match buffer header is one that starts with `hyrolo-hdr-regexp'."
25972606
(or (next-single-property-change
25982607
(point) :hyrolo-level)
25992608
(point)))
2600-
(and (> (point) last-point)
2601-
(outline-invisible-p))))))
2609+
(while (and (> (point) last-point)
2610+
(outline-invisible-p)
2611+
(progn
2612+
(end-of-visible-line)
2613+
(hyrolo-hdr-to-first-line-p)
2614+
(< (point) (hyrolo-to-entry-end)))))))))
26022615
;; Move to the start of -argth previous entry when arg < 0
26032616
(while (and (not (bobp)) (< arg 0))
26042617
(unless (bobp)

test/hyrolo-tests.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <matsl@gnu.org>
44
;;
55
;; Orig-Date: 19-Jun-21 at 22:42:00
6-
;; Last-Mod: 14-Mar-26 at 15:23:53 by Mats Lidell
6+
;; Last-Mod: 5-Apr-26 at 02:24:43 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -825,7 +825,7 @@ optional DEPTH the number of sub cells are created to that depth."
825825
(should (get-char-property (point) 'invisible))))
826826

827827
(defun hyrolo-tests--verify-not-hidden-line ()
828-
"Verify that a line is hidden."
828+
"Verify that a line is not hidden."
829829
(save-excursion
830830
(end-of-line)
831831
(should-not (get-char-property (point) 'invisible))))

0 commit comments

Comments
 (0)