Skip to content

Commit 00a7ff7

Browse files
committed
hyrolo.el - Update to match only outside of file headers
1 parent b1005e7 commit 00a7ff7

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2026-04-13 Bob Weiner <rsw@gnu.org>
2+
3+
* hyrolo.el (hyrolo-next-match, hyrolo-next-regexp-match,
4+
hyrolo-previous-match): Update to match only outside of file
5+
headers.
6+
17
2026-04-12 Bob Weiner <rsw@gnu.org>
28

39
* hywiki.el (hywiki-cache-save):

hyrolo.el

Lines changed: 32 additions & 14 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: 12-Apr-26 at 09:29:44 by Bob Weiner
6+
;; Last-Mod: 13-Apr-26 at 22:46:49 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1212,23 +1212,30 @@ Raise an error if a match is not found."
12121212
(let* ((regexp hyrolo-match-regexp)
12131213
(start (point))
12141214
(case-fold-search t)
1215-
(prior-regexp-search (stringp hyrolo-match-regexp)))
1216-
1215+
(prior-regexp-search (stringp hyrolo-match-regexp))
1216+
found)
12171217
;; Ensure a search regexp has been stored previously or error
12181218
(unless prior-regexp-search
12191219
(error (substitute-command-keys
12201220
"(hyrolo-next-match): Use {\\[hyrolo-grep-or-fgrep]} to do a search first")))
12211221

12221222
;; If already at a match, move past it to ensure we find the next one
1223-
(when (looking-at regexp)
1223+
(when (and (hproperty:but-face-p (point) (list (or hyrolo-highlight-face
1224+
hproperty:highlight-face)))
1225+
(looking-at regexp))
12241226
(goto-char (match-end 0)))
12251227

12261228
;; Search for the next match
1227-
(if (re-search-forward regexp nil t)
1228-
(progn
1229-
(goto-char (match-beginning 0))
1230-
;; !! TODO: Next line temporary until `reveal-mode' works properly
1231-
(hyrolo-outline-show-subtree))
1229+
(while (and (re-search-forward regexp nil t)
1230+
(progn (save-match-data
1231+
(setq found (hproperty:but-face-p
1232+
(1- (point)) (list (or hyrolo-highlight-face
1233+
hproperty:highlight-face)))))
1234+
(not found))))
1235+
(if found
1236+
(progn (goto-char (match-beginning 0))
1237+
;; !! TODO: Next line temporary until `reveal-mode' works properly
1238+
(hyrolo-outline-show-subtree))
12321239
(goto-char start)
12331240
(error "(hyrolo-next-match): No following matches for \"%s\"" regexp))))
12341241

@@ -1306,10 +1313,18 @@ Raise an error if a match is not found."
13061313
(interactive)
13071314
(hyrolo-verify)
13081315
(if hyrolo-match-regexp
1309-
(let ((case-fold-search t))
1310-
(if (re-search-backward hyrolo-match-regexp nil t)
1316+
(let ((case-fold-search t)
1317+
(start (point))
1318+
found)
1319+
(while (and (re-search-backward hyrolo-match-regexp nil t)
1320+
(progn (setq found (hproperty:but-face-p
1321+
(point) (list (or hyrolo-highlight-face
1322+
hproperty:highlight-face))))
1323+
(not found))))
1324+
(if found
13111325
;; !! TODO: Next line temporary until `reveal-mode' works properly
13121326
(hyrolo-outline-show-subtree)
1327+
(goto-char start)
13131328
(error
13141329
"(hyrolo-previous-match): No prior matches for \"%s\"" hyrolo-match-regexp)))
13151330
(error (substitute-command-keys "(hyrolo-previous-match): Use {\\[hyrolo-grep-or-fgrep]} to do an initial search"))))
@@ -2369,10 +2384,13 @@ Calls the functions given by `hyrolo-mode-hook'.
23692384
(run-mode-hooks 'hyrolo-mode-hook))
23702385

23712386
(defun hyrolo-next-regexp-match (regexp)
2372-
"In a HyRolo source buffer, move past next occurrence of REGEXP.
2387+
"In a HyRolo source buffer, move past next non-file-header occurrence of REGEXP.
23732388
When found, return the match start position; otherwise, return nil."
2374-
(when (re-search-forward regexp nil t)
2375-
(match-beginning 0)))
2389+
(let (found)
2390+
(while (and (setq found (re-search-forward regexp nil t))
2391+
(save-match-data (hyrolo-hdr-in-p)))
2392+
(setq found nil))
2393+
(when found (match-beginning 0))))
23762394

23772395
;; The *HyRolo* buffer uses `hyrolo-org-mode' and `hyrolo-markdown-mode'
23782396
;; on Org and Markdown files that it reads to speed loading and

0 commit comments

Comments
 (0)