branch: externals/hyperbole
commit 8f7f26468afc08b66a96328723b46b13100aaa8f
Author: Bob Weiner <[email protected]>
Commit: Bob Weiner <[email protected]>
Fix HyRolo searches where headline-only option is given
hyperbole.el - Add 'Author' field so it shows up properly in Emacs
package info listings.
---
ChangeLog | 12 ++++++++++++
hyperbole.el | 5 +++--
hyrolo-logic.el | 18 +++++++++---------
hyrolo.el | 26 ++++++++++++++++----------
4 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2b41a880d9..88ed7f0110 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-03-30 Bob Weiner <[email protected]>
+
+* hyrolo.el (hyrolo-next-match-function): Change doc so function takes only
one arg now
+ and not a second arg of 'headline-only'. That arg is now only sent to the
higher
+ level 'hyrolo-grep-file' function for efficiency.
+ (hyrolo-next-regexp-match): Remove second 'headline-only' flag.
+ (hyrolo-grep-file): With 'headline-only' flag, anchor pattern to
match
+ headline lines only and don't send 'headline-only' flag to
'hyrolo-next-match-function'
+ call. This fixes headline-only searching which previously did not work
properly.
+ hyrolo-logic.el (hyrolo-<logical-operator>): No longer send a nil second arg
to the
+ 'hyrolo-next-match-function' call; no longer needed.
+
2024-03-21 Mats Lidell <[email protected]>
* .github/workflows/main.yml (jobs): Ensure grep for warnings does not
diff --git a/hyperbole.el b/hyperbole.el
index 05f77dba96..46cc6aaf24 100644
--- a/hyperbole.el
+++ b/hyperbole.el
@@ -4,11 +4,12 @@
;;
;; Copyright (C) 1992-2024 Free Software Foundation, Inc.
-;; Authors: Robert Weiner <[email protected]>
+;; Author: Robert Weiner <[email protected]>
+;; Authors: Robert Weiner <[email protected]>, Mats Lidell <[email protected]>
;; Maintainer: Mats Lidell <[email protected]>
;; Maintainers: Robert Weiner <[email protected]>, Mats Lidell <[email protected]>
;; Created: 06-Oct-92 at 11:52:51
-;; Last-Mod: 22-Mar-24 at 08:50:50 by Bob Weiner
+;; Last-Mod: 30-Mar-24 at 11:23:37 by Bob Weiner
;; Released: 10-Mar-24
;; Version: 9.0.2pre
;; Keywords: comm, convenience, files, frames, hypermedia, languages,
mail, matching, mouse, multimedia, outlines, tools, wp
diff --git a/hyrolo-logic.el b/hyrolo-logic.el
index 0272d0e5a1..1816e8c54a 100644
--- a/hyrolo-logic.el
+++ b/hyrolo-logic.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 13-Jun-89 at 22:57:33
-;; Last-Mod: 27-Jan-24 at 13:01:44 by Bob Weiner
+;; Last-Mod: 30-Mar-24 at 12:36:32 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -374,7 +374,7 @@ string."
(or (null (setq pat (car pat-list)))
(and (stringp pat)
(goto-char start)
- (not (funcall hyrolo-next-match-function
(regexp-quote pat) nil)))))
+ (not (funcall hyrolo-next-match-function
(regexp-quote pat))))))
(setq pat-list (cdr pat-list)))
(not pat-list))))
@@ -391,7 +391,7 @@ string."
(or (null (setq pat (car pat-list)))
(and (stringp pat)
(goto-char start)
- (not (funcall hyrolo-next-match-function
(regexp-quote pat) nil)))))
+ (not (funcall hyrolo-next-match-function
(regexp-quote pat))))))
(setq pat-list (cdr pat-list)))
(if pat-list t nil)))))
@@ -407,7 +407,7 @@ string."
(or (not (setq pat (car pat-list)))
(and (or (eq pat t)
(not (goto-char start))
- (funcall hyrolo-next-match-function
(regexp-quote pat) nil))
+ (funcall hyrolo-next-match-function
(regexp-quote pat)))
(setq matches (1+ matches)))
t)
(< matches 2))
@@ -426,7 +426,7 @@ string."
(setq pat (car pat-list))
(or (eq pat t)
(not (goto-char start))
- (funcall hyrolo-next-match-function (regexp-quote pat)
nil)))
+ (funcall hyrolo-next-match-function (regexp-quote
pat))))
(setq pat-list (cdr pat-list)))
(not pat-list)))))
@@ -443,7 +443,7 @@ regular expression."
(or (null (setq pat (car pat-list)))
(and (stringp pat)
(goto-char start)
- (not (funcall hyrolo-next-match-function pat nil)))))
+ (not (funcall hyrolo-next-match-function pat)))))
(setq pat-list (cdr pat-list)))
(not pat-list))))
@@ -460,7 +460,7 @@ regular expression."
(or (null (setq pat (car pat-list)))
(and (stringp pat)
(goto-char start)
- (not (funcall hyrolo-next-match-function pat
nil)))))
+ (not (funcall hyrolo-next-match-function pat)))))
(setq pat-list (cdr pat-list)))
(if pat-list t nil)))))
@@ -476,7 +476,7 @@ regular expression."
(or (not (setq pat (car pat-list)))
(and (or (eq pat t)
(not (goto-char start))
- (funcall hyrolo-next-match-function pat nil))
+ (funcall hyrolo-next-match-function pat))
(setq matches (1+ matches)))
t)
(< matches 2))
@@ -495,7 +495,7 @@ regular expression."
(setq pat (car pat-list))
(or (eq pat t)
(not (goto-char start))
- (funcall hyrolo-next-match-function pat nil)))
+ (funcall hyrolo-next-match-function pat)))
(setq pat-list (cdr pat-list)))
(not pat-list)))))
diff --git a/hyrolo.el b/hyrolo.el
index dea913ff9c..2a9593804a 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: 21-Mar-24 at 13:33:38 by Bob Weiner
+;; Last-Mod: 30-Mar-24 at 12:47:21 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -306,7 +306,7 @@ Use the `hyrolo-edit' function instead to edit a new or
existing entry."
(defvar hyrolo-next-match-function #'hyrolo-next-regexp-match
"Value is the function to find next match within a HyRolo file.
-Must take two arguments, `match-pattern' and `headline-only-flag'.
+Must take one argument, `match-pattern', a regular expression.
Must leave point at the end of the match and return the start position
of the match or nil when no match.")
@@ -1980,6 +1980,15 @@ Return number of matching entries found."
(set-buffer actual-buf)
(when new-buf-flag
(setq buffer-read-only t))
+
+ (when (and headline-only
+ (not (or (string-match (regexp-quote "^") pattern)
+ (string-match (regexp-quote "\\`") pattern))))
+ ;; If matching only to headlines and pattern is not already
+ ;; anchored to the beginning of lines, add a file-type-specific
+ ;; headline prefix regexp to the pattern to match.
+ (setq pattern (concat hyrolo-entry-regexp ".*" pattern)))
+
(setq stuck-negative-point
(catch 'stuck
(save-excursion
@@ -1994,7 +2003,7 @@ Return number of matching entries found."
match-end)
(re-search-forward hyrolo-hdr-and-entry-regexp nil t)
(while (and (or (null max-matches) (< num-found
max-matches))
- (funcall hyrolo-next-match-function pattern
headline-only))
+ (funcall hyrolo-next-match-function
pattern))
(setq match-end (point))
;; If no entry delimiters found, just return
;; the line of the match alone.
@@ -2206,13 +2215,10 @@ Calls the functions given by `hyrolo-mode-hook'.
(run-mode-hooks 'hyrolo-mode-hook))
-(defun hyrolo-next-regexp-match (regexp headline-only)
- "In a HyRolo source buffer, move past next occurrence of REGEXP or return
nil.
-When found, return the match start position."
- (when (re-search-forward regexp
- (when headline-only
- (save-excursion (end-of-visible-line) (point)))
- t)
+(defun hyrolo-next-regexp-match (regexp)
+ "In a HyRolo source buffer, Move past next occurrence of REGEXP.
+When found, return the match start position; otherwise, return nil."
+ (when (re-search-forward regexp nil t)
(match-beginning 0)))
;; The *HyRolo* buffer uses hyrolo-org-mode and hyrolo-markdown-mode