branch: externals/hyperbole commit cc1c0529cff22a25c11d3a2609583350f7f70d97 Merge: d3203181fc a366cc9ffd Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Merge branch 'master' into rsw --- ChangeLog | 14 ++++ hbut.el | 12 +-- hsys-org.el | 3 +- hsys-xref.el | 5 +- hui-mouse.el | 4 +- hui-select.el | 3 +- hywiki.el | 4 +- test/hui-mouse-tests.el | 18 ++--- test/hywiki-tests.el | 200 ++++++++++++------------------------------------ 9 files changed, 86 insertions(+), 177 deletions(-) diff --git a/ChangeLog b/ChangeLog index 663d10fc92..46c8426615 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,20 @@ * hypb.el (hypb:in-string-p): Add optional 'max-lines' arg to limit the search to that many full buffer lines starting with the line beginning +2025-04-15 Mats Lidell <ma...@gnu.org> + +* test/hywiki-tests.el (hywiki-tests--command) + (hywiki-tests--save-referent-command) + (hywiki-tests--save-referent-command-use-menu) + (hywiki-tests--save-referent-find-use-menu) + (hywiki-tests--save-referent-info-index-use-menu): Clean up + hywiki-tests.el from FIXME comments and add the related tests. + +* hui-mouse.el (hkey-alist): Cleanup. Remove whitespace. + +* test/hui-mouse-tests.el (hui-mouse-tests--hkey-alist): Defvar + vertico-mode for bound-and-true-p to see the let value. + 2025-04-14 Bob Weiner <r...@gnu.org> * test/hui-mouse-tests.el (hui-mouse-tests--hkey-alist): Update with new diff --git a/hbut.el b/hbut.el index b17c051acd..bc250da9f0 100644 --- a/hbut.el +++ b/hbut.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 18-Sep-91 at 02:57:09 -;; Last-Mod: 14-Apr-25 at 23:07:21 by Bob Weiner +;; Last-Mod: 16-Apr-25 at 10:42:06 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -892,8 +892,8 @@ Return the symbol for the button when found, else nil." ;;; ======================================================================== (defun hattr:actype-is-p (actype-symbol &optional hbut-symbol) - "Return t if ACTYPE-SYMBOL matches an hbut's 'actype attr value. -The hbut used defaults to 'hbut:current or the optional HBUT-SYMBOL." + "Return t if ACTYPE-SYMBOL matches an hbut's \='actype attr value. +The hbut used defaults to \='hbut:current or the optional HBUT-SYMBOL." (hattr:is-p 'actype (or (actype:def-symbol actype-symbol) actype-symbol) hbut-symbol)) @@ -955,14 +955,14 @@ Return TO-HBUT." (get obj-symbol attr-symbol)) (defun hattr:ibtype-is-p (ibtype-symbol &optional ibut-symbol) - "Return t if IBTYPE-SYMBOL matches an ibut's 'categ attr value. -The ibut used defaults to 'hbut:current or the optional IBUT-SYMBOL." + "Return t if IBTYPE-SYMBOL matches an ibut's \='categ attr value. +The ibut used defaults to \='hbut:current or the optional IBUT-SYMBOL." (hattr:is-p 'categ (or (ibtype:elisp-symbol ibtype-symbol) ibtype-symbol) ibut-symbol)) (defun hattr:is-p (attr value &optional hbut-symbol) - "Return t if ATTR has VALUE for 'hbut:current or optional HBUT-SYMBOL." + "Return t if ATTR has VALUE for \='hbut:current or optional HBUT-SYMBOL." (and (symbolp attr) attr (eq (hattr:get (or (and (symbolp hbut-symbol) hbut-symbol) 'hbut:current) attr) diff --git a/hsys-org.el b/hsys-org.el index d4a74c6477..f4f173f9c3 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: 13-Apr-25 at 04:30:30 by Bob Weiner +;; Last-Mod: 14-Apr-25 at 15:47:21 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -509,7 +509,6 @@ a non-Org buffer type." (if (derived-mode-p 'org-mode) (let* ((org-plist (hsys-org-thing-at-p)) (type (plist-get org-plist :type)) - (path (plist-get org-plist :path)) label-start-end) (when (eq type 'link) (save-match-data diff --git a/hsys-xref.el b/hsys-xref.el index 798f598119..d0973bebd2 100644 --- a/hsys-xref.el +++ b/hsys-xref.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 2-Mar-25 at 18:11:45 by Bob Weiner +;; Last-Mod: 14-Apr-25 at 15:51:27 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -27,6 +27,7 @@ ;;; ************************************************************************ (declare-function smart-emacs-lisp-mode-p "hmouse-tag") +(declare-function hpath:at-p "hpath") ;;; ************************************************************************ ;;; Public functions @@ -49,7 +50,7 @@ (car (hsys-xref-definitions identifier))) (defun hsys-xref-identifier-at-point () - ;; Return nil if xref returns a pathname as an identifier + "Return nil if xref returns a pathname as an identifier." (unless (hpath:at-p nil t) (xref-backend-identifier-at-point (xref-find-backend)))) diff --git a/hui-mouse.el b/hui-mouse.el index 49f95df4db..79b9584993 100644 --- a/hui-mouse.el +++ b/hui-mouse.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-89 -;; Last-Mod: 13-Apr-25 at 14:49:05 by Bob Weiner +;; Last-Mod: 15-Apr-25 at 12:51:50 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -260,7 +260,7 @@ Its default value is `smart-scroll-down'. To disable it, set it to ((and (bound-and-true-p vertico-mode) ;; Is vertico prompting for an argument? (vertico--command-p nil (current-buffer))) - . ((funcall (lookup-key vertico-map (kbd "M-RET"))) + . ((funcall (lookup-key vertico-map (kbd "M-RET"))) . (funcall (lookup-key vertico-map (kbd "M-RET"))))) ;; ;; If in the minibuffer and reading a non-menu Hyperbole argument diff --git a/hui-select.el b/hui-select.el index 44e734f071..523d871a0c 100644 --- a/hui-select.el +++ b/hui-select.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Oct-96 at 02:25:27 -;; Last-Mod: 27-Feb-25 at 21:24:19 by Bob Weiner +;; Last-Mod: 14-Apr-25 at 15:53:22 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -327,6 +327,7 @@ Used to include a final line when marking indented code.") ;;; Public declarations ;;; ************************************************************************ +(defvar hbut:syntax-table) ; "hbut.el" (defvar help-mode-syntax-table) ; "help-mode.el" (defvar hkey-init) ; "hyperbole.el" (defvar hkey-value) ; "hui-mouse.el" diff --git a/hywiki.el b/hywiki.el index ca4a901272..19236728ee 100644 --- a/hywiki.el +++ b/hywiki.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Acpr-24 at 22:41:13 -;; Last-Mod: 18-Apr-25 at 21:53:17 by Bob Weiner +;; Last-Mod: 18-Apr-25 at 21:59:30 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2833,7 +2833,7 @@ Word may be of form: 2. If WORD is the symbol, :range, and there is a HyWikiWord at point with an existing referent, return the tuple of values: (word word-start word-end) instead of the word; otherwise, return the tuple - '(nil nil nil). + \='(nil nil nil). When using the word at point, a call to `hywiki-active-in-current-buffer-p' at point must return non-nil or this function will return nil." diff --git a/test/hui-mouse-tests.el b/test/hui-mouse-tests.el index 358804656a..76334cec8d 100644 --- a/test/hui-mouse-tests.el +++ b/test/hui-mouse-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 15-Mar-25 at 22:39:37 -;; Last-Mod: 15-Apr-25 at 01:03:12 by Bob Weiner +;; Last-Mod: 15-Apr-25 at 13:13:21 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -34,16 +34,14 @@ (should (equal (hkey-actions) (cons '(smart-dired-sidebar) '(smart-dired-sidebar))))) - ;; !! FIXME: In CI/CD tests, the hkey-alist smart-prog-at-tag-p is - ;; triggering instead of the vertico clause. Works interactively - ;; but maybe needs more context specification. Disable for now. ;; Vertico - ;; (let ((ivy-mode nil) - ;; (vertico-mode t)) - ;; (mocklet ((vertico--command-p => t)) - ;; (should (equal (hkey-actions) - ;; (cons '(funcall (lookup-key vertico-map (kbd "M-RET"))) - ;; '(funcall (lookup-key vertico-map (kbd "M-RET")))))))) + (defvar vertico-mode) + (let ((ivy-mode nil) + (vertico-mode t)) + (mocklet ((vertico--command-p => t)) + (should (equal (hkey-actions) + (cons '(funcall (lookup-key vertico-map (kbd "M-RET"))) + '(funcall (lookup-key vertico-map (kbd "M-RET")))))))) ) (provide 'hui-mouse-tests) diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index efc1071d6a..3dd41745aa 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -722,7 +722,7 @@ Both mod-time and checksum must be changed for a test to return true." ("WikiWord#Bsection-subsection" . "** Bsection subsection") ("WikiWord#Bsection-subsection:L2" . "body B") ("WikiWord#Bsection-subsection:L2:C2" . "dy B") - ;; FIXME: Uncomment when implemented. + ;; !! FIXME: Uncomment when implemented. ;; ("(WikiWord#Bsection subsection)" . "** Bsection subsection") ;; ("(WikiWord#Asection)" . "* Asection") ))) @@ -1004,24 +1004,6 @@ Note special meaning of `hywiki-allow-plurals-flag'." (hywiki-get-referent wikiword)))) (hy-delete-dir-and-buffer hywiki-directory)))) -;;; FIXME -;; Without creating an initial page the test case above oddly fails on -;; first run when executed interactively in a fresh Emacs. Such as -;; running "make all-tests" in a shell. Why? -;; -;; (ert-deftest hywiki-tests--add-org-roam-node () -;; "Verify `hywiki-add-org-roam-node'." -;; (let* ((hywiki-directory (make-temp-file "hywiki" t)) -;; (wikiword (hy-make-random-wikiword))) -;; (unwind-protect -;; (mocklet (((hypb:require-package 'org-roam) => t) -;; ((org-roam-node-read) => "node") -;; ((org-roam-node-title "node") => "node-title")) -;; (hywiki-add-org-roam-node wikiword) -;; (should (equal '(org-roam-node . "node-title") -;; (hywiki-get-referent wikiword)))) -;; (hy-delete-dir-and-buffer hywiki-directory)))) - (defmacro hywiki-tests--referent-test (expected &rest prepare) "Referent test boilerplate code. EXPECTED is the result expected from hywiki-get-referent. PREPARE sets @@ -1070,50 +1052,9 @@ up the test." ; The failure is intermittent. See expanded test case below. (skip-unless (not noninteractive)) (hywiki-tests--referent-test - (cons 'key-series "{ABC}") - (should (hact 'kbd-key "C-u C-h hhck{ABC} RET")) - (hy-test-helpers:consume-input-events))) - -;; !! TODO: Have to make this work or remove it. -;; Expanded for easier debugging -;; (ert-deftest hywiki-tests--save-referent-keyseries-use--menu-expanded () -;; "Verify saving and loading a referent works when using Hyperbole's menu." -;; :expected-result :failed -;; ;; The entered key series is inserted into the WikiWord file. See -;; ;; comment below. The failure is intermittent. -;; (skip-unless (not noninteractive)) -;; (let* ((hywiki-directory (make-temp-file "hywiki" t)) -;; (wiki-page (cdr (hywiki-add-page "WikiPage" ))) -;; (wiki-referent "WikiReferent") -;; (mode-require-final-newline nil)) -;; (unwind-protect -;; (progn -;; (find-file wiki-page) -;; (insert wiki-referent) -;; (save-buffer) -;; (goto-char 4) - -;; (should (hact 'kbd-key "C-u C-h hhck{ABC} RET")) -;; (hy-test-helpers:consume-input-events) - -;; ;; The buffer contents is changed and now reads -;; ;; "Wik{ABC}iReferent" as the next should verifies. The -;; ;; second should is the expected behavior. No change in the -;; ;; WikiPage buffer. -;; (should (string= "Wik{ABC}iReferent" (buffer-substring-no-properties (point-min) (point-max)))) -;; (should (string= wiki-referent (buffer-substring-no-properties (point-min) (point-max)))) - -;; (should (file-exists-p (hywiki-cache-default-file))) -;; (should (equal '(key-series . "{ABC}") (hywiki-get-referent wiki-referent))) - -;; ;; Simulate reload from cache -;; (hywiki-cache-save) -;; (setq hywiki--referent-hasht nil) -;; (hywiki-make-referent-hasht) - -;; (should (equal '(key-series . "{ABC}") (hywiki-get-referent wiki-referent)))) -;; (hy-delete-files-and-buffers (list wiki-page (hywiki-cache-default-file))) -;; (hy-delete-dir-and-buffer hywiki-directory)))) + (cons 'key-series "{ABC}") + (should (hact 'kbd-key "C-u C-h hhck{ABC} RET")) + (hy-test-helpers:consume-input-events))) ;; Bookmark (ert-deftest hywiki-tests--save-referent-bookmark () @@ -1135,81 +1076,43 @@ up the test." ;; Command -;; (defun hywiki-tests--command (_wikiword) -;; "Test command." -;; (interactive) -;; t) - -;; ;; FIXME: Command get the referent as argument which is not useful. -;; (ert-deftest hywiki-tests--save-referent-command () -;; "Verify saving and loading a referent command works." -;; (hywiki-tests--referent-test -;; (cons 'command #'hywiki-tests--command) -;; (with-simulated-input "hywiki-tests--command RET" -;; (hywiki-add-command wiki-referent)))) - -;; (ert-deftest hywiki-tests--save-referent-command-use-menu () -;; "Verify saving and loading a referent command works using Hyperbole's menu.." -;; (skip-unless (not noninteractive)) -;; (hywiki-tests--referent-test -;; (cons 'command #'hpath:find) -;; (should (hact 'kbd-key "C-u C-h hhcc hpath:find RET")) -;; (hy-test-helpers:consume-input-events))) - -;; Expanded for debugging -;; FIXME: There is a race here. It mostly fails but on rerun it can be -;; made to work. -;; (ert-deftest hywiki-tests--save-referent-command-use-menu-expanded () -;; "Verify saving and loading a referent bookmark works using Hyperbole's menu.." -;; (skip-unless (not noninteractive)) -;; (let* ((hywiki-directory (make-temp-file "hywiki" t)) -;; (wiki-page (cdr (hywiki-add-page "WikiPage" ))) -;; (wiki-referent "WikiReferent") -;; (mode-require-final-newline nil)) -;; (unwind-protect -;; (progn -;; (find-file wiki-page) -;; (insert wiki-referent) -;; (save-buffer) -;; (goto-char 4) - -;; (should (hact 'kbd-key "C-u C-h hhcc hpath:find RET")) -;; (hy-test-helpers:consume-input-events) - -;; (should (string= wiki-referent (buffer-substring-no-properties (point-min) (point-max)))) -;; (should (file-exists-p (hywiki-cache-default-file))) -;; (should (equal (cons 'command #'hpath:find) (hywiki-get-referent wiki-referent))) - -;; ;; Simulate reload from cache -;; (hywiki-cache-save) -;; (setq hywiki--referent-hasht nil) -;; (hywiki-make-referent-hasht) - -;; (should (equal (cons 'command #'hpath:find) (hywiki-get-referent wiki-referent)))) -;; (hy-delete-files-and-buffers (list wiki-page (hywiki-cache-default-file))) -;; (hy-delete-dir-and-buffer hywiki-directory)))) +(defun hywiki-tests--command (wikiword) + "Test command." + (interactive) + (should (string= "WikiReferent" wikiword))) + +(ert-deftest hywiki-tests--save-referent-command () + "Verify saving and loading a referent command works." + (hywiki-tests--referent-test + (cons 'command #'hywiki-tests--command) + (with-simulated-input "hywiki-tests--command RET" + (hywiki-add-command wiki-referent)))) + +(ert-deftest hywiki-tests--save-referent-command-use-menu () + "Verify saving and loading a referent command works using Hyperbole's menu.." + (skip-unless (not noninteractive)) + (hywiki-tests--referent-test + (cons 'command #'hywiki-tests--command) + (should (hact 'kbd-key "C-u C-h hhcc hywiki-tests--command RET")) + (hy-test-helpers:consume-input-events))) ;; Find (ert-deftest hywiki-tests--save-referent-find () "Verify saving and loading a referent find works." (hywiki-tests--referent-test - (cons 'find #'hywiki-word-grep) - (hywiki-add-find wiki-referent))) - -;; FIXME - Find defaults to search the referent which is not a likely -;; use case. Should it not prompt user for the search string and -;; not assume the referent is what you want to search for? - -;; FIXME - fails on 28.2 if executed with other test case!? -;; (ert-deftest hywiki-tests--save-referent-find-use-menu () -;; "Verify saving and loading a referent find works using Hyperbole's menu.." -;; (skip-unless (not noninteractive)) -;; (hywiki-tests--referent-test -;; (cons 'find #'hywiki-word-grep) -;; (with-mock -;; (mock (hywiki-word-grep "WikiReferent") => t) -;; (should (hact 'kbd-key "C-u C-h hhcf")) -;; (hy-test-helpers:consume-input-events)))) + (cons 'find #'hywiki-word-grep) + (hywiki-add-find wiki-referent))) + +(ert-deftest hywiki-tests--save-referent-find-use-menu () + "Verify saving and loading a referent find works using Hyperbole's menu.." + (skip-unless (not noninteractive)) + (skip-unless (not (version< emacs-version "29"))) ;; Fails on 28!? + (hywiki-tests--referent-test + (cons 'find #'hywiki-word-grep) + (with-mock + (mock (hywiki-word-grep "WikiReferent") => t) + (should (hact 'kbd-key "C-u C-h hhcf")) + (hy-test-helpers:consume-input-events)))) ;; Global-button (ert-deftest hywiki-tests--save-referent-global-button () @@ -1239,8 +1142,6 @@ up the test." (hy-delete-file-and-buffer test-file))))) ;; HyRolo -;; FIXME: The search is over the name of the WikiWord which is likely -;; not what was intended. Test below is for completeness. (ert-deftest hywiki-tests--save-referent-hyrolo () "Verify saving and loading a referent hyrolo works." (hywiki-tests--referent-test @@ -1257,21 +1158,17 @@ up the test." (info "emacs") (hywiki-add-info-index wiki-referent))))) -;; FIXME: Does not work properly. Ends prematurely on reading in index -;; item, at least if starting from scratch, i.e., no *info* buffer -;; already created. -;; -- -;; (ert-deftest hywiki-tests--save-referent-info-index-use-menu () -;; "Verify saving and loading a referent info index works using Hyperbole's menu." -;; (skip-unless (not noninteractive)) -;; (hywiki-tests--referent-test -;; (cons 'info-index "(emacs)files") -;; (save-excursion -;; (unwind-protect -;; (progn -;; (should (hact 'kbd-key "C-u C-h hhcim emacs RET i files RET")) -;; (hy-test-helpers:consume-input-events)) -;; (kill-buffer "*info*"))))) +(ert-deftest hywiki-tests--save-referent-info-index-use-menu () + "Verify saving and loading a referent info index works using Hyperbole's menu." + (skip-unless (not noninteractive)) + (hywiki-tests--referent-test + (cons 'info-index "(emacs)files") + (save-excursion + (unwind-protect + (progn + (should (hact 'kbd-key "C-u C-h hhci (emacs)files RET")) + (hy-test-helpers:consume-input-events)) + (kill-buffer "*info*"))))) ;; Info node (ert-deftest hywiki-tests--save-referent-info-node () @@ -1320,8 +1217,7 @@ up the test." (hywiki-add-org-id wiki-referent))) (hy-delete-file-and-buffer filea)))))) -;; FIXME: Org-id links does not seem to work. -;; FIXME: Add test using Hyperbole's menu. +;; FIXME: Add Org-id links tests. ;; Org roam (ert-deftest hywiki-tests--save-referent-org-roam-node ()