Skip to content

Commit b982163

Browse files
authored
Merge pull request #919 from rswgnu/rsw
- hypb:in-string-p - Limit string searches to 9000 chars for speed - hsys-org-id-find-advice - Auto-remove org-roam advice of org-find-id
2 parents dc5048c + a491ce6 commit b982163

9 files changed

Lines changed: 275 additions & 157 deletions

File tree

ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2026-03-28 Bob Weiner <rsw@gnu.org>
2+
3+
* hypb.el (hypb:sqlite-p): Add to return non-nil when Emacs supports sqlite.
4+
(hypb:advised-p): Add to test whether a function has been advised with
5+
a specific function.
6+
hsys-org.el (hsys-org-id-find-advice): Add as :before advice to `org-id-find'
7+
to remove :before-until advice that `org-roam-id-find' adds if sqlite is not
8+
available inside Emacs.
9+
hactypes.el (link-to-org-id):
10+
hibtypes.el (org-id, org-id:help): Remove call of `org-roam-id-find' since that
11+
will be called when loaded by any call to `org-id-find' as `org-roam' advises
12+
it.
13+
114
2026-03-26 Mats Lidell <matsl@gnu.org>
215

316
* test/hui-tests.el (hui--kill-region-delimited-text-and-yank-back):
@@ -18,12 +31,20 @@
1831
(hywiki-org-to-heading-instance): Use with-suppressed-warnings for
1932
obsolete org-show-entry.
2033

34+
2026-03-24 Bob Weiner <rsw@gnu.org>
35+
36+
* hibtypes.el (hib-link-to-file-line): Add missing 'let' for 'ext' variable,
37+
fix indentation and change 'and' to 'when' for clarity.
38+
2139
2026-03-23 Bob Weiner <rsw@gnu.org>
2240

41+
* hypb.el (hypb:in-string-p): Limit searches to a max of 9000 chars for speed.
42+
2343
* hui-mouse.el (hkey-alist): Add 'profiler-report-mode' support for jumping
2444
to call tree items or expanding/collapsing their call trees.
2545
(smart-profiler-report, smart-profiler-report-assist): Add.
2646
man/hyperbole.texi (Smart Key - Profiler Report Mode): Add doc.
47+
(smart-profiler-report): Fix display of found buffer.
2748

2849
2026-03-22 Mats Lidell <matsl@gnu.org>
2950

hactypes.el

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 23-Sep-91 at 20:34:36
6-
;; Last-Mod: 15-Mar-26 at 14:44:00 by Bob Weiner
6+
;; Last-Mod: 28-Mar-26 at 13:03:44 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -639,13 +639,12 @@ information on how to specify a mail reader to use."
639639
(hypb:error "(link-to-mail): No msg `%s' in file \"%s\""
640640
mail-msg-id mail-file)))))
641641

