branch: externals/hyperbole commit cf8c30b0800cd3a0020b580800dab6d159096726 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
kbd-key:key-series-to-events - Use kbd macros except with Hypb menus Should help eliminate race conditions. --- ChangeLog | 16 +++++++++++++++- hib-kbd.el | 25 +++++++++++++++++-------- hui-mini.el | 10 +++++----- hywiki.el | 39 +++++++++++++++++++-------------------- test/hywiki-tests.el | 1 - 5 files changed, 56 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index fce6b83e68..17d65229d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2025-08-30 Bob Weiner <r...@gnu.org> + +* hui-mini.el: Replace all (beep) calls with (beep t) so do not exit keyboard + macros when meant only as an interactive user alert. + +* hib-kbd.el (kbd-key:key-series-to-events): Rewrite to execute 'key-series' + as a keyboard macro immediately (to reduce race conditions) unless it + contains a Hyperbole minibuffer menu in which case continue to queue + in `unread-command-events' because the Hyperbole minibuffer menu does not + work within keyboard macros. + +* hywiki.el (hywiki-org-link-resolve): Rename to 'hywiki-reference-to-referent'. + (hywiki-reference-to-org-link): Simplify conversion when no + 'description' is given to just [[hy:reference]]. + 2025-08-29 Bob Weiner <r...@gnu.org> * hui-select.el (hui-select-set-region): Fix so selection of a whole @@ -6,7 +21,6 @@ * hywiki.el (hywiki-word-to-org-link): Rewrite to minimize text in the Org links created. Use 'hy:' protocol prefix. - (hywiki-org-link-resolve): Rename to 'hywiki-reference-to-referent'. (hywiki-word-to-org-link): Rename to 'hywiki-reference-to-org-link'. (hywiki-convert-words-to-org-links): Rename to 'hywiki-references-to-org-links'. diff --git a/hib-kbd.el b/hib-kbd.el index 9c58fc64b4..3b6b4189da 100644 --- a/hib-kbd.el +++ b/hib-kbd.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 22-Nov-91 at 01:37:57 -;; Last-Mod: 29-Aug-25 at 12:52:43 by Bob Weiner +;; Last-Mod: 30-Aug-25 at 12:10:55 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -225,16 +225,25 @@ Restore \\`M-x' binding to ORIG-M-X-BINDING." (global-set-key [?\M-x] orig-M-x-binding)) (defun kbd-key:key-series-to-events (key-series) - "Insert the KEY-SERIES as a series of keyboard events. + "Insert the normalized KEY-SERIES as a series of keyboard events. The events are inserted into Emacs `unread-command-events' stream. Emacs then executes them when its command-loop regains control." - (setq unread-command-events (nconc unread-command-events - ;; Cons t here to ensure events - ;; are added to command-keys. - (mapcar (lambda (e) (cons t e)) - (listify-key-sequence - (kbd-key:kbd key-series)))))) + (if (and (stringp key-series) + (let ((hyperbole-key-desc (key-description (car (where-is-internal #'hyperbole))))) + (string-match (format "%sC-h h\\|C-hh\\|h\\|M-x hyperbole RET" + (if (equal hyperbole-key-desc "C-h h") + "" + ;; Add any custom binding for Hyperbole minibuffer menus + (concat hyperbole-key-desc "\\|"))) + key-series))) + (setq unread-command-events (nconc unread-command-events + ;; Cons t here to ensure events + ;; are added to command-keys. + (mapcar (lambda (e) (cons t e)) + (listify-key-sequence + (kbd-key:kbd key-series))))) + (execute-kbd-macro (kbd-key:kbd key-series)))) (defun kbd-key:doc (key-series &optional full) "Show first line of doc for binding of keyboard KEY-SERIES in minibuffer. diff --git a/hui-mini.el b/hui-mini.el index 490b4044ad..b514ad6613 100644 --- a/hui-mini.el +++ b/hui-mini.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 15-Oct-91 at 20:13:17 -;; Last-Mod: 29-Aug-25 at 03:49:50 by Bob Weiner +;; Last-Mod: 30-Aug-25 at 11:02:42 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -100,7 +100,7 @@ documentation, not the full text." (interactive (list nil nil nil nil)) (if (and hui:menu-p (> (minibuffer-depth) 0)) - (progn (beep) nil) + (progn (beep t) nil) (unwind-protect (progn (hyperbole-mode 1) @@ -216,7 +216,7 @@ documentation, not the full text." "Invoke the Hyperbole minibuffer menu and return menu keys pressed. Return nil when already in a Hyperbole minibuffer menu." (if (and hui:menu-p (> (minibuffer-depth) 0)) - (progn (beep) nil) + (progn (beep t) nil) (unwind-protect (progn (hyperb:init-menubar) @@ -461,7 +461,7 @@ documentation, not the full text." (hui:menu-read-from-minibuffer "" menu-line hui:menu-mode-map nil t)))) keys)) - (beep) + (beep t) (setq hargs:reading-type 'hmenu) (discard-input)) ;; Here, the minibuffer has been exited, and `key' has been set to one of: @@ -481,7 +481,7 @@ documentation, not the full text." ((eq key 0) nil) ((eq key abort-char) - (beep) + (beep t) (set--this-command-keys (hui:menu-this-command-keys hui:menu-abort)) (setq this-command #'hui:menu-abort) nil) diff --git a/hywiki.el b/hywiki.el index 0459311860..c1887d61da 100644 --- a/hywiki.el +++ b/hywiki.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Apr-24 at 22:41:13 -;; Last-Mod: 29-Aug-25 at 19:39:57 by Bob Weiner +;; Last-Mod: 30-Aug-25 at 10:04:23 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1577,41 +1577,40 @@ simplifies to: (defun hywiki-reference-to-org-link (reference &optional description) "Convert a HyWiki REFERENCE and an optional DESCRIPTION to an Org link." ;; \"[[file:<hywiki-directory>/WikiWord.org::Multi-Word Section][WikiWord#Multi-Word Section]]\". - (let ((referent (hywiki-parse-reference reference :full-data))) + (let ((referent (hywiki-reference-to-referent reference :full-data))) (when (stringp (car referent)) (let* ((path-word-suffix referent) (path (file-relative-name (nth 0 path-word-suffix))) - (path-stem (when path - (file-name-sans-extension path))) - (word (nth 1 path-word-suffix)) + ;; (path-stem (when path + ;; (file-name-sans-extension path))) (suffix (nth 2 path-word-suffix)) - (desc (cond (description) - (suffix (when word - (format "%s%s" word suffix))) - (word))) - suffix-no-hashmark) + (desc description) + ;; suffix-no-hashmark + ) (unless (and suffix (not (string-empty-p suffix))) (setq suffix nil)) - (setq suffix-no-hashmark (when suffix (substring suffix 1))) + ;; (setq suffix-no-hashmark (when suffix (substring suffix 1))) ;; (when (or (not buffer-file-name) ;; (string-equal path (file-name-nondirectory buffer-file-name))) ;; (setq path nil)) (cond (desc (if path - (if suffix - ;; "[[file:path-stem.org::suffix][desc]" - (format "[[file:%s.org::%s][%s]]" - path-stem suffix-no-hashmark desc) - ;; "[[file:path-stem.org][desc]]") - (format "[[file:%s.org][%s]]" path-stem desc)) + ;; "[[hy:reference]]" + (format "[[%s:%s]]" hywiki-org-link-type reference) + ;; (if suffix + ;; ;; "[[file:path-stem.org::suffix][desc]" + ;; (format "[[file:%s.org::%s][%s]]" + ;; path-stem suffix-no-hashmark desc) + ;; ;; "[[file:path-stem.org][desc]]") + ;; (format "[[file:%s.org][%s]]" path-stem desc)) (if suffix ;; "[[suffix][desc]]" (format "[[%s][%s]]" suffix desc) ;; "[[desc]]" (format "[[%s]]" desc)))) (path - ;; "[[file:path-stem.org][word]]" - (format "[[file:%s.org][%s]]" path-stem word))))))) + ;; "[[hy:reference]]" + (format "[[%s:%s]]" hywiki-org-link-type reference))))))) (defun hywiki-maybe-at-wikiword-beginning () "Return non-nil if previous character is one preceding a HyWiki word. @@ -2886,7 +2885,7 @@ backend." (_ path)) link))) -(defun hywiki-parse-reference (reference &optional full-data) +(defun hywiki-reference-to-referent (reference &optional full-data) "Resolve HyWikiWord REFERENCE to its referent file or other type of referent. If the referent is not a file type, return (referent-type . referent-value). diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index a6e8c3e799..51789cace5 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -968,7 +968,6 @@ body B (ert-deftest hywiki-tests--published-html-links-to-word-and-section () "Verify published html links to WikiWord and section." - :expected-result :failed (let* ((hywiki-directory (make-temp-file "hywiki_" t)) org-publish-project-alist (hywiki-org-publishing-directory (make-temp-file "public_html_" t))