|
3 | 3 | ;; Author: Bob Weiner |
4 | 4 | ;; |
5 | 5 | ;; 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 |
7 | 7 | ;; |
8 | 8 | ;; SPDX-License-Identifier: GPL-3.0-or-later |
9 | 9 | ;; |
@@ -1212,23 +1212,30 @@ Raise an error if a match is not found." |
1212 | 1212 | (let* ((regexp hyrolo-match-regexp) |
1213 | 1213 | (start (point)) |
1214 | 1214 | (case-fold-search t) |
1215 | | - (prior-regexp-search (stringp hyrolo-match-regexp))) |
1216 | | - |
| 1215 | + (prior-regexp-search (stringp hyrolo-match-regexp)) |
| 1216 | + found) |
1217 | 1217 | ;; Ensure a search regexp has been stored previously or error |
1218 | 1218 | (unless prior-regexp-search |
1219 | 1219 | (error (substitute-command-keys |
1220 | 1220 | "(hyrolo-next-match): Use {\\[hyrolo-grep-or-fgrep]} to do a search first"))) |
1221 | 1221 |
|
1222 | 1222 | ;; 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)) |
1224 | 1226 | (goto-char (match-end 0))) |
1225 | 1227 |
|
1226 | 1228 | ;; 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)) |
1232 | 1239 | (goto-char start) |
1233 | 1240 | (error "(hyrolo-next-match): No following matches for \"%s\"" regexp)))) |
1234 | 1241 |
|
@@ -1306,10 +1313,18 @@ Raise an error if a match is not found." |
1306 | 1313 | (interactive) |
1307 | 1314 | (hyrolo-verify) |
1308 | 1315 | (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 |
1311 | 1325 | ;; !! TODO: Next line temporary until `reveal-mode' works properly |
1312 | 1326 | (hyrolo-outline-show-subtree) |
| 1327 | + (goto-char start) |
1313 | 1328 | (error |
1314 | 1329 | "(hyrolo-previous-match): No prior matches for \"%s\"" hyrolo-match-regexp))) |
1315 | 1330 | (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'. |
2369 | 2384 | (run-mode-hooks 'hyrolo-mode-hook)) |
2370 | 2385 |
|
2371 | 2386 | (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. |
2373 | 2388 | 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)))) |
2376 | 2394 |
|
2377 | 2395 | ;; The *HyRolo* buffer uses `hyrolo-org-mode' and `hyrolo-markdown-mode' |
2378 | 2396 | ;; on Org and Markdown files that it reads to speed loading and |
|
0 commit comments