branch: externals/hyperbole
commit 4abe195effadab4b4449a387182f176ae629c8b9
Merge: ab8bde59cd 128000c5fa
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #749 from rswgnu/rsw
Add hyrolo-update-file-list and don't change case in matches in hyrolo.py
---
ChangeLog | 8 ++++++++
hyrolo.el | 10 ++++++++--
hyrolo.py | 24 +++++++++++++++++++-----
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c6e45ab38c..4da35192b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2025-06-15 Bob Weiner <[email protected]>
+* hyrolo.py (highlight_matches): Fix so does not change the case of
+ matches found.
+ (highlight_re_matches): Add for future use for regex
+ searching.
+
+* hyrolo.el (hyrolo-update-file-list): Add to update 'hyrolo-file-list'
+ and the cached, fully expanded 'hyrolo--expanded-file-list'.
+
* hyrolo.el (hyrolo-helm-org-rifle, hyrolo-helm-org-rifle-directory,
hyrolo-helm-org-rifle-directories): Remove all 'helm-org-rifle'
support from HyRolo in favor of 'consult', the much more widely used
diff --git a/hyrolo.el b/hyrolo.el
index 8f1e157943..b0ccd0fdb0 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: 15-Jun-25 at 22:36:53 by Bob Weiner
+;; Last-Mod: 15-Jun-25 at 23:20:28 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2866,6 +2866,12 @@ entire subtree. Return INCLUDE-SUB-ENTRIES flag value."
(when (called-interactively-p 'interactive)
(message "No previous file/buffer location") (beep)))))
+(defun hyrolo-update-file-list (&optional path-list)
+ "Update cached HyRolo file list.
+Optionally, also set `hyrolo-file-list' to PATH-LIST when non-nil."
+ (interactive)
+ (hyrolo-set-file-list 'hyrolo-file-list (or path-list hyrolo-file-list)))
+
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************
@@ -3796,7 +3802,7 @@ Used in the *HyRolo* display match buffer."
;;; ************************************************************************
(when (and hyrolo-file-list (null hyrolo--expanded-file-list))
- (hyrolo-set-file-list 'hyrolo-file-list hyrolo-file-list))
+ (hyrolo-update-file-list))
(provide 'hyrolo)
diff --git a/hyrolo.py b/hyrolo.py
index 5f3b2e656f..9734adc281 100644
--- a/hyrolo.py
+++ b/hyrolo.py
@@ -8,7 +8,7 @@
# Author: Bob Weiner
#
# Orig-Date: 1-Apr-24 at 01:45:27
-# Last-Mod: 1-Sep-24 at 12:25:38 by Bob Weiner
+# Last-Mod: 16-Jun-25 at 00:03:41 by Bob Weiner
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
@@ -144,12 +144,26 @@ def find_matching_entries(match_string, file_paths):
def highlight_matches(match_string, buffer):
- "Split the last buffer into lines and print each line, inverting 'mymatch'
colors."
+ "Split the last buffer into lines and print each line, inverting string
'match' colors."
for b_line in buffer.splitlines():
- if match_string.casefold() in b_line.casefold():
+ lower_b_line, lower_match_string = b_line.lower(), match_string.lower()
+ pos = lower_b_line.find(lower_match_string)
+ match = b_line[pos:pos + len(match_string)] if pos != -1 else None
+ if match:
# Replace the search string with the inverted version
- print(re.sub(re.escape(match_string), invert + match_string +
reset,
- b_line, flags=re.IGNORECASE))
+ print(re.sub(re.escape(match), invert + match + reset, b_line))
+ else:
+ print(b_line)
+
+# Regex search, not yet used; need a flag to switch to regex search
+def highlight_re_matches(match_re, buffer):
+ "Split the last buffer into lines and print each line, inverting regex
'match' colors."
+ for b_line in buffer.splitlines():
+ match_result = re.search(r'(?i)' + match_re, b_line)
+ match = match_result.group() if match_result else None
+ if match:
+ # Replace the search string with the inverted version
+ print(re.sub(re.escape(match), invert + match + reset, b_line))
else:
print(b_line)