Skip to content

Commit 18c3361

Browse files
committed
hyrolo.el - Fix movement across file hdrs in match display buffer
1 parent 48f5e51 commit 18c3361

2 files changed

Lines changed: 33 additions & 18 deletions

File tree

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2026-04-05 Bob Weiner <rsw@gnu.org>
2+
3+
* hyrolo.el (hyrolo-hdr-to-first-line-p): Handle black lines and @loc> after
4+
two lines of 'hyrolo-hdr-regexp'.
5+
(hyrolo-outline-next-visible-heading): Fix moving when in a file
6+
hdr but not at the start of a line.
7+
18
2026-04-04 Bob Weiner <rsw@gnu.org>
29

310
* hyrolo.el (hyrolo-grep-file): Change to call 'hyrolo-set-display-buffer'

hyrolo.el

Lines changed: 26 additions & 18 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: 4-Apr-26 at 23:14:26 by Bob Weiner
6+
;; Last-Mod: 5-Apr-26 at 00:34:28 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1974,13 +1974,20 @@ return nil.
19741974
The header includes lines matching both `hyrolo-hdr-regexp' and
19751975
`hbut:source-prefix'."
19761976
(let ((opoint (point)))
1977+
;; Skip back over blank lines
1978+
(when (looking-at "^[ \t]*$")
1979+
(skip-chars-backward " \t\n\r"))
19771980
(beginning-of-line)
19781981
(if (if (zerop (% (count-matches hyrolo-hdr-regexp (point-min) (point)) 2))
1979-
(if (looking-at hyrolo-hdr-regexp)
1980-
;; Now at the start of the first line of a file header
1981-
t
1982-
;; Not within a file header
1983-
nil)
1982+
(cond ((looking-at hyrolo-hdr-regexp)
1983+
;; Now at the start of the first line of a file header
1984+
t)
1985+
((looking-at hbut:source-prefix)
1986+
(forward-line -1)
1987+
(hyrolo-hdr-to-first-line-p))
1988+
(t
1989+
;; Not within a file header
1990+
nil))
19841991
;; If in a file header, past the first line
19851992
(and (hyrolo-hdr-move-after-p)
19861993
(re-search-backward hyrolo-hdr-regexp nil t 2)
@@ -2007,10 +2014,12 @@ The header includes lines matching both `hyrolo-hdr-regexp' and
20072014
"If point is within a file header, move past the hdr and blank lines.
20082015
Return non-nil if point moves, else return nil."
20092016
(let ((opoint (point))
2017+
in-file-hdr-first-line
20102018
result)
20112019
(when (save-excursion
20122020
(beginning-of-line)
2013-
(zerop (% (count-matches hyrolo-hdr-regexp (point-min) (point)) 2)))
2021+
(setq in-file-hdr-first-line
2022+
(zerop (% (count-matches hyrolo-hdr-regexp (point-min) (line-beginning-position)) 2))))
20142023
(cond ((save-excursion
20152024
(beginning-of-line)
20162025
(looking-at hyrolo-hdr-regexp))
@@ -2030,7 +2039,7 @@ Return non-nil if point moves, else return nil."
20302039
(forward-line 1))))
20312040

20322041
;; Within a file header pair, past the first header line
2033-
(when (and (= (point) opoint)
2042+
(when (and (not in-file-hdr-first-line)
20342043
(progn (beginning-of-line)
20352044
(re-search-forward hyrolo-hdr-regexp nil t)))
20362045
(setq result t)
@@ -2593,17 +2602,16 @@ A match buffer header is one that starts with `hyrolo-hdr-regexp'."
25932602
;; Move to the start of -argth previous entry when arg < 0
25942603
(while (and (not (bobp)) (< arg 0))
25952604
(unless (bobp)
2596-
(if (hyrolo-hdr-to-first-line-p)
2597-
(setq found t)
2598-
(hyrolo-funcall-match #'to-prev-entry nil t)
2599-
(when (< (point) last-point)
2600-
(setq found t))))
2605+
(hyrolo-hdr-to-first-line-p)
2606+
(hyrolo-funcall-match #'to-prev-entry nil t)
2607+
(when (< (point) last-point)
2608+
(setq found t)))
26012609
(setq arg (1+ arg)))
26022610

26032611
;; Move to the start of argth next entry when arg > 0
26042612
(while (and (not (eobp)) (> arg 0))
26052613
(unless (eobp)
2606-
(if (hyrolo-hdr-to-first-line-p)
2614+
(if (hyrolo-hdr-move-after-p)
26072615
(setq found t)
26082616
(hyrolo-funcall-match #'to-next-entry)
26092617
(when (< last-point (point))
@@ -2913,9 +2921,9 @@ Optionally, also set `hyrolo-file-list' to PATH-LIST when non-nil."
29132921
;;; ************************************************************************
29142922

29152923
(defun hyrolo-add-match (regexp start end headline-only)
2916-
"Add to `hyrolo-display-buffer' an entry matching REGEXP from current region.
2917-
The region is between START to END. Point moves to the end of the inserted
2918-
entry."
2924+
"Add a REGEXP match entry from START to END in curr buffer to display buffer.
2925+
Then highlight the matches within the entry. Point moves to the end of the
2926+
inserted entry in the match display buffer, `hyrolo-display-buffer'."
29192927
(let* ((display-buf (get-buffer-create hyrolo-display-buffer))
29202928
(start-point (with-current-buffer display-buf (point)))
29212929
end-point)
@@ -2930,7 +2938,7 @@ entry."
29302938
;; sub-levels in the entry as well. If an entry does not have a
29312939
;; starting delimiter, then it must be a single line entry; add the
29322940
;; text property to the first character of the line in this case.
2933-
(if (not (looking-at hyrolo-entry-regexp))
2941+
(if (looking-at hyrolo-hdr-regexp)
29342942
(add-text-properties (point) (1+ (point)) '(:hyrolo-level t))
29352943
(while (re-search-forward hyrolo-entry-regexp end-point t)
29362944
(add-text-properties (match-beginning hyrolo-entry-group-number)

0 commit comments

Comments
 (0)