642-
(defact link-to-org-id (id &optional title)
643-
"Display the Org entry, if any, for ID with optional TITLE.
642+
(defact link-to-org-id (id &optional _title)
643+
"Display the Org entry, if any, for ID with optional _TITLE.
644644
ID is a uuid without any \\='id:' prefix."
645645
(when (stringp id)
646-
(let* ((inhibit-message t) ;; Inhibit org-id-find status msgs
647-
(m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker))
648-
(org-id-find id 'marker))))
646+
(let* ((inhibit-message t) ;; Inhibit `org-id-find' status msgs
647+
(m (org-id-find id 'marker)))
649648
(when m
650649
(hact 'link-to-org-id-marker m)))))
651650

hibtypes.el

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Sep-91 at 20:45:31
6-
;; Last-Mod: 22-Mar-26 at 18:18:45 by Bob Weiner
6+
;; Last-Mod: 28-Mar-26 at 13:02:39 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -191,12 +191,10 @@ only to prevent false matches."
191191
(re-search-forward ":\\(CUSTOM_\\)?ID:[ \t]+"
192192
(line-end-position) t)))
193193
(hact 'message "On Org ID definition; use {C-u M-RET} to copy a link to an ID.")
194-
(when (let ((inhibit-message t) ;; Inhibit org-id-find status msgs
194+
(when (let ((inhibit-message t) ;; Inhibit `org-id-find' status msgs
195195
(obuf (current-buffer))
196196
(omode major-mode))
197-
(prog1 (setq m (or (and (featurep 'org-roam)
198-
(org-roam-id-find id 'marker))
199-
(org-id-find id 'marker)))
197+
(prog1 (setq m (org-id-find id 'marker))
200198
;; org-find-id sets current buffer mode to Org
201199
;; mode even if ID is not found; switch it back
202200
;; when necessary.
@@ -218,9 +216,8 @@ If the referenced location is found, return non-nil."
218216
(setq id (substring id 3)))
219217
;; Ignore ID definitions or when not on a possible ID
220218
(when (and id
221-
(let ((inhibit-message t)) ;; Inhibit org-id-find status msgs
222-
(setq m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker))
223-
(org-id-find id 'marker)))))
219+
(let ((inhibit-message t)) ;; Inhibit `org-id-find' status msgs
220+
(setq m (org-id-find id 'marker))))
224221
(save-excursion
225222
(setq mpos (marker-position m))
226223
(set-buffer (marker-buffer m))
@@ -1027,15 +1024,16 @@ LINE-NUM may be an integer or string."
10271024
((stringp source-loc)
10281025
(setq file (expand-file-name file (file-name-directory source-loc))))
10291026
(t (setq file (or (hpath:prepend-shell-directory file)
1030-
;; find-library-name will strip file
1031-
;; suffixes, so use it only when the file
1032-
;; either doesn't have a suffix or has a
1033-
;; library suffix.
1034-
(and (or (null (setq ext (file-name-extension file)))
1035-
(member (concat "." ext) (get-load-suffixes)))
1036-
(ignore-errors (find-library-name file)))
1037-
(hpath:is-p (expand-file-name file))
1038-
(hywiki-get-existing-page-file file)))))
1027+
;; find-library-name will strip file
1028+
;; suffixes, so use it only when the file
1029+
;; either doesn't have a suffix or has a
1030+
;; library suffix.
1031+
(let ((ext (file-name-extension file)))
1032+
(when (or (null ext)
1033+
(member (concat "." ext) (get-load-suffixes)))
1034+
(ignore-errors (find-library-name file))))
1035+
(hpath:is-p (expand-file-name file))
1036+
(hywiki-get-existing-page-file file)))))
10391037
(when (file-exists-p (hpath:normalize file))
10401038
(actypes::link-to-file-line file line-num))))
10411039

hsys-org.el

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 2-Jul-16 at 14:54:14
6-
;; Last-Mod: 14-Mar-26 at 18:38:59 by Bob Weiner
6+
;; Last-Mod: 28-Mar-26 at 13:22:56 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -215,6 +215,18 @@ otherwise, just match to the single tag around point."
215215
(interactive)
216216
(hsys-org-get-agenda-tags #'hywiki-tags-view))
217217

218+
(defun hsys-org-id-find-advice (&rest _)
219+
"If `org-roam' is loaded and has advised `org-id-find' with the function
220+
'org-roam-id-find' but Emacs does not have the `sqlite' module, then any
221+
call to `org-id-find' will fail. This :before advice function fixes this
222+
by removing the `org-roam' advice from `org-id-find'."
223+
(when (and (fboundp 'org-roam-id-find)
224+
(not (hypb:sqlite-p))
225+
(hypb:advised-p 'org-id-find 'org-roam-id-find))
226+
(advice-remove #'org-id-find #'org-roam-id-find)))
227+
228+
(advice-add 'org-id-find :before #'hsys-org-id-find-advice)
229+
218230
(defun hsys-org-agenda-tags ()
219231
"On an `org-directory' tag, use `hsys-org-tags-view' to list dir tag matches.
220232
If on a colon, match to sections with all tags around point;

hui-mouse.el

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 04-Feb-89
6-
;; Last-Mod: 23-Mar-26 at 18:49:48 by Bob Weiner
6+
;; Last-Mod: 23-Mar-26 at 21:47:31 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -2223,13 +2223,12 @@ If key is pressed:
22232223
(quit-window))
22242224
;; If on the text of an entry, jump to its definition if is a link
22252225
((text-property-any (point) (1+ (point)) 'face 'link)
2226-
(let* ((curr-buffer nil)
2227-
(find-function-after-hook '((lambda ()
2228-
(setq curr-buffer (current-buffer))))))
2229-
(hpath:display-buffer (save-window-excursion
2230-
(profiler-report-find-entry)
2231-
curr-buffer)))
2232-
t)))
2226+
(let* ((dbuf)
2227+
(obuf (current-buffer)))
2228+
(profiler-report-find-entry)
2229+
(setq dbuf (window-buffer (selected-window)))
2230+
(switch-to-buffer obuf)
2231+
(hpath:display-buffer dbuf)))))
22332232

22342233
(defun smart-profiler-report-assist ()
22352234
"Use a single assist key or mouse assist key to toggle profiler call trees.

hypb.el

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 6-Oct-91 at 03:42:38
6-
;; Last-Mod: 22-Mar-26 at 01:29:41 by Bob Weiner
6+
;; Last-Mod: 28-Mar-26 at 11:58:58 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -145,6 +145,18 @@ text will become visible."
145145
(setq buffer-invisibility-spec
146146
(cons element buffer-invisibility-spec))))
147147

148+
;;;###autoload
149+
(defun hypb:advised-p (advised-function advice-function)
150+
"Return t if ADVISED-FUNCTION is advised with ADVICE-FUNCTION.
151+
Uses the newer \"nadvice\" elisp library, not \"advice\"."
152+
(let (found)
153+
(when (advice--p (symbol-function advised-function))
154+
(advice-mapc (lambda (advs _props)
155+
(when (eq advs advice-function)
156+
(setq found t)))
157+
advised-function))
158+
found))
159+
148160
;;;###autoload
149161
(defun hypb:activate-interaction-log-mode ()
150162
"Configure and enable the interaction-log package for use with Hyperbole.
@@ -713,6 +725,8 @@ This will this install the Emacs helm package when needed."
713725
(error "(hypb:hkey-help-file): Non-existent file: \"%s\""
714726
help-file))))))
715727

728+
(defvar hypb:in-string-and-tick (cons nil 0))
729+
716730
(defun hypb:in-string-p (&optional max-lines range-flag)
717731
"Return non-nil iff point is within a string and not on the closing quote.
718732
@@ -724,7 +738,8 @@ the positions exclude the delimiters.
724738
To prevent searching back to the buffer start and producing slow
725739
performance, this limits its count of quotes found prior to point
726740
to the beginning of the first line prior to point that contains a
727-
non-backslashed quote mark.
741+
non-backslashed quote mark and limits string length to a maximum
742+
of 9000 characters.
728743
729744
Quoting conventions recognized are:
730745
double-quotes: \"str\";
@@ -733,7 +748,10 @@ Quoting conventions recognized are:
733748
Python triple single-quotes: '''str''';
734749
Python triple double-quotes: \"\"\"str\"\"\";
735750
Texinfo open and close quotes: ``str''."
751+
736752
(let ((list-of-unformatted-open-close-regexps (eval hypb:in-string-mode-regexps))
753+
;; search limit length
754+
(limit 9000)
737755
list-of-open-close-regexps)
738756
(if (and list-of-unformatted-open-close-regexps
739757
(listp list-of-unformatted-open-close-regexps)
@@ -783,12 +801,12 @@ Quoting conventions recognized are:
783801
(looking-at orig-close-regexp)))
784802
(/= (or (char-before) 0) ?\\)
785803
(setq open-match-string (match-string 2)))
786-
(while (and (setq possible-delim (search-backward open-match-string nil t))
804+
(while (and (setq possible-delim (search-backward open-match-string (max (point-min) (- (point) limit)) t))
787805
(if (= (or (char-before) 0) ?\\)
788806
(goto-char (1- (point)))
789807
(progn (setq str-start (match-end 0))
790808
nil))))
791-
(when (setq possible-delim (re-search-backward open-regexp nil t))
809+
(when (setq possible-delim (re-search-backward open-regexp (max (point-min) (- (point) limit)) t))
792810
(setq open-match-string (match-string 2))
793811
(setq str-start (match-end 2))))
794812

@@ -823,7 +841,10 @@ Quoting conventions recognized are:
823841
(regexp-quote texinfo-close-quote))
824842
start (point))))
825843

826-
(progn (while (and (setq possible-delim (search-forward texinfo-close-quote nil t))
844+
(progn (while (and (setq possible-delim (search-forward
845+
texinfo-close-quote
846+
(min (point-max) (+ (point) limit))
847+
t))
827848
(= (or (char-before (match-beginning 0)) 0) ?\\)))
828849
possible-delim)
829850
(setq str-end (match-beginning 0)
@@ -839,7 +860,10 @@ Quoting conventions recognized are:
839860
;; closing delimiter char to ensure it is not
840861
;; backslash quoted and so the right delimiter is matched.
841862
;; Find the matching closing delimiter
842-
(progn (while (and (setq possible-delim (search-forward open-match-string nil t))
863+
(progn (while (and (setq possible-delim
864+
(search-forward open-match-string
865+
(min (point-max) (+ (point) limit))
866+
t))
843867
(= (or (char-before (match-beginning 0)) 0) ?\\)))
844868
possible-delim)
845869
(setq str-end (match-beginning 0))
@@ -1148,6 +1172,13 @@ descriptors."
11481172
(setq seq (seq-drop seq size)))
11491173
(nreverse result)))
11501174

1175+
;;;###autoload
1176+
(defun hypb:sqlite-p ()
1177+
"Return non-nil if Emacs has available SQLite support."
1178+
(if (fboundp 'sqlite-available-p)
1179+
(sqlite-available-p)
1180+
(fboundp 'sqlite-open)))
1181+
11511182
(defun hypb:straight-package-plist (pkg-string)
11521183
"Return package info for a straight.el built package with name PKG-STRING.
11531184
The package info is a property list of package-name,

0 commit comments

Comments
 (0)