diff --git a/ChangeLog b/ChangeLog index b9fc060b..f1c201b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2026-03-28 Bob Weiner + +* hypb.el (hypb:sqlite-p): Add to return non-nil when Emacs supports sqlite. + (hypb:advised-p): Add to test whether a function has been advised with + a specific function. + hsys-org.el (hsys-org-id-find-advice): Add as :before advice to `org-id-find' + to remove :before-until advice that `org-roam-id-find' adds if sqlite is not + available inside Emacs. + hactypes.el (link-to-org-id): + hibtypes.el (org-id, org-id:help): Remove call of `org-roam-id-find' since that + will be called when loaded by any call to `org-id-find' as `org-roam' advises + it. + 2026-03-26 Mats Lidell * test/hui-tests.el (hui--kill-region-delimited-text-and-yank-back): @@ -18,12 +31,20 @@ (hywiki-org-to-heading-instance): Use with-suppressed-warnings for obsolete org-show-entry. +2026-03-24 Bob Weiner + +* hibtypes.el (hib-link-to-file-line): Add missing 'let' for 'ext' variable, + fix indentation and change 'and' to 'when' for clarity. + 2026-03-23 Bob Weiner +* hypb.el (hypb:in-string-p): Limit searches to a max of 9000 chars for speed. + * hui-mouse.el (hkey-alist): Add 'profiler-report-mode' support for jumping to call tree items or expanding/collapsing their call trees. (smart-profiler-report, smart-profiler-report-assist): Add. man/hyperbole.texi (Smart Key - Profiler Report Mode): Add doc. + (smart-profiler-report): Fix display of found buffer. 2026-03-22 Mats Lidell diff --git a/hactypes.el b/hactypes.el index 542267f0..a0827190 100644 --- a/hactypes.el +++ b/hactypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 23-Sep-91 at 20:34:36 -;; Last-Mod: 15-Mar-26 at 14:44:00 by Bob Weiner +;; Last-Mod: 28-Mar-26 at 13:03:44 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -639,13 +639,12 @@ information on how to specify a mail reader to use." (hypb:error "(link-to-mail): No msg `%s' in file \"%s\"" mail-msg-id mail-file))))) -(defact link-to-org-id (id &optional title) - "Display the Org entry, if any, for ID with optional TITLE. +(defact link-to-org-id (id &optional _title) + "Display the Org entry, if any, for ID with optional _TITLE. ID is a uuid without any \\='id:' prefix." (when (stringp id) - (let* ((inhibit-message t) ;; Inhibit org-id-find status msgs - (m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker)) - (org-id-find id 'marker)))) + (let* ((inhibit-message t) ;; Inhibit `org-id-find' status msgs + (m (org-id-find id 'marker))) (when m (hact 'link-to-org-id-marker m))))) diff --git a/hibtypes.el b/hibtypes.el index 84c87e83..7508cde0 100644 --- a/hibtypes.el +++ b/hibtypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 20:45:31 -;; Last-Mod: 22-Mar-26 at 18:18:45 by Bob Weiner +;; Last-Mod: 28-Mar-26 at 13:02:39 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -191,12 +191,10 @@ only to prevent false matches." (re-search-forward ":\\(CUSTOM_\\)?ID:[ \t]+" (line-end-position) t))) (hact 'message "On Org ID definition; use {C-u M-RET} to copy a link to an ID.") - (when (let ((inhibit-message t) ;; Inhibit org-id-find status msgs + (when (let ((inhibit-message t) ;; Inhibit `org-id-find' status msgs (obuf (current-buffer)) (omode major-mode)) - (prog1 (setq m (or (and (featurep 'org-roam) - (org-roam-id-find id 'marker)) - (org-id-find id 'marker))) + (prog1 (setq m (org-id-find id 'marker)) ;; org-find-id sets current buffer mode to Org ;; mode even if ID is not found; switch it back ;; when necessary. @@ -218,9 +216,8 @@ If the referenced location is found, return non-nil." (setq id (substring id 3))) ;; Ignore ID definitions or when not on a possible ID (when (and id - (let ((inhibit-message t)) ;; Inhibit org-id-find status msgs - (setq m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker)) - (org-id-find id 'marker))))) + (let ((inhibit-message t)) ;; Inhibit `org-id-find' status msgs + (setq m (org-id-find id 'marker)))) (save-excursion (setq mpos (marker-position m)) (set-buffer (marker-buffer m)) @@ -1027,15 +1024,16 @@ LINE-NUM may be an integer or string." ((stringp source-loc) (setq file (expand-file-name file (file-name-directory source-loc)))) (t (setq file (or (hpath:prepend-shell-directory file) - ;; find-library-name will strip file - ;; suffixes, so use it only when the file - ;; either doesn't have a suffix or has a - ;; library suffix. - (and (or (null (setq ext (file-name-extension file))) - (member (concat "." ext) (get-load-suffixes))) - (ignore-errors (find-library-name file))) - (hpath:is-p (expand-file-name file)) - (hywiki-get-existing-page-file file))))) + ;; find-library-name will strip file + ;; suffixes, so use it only when the file + ;; either doesn't have a suffix or has a + ;; library suffix. + (let ((ext (file-name-extension file))) + (when (or (null ext) + (member (concat "." ext) (get-load-suffixes))) + (ignore-errors (find-library-name file)))) + (hpath:is-p (expand-file-name file)) + (hywiki-get-existing-page-file file))))) (when (file-exists-p (hpath:normalize file)) (actypes::link-to-file-line file line-num)))) diff --git a/hsys-org.el b/hsys-org.el index 9740ca3b..dac34566 100644 --- a/hsys-org.el +++ b/hsys-org.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 2-Jul-16 at 14:54:14 -;; Last-Mod: 14-Mar-26 at 18:38:59 by Bob Weiner +;; Last-Mod: 28-Mar-26 at 13:22:56 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -215,6 +215,18 @@ otherwise, just match to the single tag around point." (interactive) (hsys-org-get-agenda-tags #'hywiki-tags-view)) +(defun hsys-org-id-find-advice (&rest _) + "If `org-roam' is loaded and has advised `org-id-find' with the function +'org-roam-id-find' but Emacs does not have the `sqlite' module, then any +call to `org-id-find' will fail. This :before advice function fixes this +by removing the `org-roam' advice from `org-id-find'." + (when (and (fboundp 'org-roam-id-find) + (not (hypb:sqlite-p)) + (hypb:advised-p 'org-id-find 'org-roam-id-find)) + (advice-remove #'org-id-find #'org-roam-id-find))) + +(advice-add 'org-id-find :before #'hsys-org-id-find-advice) + (defun hsys-org-agenda-tags () "On an `org-directory' tag, use `hsys-org-tags-view' to list dir tag matches. If on a colon, match to sections with all tags around point; diff --git a/hui-mouse.el b/hui-mouse.el index ba1e12fe..e0210abf 100644 --- a/hui-mouse.el +++ b/hui-mouse.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-89 -;; Last-Mod: 23-Mar-26 at 18:49:48 by Bob Weiner +;; Last-Mod: 23-Mar-26 at 21:47:31 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2223,13 +2223,12 @@ If key is pressed: (quit-window)) ;; If on the text of an entry, jump to its definition if is a link ((text-property-any (point) (1+ (point)) 'face 'link) - (let* ((curr-buffer nil) - (find-function-after-hook '((lambda () - (setq curr-buffer (current-buffer)))))) - (hpath:display-buffer (save-window-excursion - (profiler-report-find-entry) - curr-buffer))) - t))) + (let* ((dbuf) + (obuf (current-buffer))) + (profiler-report-find-entry) + (setq dbuf (window-buffer (selected-window))) + (switch-to-buffer obuf) + (hpath:display-buffer dbuf))))) (defun smart-profiler-report-assist () "Use a single assist key or mouse assist key to toggle profiler call trees. diff --git a/hypb.el b/hypb.el index 6cd88e9d..fddfceb6 100644 --- a/hypb.el +++ b/hypb.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6-Oct-91 at 03:42:38 -;; Last-Mod: 22-Mar-26 at 01:29:41 by Bob Weiner +;; Last-Mod: 28-Mar-26 at 11:58:58 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -145,6 +145,18 @@ text will become visible." (setq buffer-invisibility-spec (cons element buffer-invisibility-spec)))) +;;;###autoload +(defun hypb:advised-p (advised-function advice-function) + "Return t if ADVISED-FUNCTION is advised with ADVICE-FUNCTION. +Uses the newer \"nadvice\" elisp library, not \"advice\"." + (let (found) + (when (advice--p (symbol-function advised-function)) + (advice-mapc (lambda (advs _props) + (when (eq advs advice-function) + (setq found t))) + advised-function)) + found)) + ;;;###autoload (defun hypb:activate-interaction-log-mode () "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." (error "(hypb:hkey-help-file): Non-existent file: \"%s\"" help-file)))))) +(defvar hypb:in-string-and-tick (cons nil 0)) + (defun hypb:in-string-p (&optional max-lines range-flag) "Return non-nil iff point is within a string and not on the closing quote. @@ -724,7 +738,8 @@ the positions exclude the delimiters. To prevent searching back to the buffer start and producing slow performance, this limits its count of quotes found prior to point to the beginning of the first line prior to point that contains a -non-backslashed quote mark. +non-backslashed quote mark and limits string length to a maximum +of 9000 characters. Quoting conventions recognized are: double-quotes: \"str\"; @@ -733,7 +748,10 @@ Quoting conventions recognized are: Python triple single-quotes: '''str'''; Python triple double-quotes: \"\"\"str\"\"\"; Texinfo open and close quotes: ``str''." + (let ((list-of-unformatted-open-close-regexps (eval hypb:in-string-mode-regexps)) + ;; search limit length + (limit 9000) list-of-open-close-regexps) (if (and list-of-unformatted-open-close-regexps (listp list-of-unformatted-open-close-regexps) @@ -783,12 +801,12 @@ Quoting conventions recognized are: (looking-at orig-close-regexp))) (/= (or (char-before) 0) ?\\) (setq open-match-string (match-string 2))) - (while (and (setq possible-delim (search-backward open-match-string nil t)) + (while (and (setq possible-delim (search-backward open-match-string (max (point-min) (- (point) limit)) t)) (if (= (or (char-before) 0) ?\\) (goto-char (1- (point))) (progn (setq str-start (match-end 0)) nil)))) - (when (setq possible-delim (re-search-backward open-regexp nil t)) + (when (setq possible-delim (re-search-backward open-regexp (max (point-min) (- (point) limit)) t)) (setq open-match-string (match-string 2)) (setq str-start (match-end 2)))) @@ -823,7 +841,10 @@ Quoting conventions recognized are: (regexp-quote texinfo-close-quote)) start (point)))) - (progn (while (and (setq possible-delim (search-forward texinfo-close-quote nil t)) + (progn (while (and (setq possible-delim (search-forward + texinfo-close-quote + (min (point-max) (+ (point) limit)) + t)) (= (or (char-before (match-beginning 0)) 0) ?\\))) possible-delim) (setq str-end (match-beginning 0) @@ -839,7 +860,10 @@ Quoting conventions recognized are: ;; closing delimiter char to ensure it is not ;; backslash quoted and so the right delimiter is matched. ;; Find the matching closing delimiter - (progn (while (and (setq possible-delim (search-forward open-match-string nil t)) + (progn (while (and (setq possible-delim + (search-forward open-match-string + (min (point-max) (+ (point) limit)) + t)) (= (or (char-before (match-beginning 0)) 0) ?\\))) possible-delim) (setq str-end (match-beginning 0)) @@ -1148,6 +1172,13 @@ descriptors." (setq seq (seq-drop seq size))) (nreverse result))) +;;;###autoload +(defun hypb:sqlite-p () + "Return non-nil if Emacs has available SQLite support." + (if (fboundp 'sqlite-available-p) + (sqlite-available-p) + (fboundp 'sqlite-open))) + (defun hypb:straight-package-plist (pkg-string) "Return package info for a straight.el built package with name PKG-STRING. The package info is a property list of package-name, diff --git a/man/hyperbole.html b/man/hyperbole.html index 6f5228f3..9cb5697c 100644 --- a/man/hyperbole.html +++ b/man/hyperbole.html @@ -4,7 +4,7 @@