branch: externals/hyperbole commit 384b76d90689673b5c156d5d4ca8c470cd568273 Merge: 06608abdf9 540c4a3d74 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Merge branch 'master' into rsw --- ChangeLog | 77 ++++++++++++++++++++++++++ hibtypes.el | 23 +++++++- hsys-org.el | 10 ++-- hui-mouse.el | 28 +++++++--- hywiki.el | 12 +++-- test/MANIFEST | 4 ++ test/hargs-tests.el | 20 +++---- test/hibtypes-resources/TAGS | 3 ++ test/hibtypes-resources/test-data.el | 21 ++++++++ test/hibtypes-tests.el | 47 ++++++++-------- test/hmouse-drv-resources/TAGS | 3 ++ test/hmouse-drv-resources/test-data.el | 21 ++++++++ test/hmouse-drv-tests.el | 52 ++++++++---------- test/hmouse-info-tests.el | 13 ++--- test/hpath-tests.el | 4 +- test/hui-tests.el | 44 +++++++-------- test/hy-test-dependencies.el | 4 +- test/hy-test-helpers.el | 10 ++++ test/hywiki-tests.el | 99 ++++++++++++++++++++++++++++------ 19 files changed, 359 insertions(+), 136 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca85afc522..a1434134c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,83 @@ * hpath.el (hpath:file-position-to-line-and-column): Fix to shorten path in the current directory, not within the buffer of path. +2025-04-26 Mats Lidell <ma...@gnu.org> + +* hibtypes.el (smerge): Add ibut smerge. + +* hui-mouse.el (smart-magit): Add smerge support in magit-status-mode. + +* hywiki.el (hywiki-word-face-at-p): Add optional pos to enable reuse. + +* test/hy-test-helpers.el (hy-test-word-face-at-region): Simplify by + reusing hywiki-word-face-at-p. + +* test/hywiki-tests.el + (hywiki-tests--wikiword-step-check-verification-with-faces): Add + missing WikiWord, Hiho, required by the test. Enable the test for CI. + +* test/hywiki-tests.el: +* test/hui-tests.el: +* test/hmouse-info-tests.el: +* test/hmouse-drv-tests.el: +* test/hargs-tests.el: Use ert-simulate-keys. Replaces external dependency + on with-simulated-input. + +* test/hy-test-dependencies.el: Remove dependency on with-simulated-input. + +2025-04-25 Mats Lidell <ma...@gnu.org> + +* hsys-org.el: Require 'warnings to get definition of variables + `warning-minimum-level' and `warning-suppress-log-types' else causing + byte compilation warnings. + +* test/MANIFEST: Add resource folders. + +* test/hmouse-drv-resources/test-data.el: + test/hmouse-drv-resources/TAGS: + test/hibtypes-resources/test-data.el: + test/hibtypes-resources/TAGS: Test resources. + +* test/hmouse-drv-tests.el (hbut-ctags-vgrind-test, hbut-etags-test): Use + test resources. + +* test/hibtypes-tests.el (ibtypes::ctags-vgrind-test) + (ibtypes::etags-test): Use test resources. + +2025-04-23 Mats Lidell <ma...@gnu.org> + +* test/hywiki-tests.el (hywiki-tests--word-n-face-at): Verify that point + is at a WikiWord where WikiWord has hywiki--word-face set. + (hywiki-tests--with-face-test): Control type of WikiWord check. + (hywiki-tests--word-at): Use either hywiki-word-at or + hywiki-tests--word-n-face-at controlled by + hywiki-tests--with-face-test. + (hywiki-tests--verify-hywiki-word): Use hywiki-tests--word-at. + (hywiki-tests--wikiword-step-check-verification-with-faces): Run the + step-check test verifying WikiWords and faces. Test is behind failure + flag. + +* test/hy-test-helpers.el (hy-test-word-face-at-point): Check if + hywiki--word-face is set at point. + (hy-test-word-face-at-region): Check that region has hywiki--word-face set. + +2025-04-21 Mats Lidell <ma...@gnu.org> + +* test/hywiki-tests.el (hywiki-tests--wikiword-step-check): Update test + sequence. + +* hywiki.el (ibtypes::pathname, ibtypes::pathname-line-and-column): + Declare functions from hpath. + +* hsys-org.el (hsys-org-link-at-p): Reinsert let binding of label-start-end. + +* hbut.el (ibut:insert-text): Remove shadowed pcase. + +2025-04-20 Mats Lidell <ma...@gnu.org> + +* test/hywiki-tests.el (hywiki-tests--filename-same-as-wiki-word): Add + test for filename being the same as a WikiWord. + 2025-04-20 Bob Weiner <r...@gnu.org> * test/hui-tests.el (hui--link-possible-types): Change Outline Heading diff --git a/hibtypes.el b/hibtypes.el index 3d9be82144..83f8e8e5be 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: 19-Apr-25 at 17:51:14 by Bob Weiner +;; Last-Mod: 26-Apr-25 at 10:19:22 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -45,6 +45,7 @@ (require 'org-macs) ;; for org-uuid-regexp (require 'subr-x) ;; for string-trim (require 'thingatpt) +(eval-when-compile (require 'smerge-mode)) ;;; ************************************************************************ ;;; Public declarations @@ -1737,6 +1738,26 @@ If a boolean function or variable, display its value." ;; If you want to to disable ALL Hyperbole support within Org major ;; and minor modes, set the custom option `hsys-org-enable-smart-keys' to nil. +;;; ======================================================================== +;;; Resolve merge conflicts in smerge-mode +;;; ======================================================================== + +(defib smerge () + "Act on conflicts in merge buffers, i.e. when smerge-mode is active." + (when (bound-and-true-p smerge-mode) + (let (op) + (save-excursion + (beginning-of-line) + (cond ((looking-at smerge-end-re) + (setq op 'smerge-keep-lower)) + ((looking-at smerge-begin-re) + (setq op 'smerge-keep-upper)) + ((looking-at smerge-lower-re) + (setq op 'smerge-keep-all)))) + (when op + (ibut:label-set (match-string-no-properties 0) (match-beginning 0) (match-end 0)) + (hact op))))) + (run-hooks 'hibtypes-end-load-hook) (provide 'hibtypes) diff --git a/hsys-org.el b/hsys-org.el index f4f173f9c3..9a9352a4ac 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-Apr-25 at 15:47:21 by Mats Lidell +;; Last-Mod: 24-Apr-25 at 15:31:03 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -39,6 +39,7 @@ (require 'org-fold nil t) (require 'org-macs) (require 'package) +(require 'warnings) ;; Avoid any potential library name conflict by giving the load directory. (require 'set (expand-file-name "set" hyperb:dir)) @@ -537,9 +538,10 @@ a non-Org buffer type." (save-match-data ;; If this Org link matches a potential HyWiki word, ignore it. (when (not (and (fboundp 'hywiki-word-at) (hywiki-word-at))) - (if (setq label-start-end (ibut:label-p t "[" "]" t)) - (cons (nth 1 label-start-end) (nth 2 label-start-end)) - t))))))))) + (let ((label-start-end (ibut:label-p t "[" "]" t))) + (if label-start-end + (cons (nth 1 label-start-end) (nth 2 label-start-end)) + t)))))))))) ;; Assume caller has already checked that the current buffer is in org-mode. (defun hsys-org-heading-at-p (&optional _) diff --git a/hui-mouse.el b/hui-mouse.el index 79b9584993..075b88a9a5 100644 --- a/hui-mouse.el +++ b/hui-mouse.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-89 -;; Last-Mod: 15-Apr-25 at 12:51:50 by Mats Lidell +;; Last-Mod: 25-Apr-25 at 23:35:04 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1575,13 +1575,25 @@ If key is pressed: point (\"RET\" key binding) but display based on the value of `hpath:display-where'." (interactive) - (cond ((last-line-p) - (call-interactively (key-binding "q"))) - ((eolp) - (smart-scroll-up)) - (t - (let ((magit-display-buffer-function #'hpath:display-buffer)) - (call-interactively #'smart-magit-tab))))) + (let (op) + (cond ((last-line-p) + (call-interactively (key-binding "q"))) + ((eolp) + (smart-scroll-up)) + ((and + (eq major-mode 'magit-status-mode) + (save-excursion + (beginning-of-line) + (cond ((looking-at (regexp-quote "++>>>>>>>")) + (setq op 'magit-smerge-keep-lower)) + ((looking-at (regexp-quote "++<<<<<<<")) + (setq op 'magit-smerge-keep-upper)) + ((looking-at (regexp-quote "++=======")) + (setq op 'magit-smerge-keep-all))))) + (call-interactively op)) + (t + (let ((magit-display-buffer-function #'hpath:display-buffer)) + (call-interactively #'smart-magit-tab)))))) (defun smart-magit-assist () "Use an assist key or mouse key to jump to source and to hide/show changes. diff --git a/hywiki.el b/hywiki.el index 1ddafac5be..8d91089d45 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: 19-Apr-25 at 22:52:58 by Bob Weiner +;; Last-Mod: 20-Apr-25 at 22:27:39 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -175,6 +175,8 @@ (declare-function bookmark-completing-read "bookmark" (prompt &optional default)) (declare-function bookmark-location "bookmark" (bookmark-name-or-record)) (declare-function hsys-org-at-tags-p "hsys-org") +(declare-function ibtypes::pathname "hpath") +(declare-function ibtypes::pathname-line-and-column "hpath") (declare-function org-link-store-props "ol" (&rest plist)) (declare-function org-publish-property "ox-publish" (property project &optional default)) (declare-function org-roam-node-from-title-or-alias "org-roam-node" (s &optional nocase)) @@ -3171,9 +3173,11 @@ a HyWikiWord at point." (= (matching-paren (char-before (nth 1 range))) (char-after (nth 2 range)))))))) -(defun hywiki-word-face-at-p () - "Non-nil if but at point has `hywiki-word-face' property." - (hproperty:but-get (point) 'face hywiki-word-face)) +(defun hywiki-word-face-at-p (&optional pos) + "Non-nil if but at point or optional POS has `hywiki-word-face' property." + (unless pos + (setq pos (point))) + (hproperty:but-get pos 'face hywiki-word-face)) ;;;###autoload (defun hywiki-word-consult-grep (word) diff --git a/test/MANIFEST b/test/MANIFEST index 37356fdd7b..80854f59d0 100644 --- a/test/MANIFEST +++ b/test/MANIFEST @@ -33,3 +33,7 @@ kotl-orgtbl-tests.el - kotl orgtbl tests set-tests.el - mathematical set library tests smart-org-tests.el - smart-org-el tests test-helpers-tests.el - unit test of the test helpers + +--- HYPERBOLE TEST RESOURCES --- +hibtypes-resources - test resources for hibtypes-tests +hmouse-drv-resources - test resources for hmouse-drv-tests diff --git a/test/hargs-tests.el b/test/hargs-tests.el index 7fe53d852d..17b518e4b6 100644 --- a/test/hargs-tests.el +++ b/test/hargs-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 04-Feb-22 at 23:00:00 -;; Last-Mod: 20-Jan-24 at 19:38:11 by Mats Lidell +;; Last-Mod: 25-Apr-25 at 19:57:44 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -19,7 +19,7 @@ ;;; Code: (require 'ert) -(require 'with-simulated-input) +(require 'ert-x) (require 'hargs) (require 'hy-test-helpers "test/hy-test-helpers") @@ -29,15 +29,15 @@ (let ((file (make-temp-file "hypb"))) (unwind-protect (progn - (with-simulated-input "xyz RET" + (ert-simulate-keys "xyz\r" (should (string= (hargs:get "+I: ") "xyz"))) - (with-simulated-input "xyz RET" + (ert-simulate-keys "xyz\r" (should (string= (hargs:get "+L: ") "xyz"))) - (with-simulated-input '((insert "xyz" file) "RET")' + (ert-simulate-keys (concat "(\"xyz\" \"" file "\")\r") (should (equal (hargs:get "+M: ") (list "xyz" file)))) - (with-simulated-input "xyz RET" + (ert-simulate-keys "xyz\r" (should (string= (hargs:get "+V: ") "xyz"))) - (with-simulated-input "xyz RET" + (ert-simulate-keys "xyz\r" (should (string= (hargs:get "+X: ") "(dir)xyz"))) (should-error (hargs:get "+A: ") :type 'error)) (hy-delete-file-and-buffer file)))) @@ -67,11 +67,5 @@ (should (string= (cadr v) (hargs:sexpression-p))) (should (string= (caddr v) (hargs:sexpression-p t)))))) -;; This file can't be byte-compiled without `with-simulated-input' which -;; is not part of the actual dependencies, so: -;; Local Variables: -;; no-byte-compile: t -;; End: - (provide 'hargs-tests) ;;; hargs-tests.el ends here diff --git a/test/hibtypes-resources/TAGS b/test/hibtypes-resources/TAGS new file mode 100644 index 0000000000..d0635cb7a5 --- /dev/null +++ b/test/hibtypes-resources/TAGS @@ -0,0 +1,3 @@ + +test-data.el,25 +(defun test-func 19,386 diff --git a/test/hibtypes-resources/test-data.el b/test/hibtypes-resources/test-data.el new file mode 100644 index 0000000000..6aa981fef4 --- /dev/null +++ b/test/hibtypes-resources/test-data.el @@ -0,0 +1,21 @@ +;;; test-data.el + +;; Author: Mats Lidell <ma...@gnu.org> +;; +;; Orig-Date: 24-Apr-25 at 22:20:39 +;; Last-Mod: 24-Apr-25 at 22:22:16 by Mats Lidell +;; +;; SPDX-License-Identifier: GPL-3.0-or-later +;; +;; Copyright (C) 2025 Free Software Foundation, Inc. +;; See the "HY-COPY" file for license information. +;; +;; This file is part of GNU Hyperbole. + +;;; Commentary: + +;;; Code: + +(defun test-func () + "Test function." + nil) diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el index 3998c5bd73..ab2bef76ad 100644 --- a/test/hibtypes-tests.el +++ b/test/hibtypes-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 20-Feb-21 at 23:45:00 -;; Last-Mod: 8-Sep-24 at 00:48:52 by Mats Lidell +;; Last-Mod: 24-Apr-25 at 23:49:38 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -19,6 +19,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'hibtypes) (require 'info) (require 'el-mock) @@ -215,36 +216,32 @@ ;; ctags ;; Seems ctags -v does not give the proper answer -;; FIXME: Rewrite to not depend on hy-test-helpers.el (ert-deftest ibtypes::ctags-vgrind-test () - (unwind-protect - (with-temp-buffer - (insert "hy-test-helpers:consume-input-events hy-test-helpers.el 25\n") - (goto-char (point-min)) - (forward-char 4) - (let ((default-directory (expand-file-name "test" hyperb:dir))) + (let ((default-directory (ert-resource-directory))) + (unwind-protect + (with-temp-buffer + (insert "test-func test-data.el 19\n") + (goto-char (point-min)) + (forward-char 4) (ibtypes::ctags) - (set-buffer "hy-test-helpers.el") - (should (looking-at "(defun hy-test-helpers:consume-input-events")))) - (kill-buffer "hy-test-helpers.el"))) + (set-buffer "test-data.el") + (should (looking-at "(defun test-func"))) + (hy-test-helpers:kill-buffer "test-data.el")))) ;; etags -;; FIXME: Rewrite to not depend on hy-test-helpers.el (ert-deftest ibtypes::etags-test () - (unwind-protect - (with-temp-buffer - (insert "\n") - (insert "hy-test-helpers.el,237\n") - (insert "(defun hy-test-helpers:consume-input-events 25,518\n") - (rename-buffer (concat "TAGS" (buffer-name))) - (goto-char (point-min)) - (forward-line 2) - (forward-char 10) - (let ((default-directory (expand-file-name "test" hyperb:dir))) + (let ((tags (find-file (ert-resource-file "TAGS"))) + (default-directory (ert-resource-directory))) + (unwind-protect + (with-current-buffer tags + (goto-char (point-min)) + (forward-line 2) + (forward-char 10) (ibtypes::etags) - (set-buffer "hy-test-helpers.el") - (should (looking-at "(defun hy-test-helpers:consume-input-events")))) - (kill-buffer "hy-test-helpers.el"))) + (set-buffer "test-data.el") + (should (looking-at "(defun test-func"))) + (hy-test-helpers:kill-buffer "test-data.el") + (hy-test-helpers:kill-buffer tags)))) ;; cscope diff --git a/test/hmouse-drv-resources/TAGS b/test/hmouse-drv-resources/TAGS new file mode 100644 index 0000000000..d0635cb7a5 --- /dev/null +++ b/test/hmouse-drv-resources/TAGS @@ -0,0 +1,3 @@ + +test-data.el,25 +(defun test-func 19,386 diff --git a/test/hmouse-drv-resources/test-data.el b/test/hmouse-drv-resources/test-data.el new file mode 100644 index 0000000000..6aa981fef4 --- /dev/null +++ b/test/hmouse-drv-resources/test-data.el @@ -0,0 +1,21 @@ +;;; test-data.el + +;; Author: Mats Lidell <ma...@gnu.org> +;; +;; Orig-Date: 24-Apr-25 at 22:20:39 +;; Last-Mod: 24-Apr-25 at 22:22:16 by Mats Lidell +;; +;; SPDX-License-Identifier: GPL-3.0-or-later +;; +;; Copyright (C) 2025 Free Software Foundation, Inc. +;; See the "HY-COPY" file for license information. +;; +;; This file is part of GNU Hyperbole. + +;;; Commentary: + +;;; Code: + +(defun test-func () + "Test function." + nil) diff --git a/test/hmouse-drv-tests.el b/test/hmouse-drv-tests.el index 64de76646c..07d6652af4 100644 --- a/test/hmouse-drv-tests.el +++ b/test/hmouse-drv-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 28-Feb-21 at 22:52:00 -;; Last-Mod: 13-Apr-25 at 15:43:05 by Bob Weiner +;; Last-Mod: 25-Apr-25 at 10:01:41 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -20,9 +20,9 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'hbut) (require 'el-mock) -(require 'with-simulated-input) (require 'hy-test-helpers "test/hy-test-helpers") (ert-deftest hbut-defal () @@ -190,7 +190,7 @@ (with-temp-buffer (insert "\"/tmp\"\n") (goto-char 3) - (with-simulated-input "TMP RET" + (ert-simulate-keys "TMP\r" (let ((enable-recursive-minibuffers t)) (hui:ibut-label-create) (should (string= "<[TMP]> - \"/tmp\"\n" (buffer-string))))))) @@ -200,7 +200,7 @@ (with-temp-buffer (insert "<[LBL]>: \"/tmp\"\n") (goto-char 14) - (with-simulated-input "TMP RET" + (ert-simulate-keys "TMP\r" (condition-case err (hui:ibut-label-create) (error @@ -457,37 +457,33 @@ ;; ctags ; Seems ctags -v does not give the proper answer -;; FIXME: Rewrite to not depend on hy-test-helpers.el (ert-deftest hbut-ctags-vgrind-test () (unwind-protect (with-temp-buffer - (insert "hy-test-helpers:consume-input-events hy-test-helpers.el 25\n") + (insert "test-func test-data.el 19\n") (goto-char (point-min)) (forward-char 4) - (let ((default-directory (expand-file-name "test" hyperb:dir))) + (let ((default-directory (ert-resource-directory))) (action-key) (should (hattr:ibtype-is-p 'ctags)) - (should (looking-at "(defun hy-test-helpers:consume-input-events")))) - (hy-test-helpers:kill-buffer "hy-test-helpers.el"))) + (should (looking-at "(defun test-func")))) + (hy-test-helpers:kill-buffer "test-data.el"))) ;; etags -;; FIXME: Rewrite to not depend on hy-test-helpers.el (ert-deftest hbut-etags-test () - (unwind-protect - (with-temp-buffer - (insert "\n") - (insert "hy-test-helpers.el,237\n") - (insert "(defun hy-test-helpers:consume-input-events 25,518\n") - (rename-buffer (concat "TAGS" (buffer-name))) - (goto-char (point-min)) - (forward-line 2) - (forward-char 10) - (let ((default-directory (expand-file-name "test" hyperb:dir))) - (action-key) - (should (hattr:ibtype-is-p 'etags)) - (set-buffer "hy-test-helpers.el") - (should (looking-at "(defun hy-test-helpers:consume-input-events")))) - (hy-test-helpers:kill-buffer "hy-test-helpers.el"))) + (let ((tags (find-file (ert-resource-file "TAGS")))) + (unwind-protect + (with-current-buffer tags + (goto-char (point-min)) + (forward-line 2) + (forward-char 10) + (let ((default-directory (ert-resource-directory))) + (action-key) + (should (hattr:ibtype-is-p 'etags)) + (set-buffer "test-data.el") + (should (looking-at "(defun test-func")))) + (hy-test-helpers:kill-buffer "test-data.el") + (hy-test-helpers:kill-buffer tags)))) ;; text-toc (ert-deftest hbut-text-toc-test () @@ -659,10 +655,8 @@ The frame setup is mocked." (hy-delete-file-and-buffer filea) (hy-delete-file-and-buffer fileb)))) -;; This file can't be byte-compiled without the `el-mock' and -;; `with-simulated-input' package (because of the use of the -;; `with-mock' and `with-simulated-input' macro), which is not a -;; dependency of Hyperbole. +;; This file can't be byte-compiled without the `el-mock' package +;; which is not a dependency of Hyperbole. ;; Local Variables: ;; no-byte-compile: t ;; End: diff --git a/test/hmouse-info-tests.el b/test/hmouse-info-tests.el index 4f0fd90ef2..833d4823a1 100644 --- a/test/hmouse-info-tests.el +++ b/test/hmouse-info-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 29-Dec-21 at 09:02:00 -;; Last-Mod: 22-May-22 at 11:11:53 by Mats Lidell +;; Last-Mod: 25-Apr-25 at 19:56:35 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -19,12 +19,12 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'hmouse-info) -(require 'with-simulated-input) (ert-deftest hmouse-info-read-index-with-completion () "Read a completion that completes." - (with-simulated-input "(emacs)regex TAB RET" + (ert-simulate-keys "(emacs)regex\t\r" (should (string= "(emacs)regexp" (Info-read-index-item-name "Prompt: "))))) (ert-deftest hmouse-info-build-completions-no-match () @@ -46,12 +46,5 @@ (should (string-prefix-p "regexp" m t)))) (kill-buffer "*info*"))) -;; This file can't be byte-compiled without the `with-simulated-input' -;; package (because of the use of the `with-simulated-input' macro), -;; which is not a dependency of Hyperbole. -;; Local Variables: -;; no-byte-compile: t -;; End: - (provide 'hmouse-info-tests) ;;; hmouse-info-tests.el ends here diff --git a/test/hpath-tests.el b/test/hpath-tests.el index 462b2b3fa2..9c4b68bf4b 100644 --- a/test/hpath-tests.el +++ b/test/hpath-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 28-Feb-21 at 23:26:00 -;; Last-Mod: 7-Mar-25 at 10:21:48 by Mats Lidell +;; Last-Mod: 25-Apr-25 at 21:51:39 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -491,7 +491,7 @@ dir/subdir: (provide 'hpath-tests) -:; This file can't be byte-compiled without the `el-mock' package +;; This file can't be byte-compiled without the `el-mock' package ;; which is not a dependency of Hyperbole. ;; ;; Local Variables: diff --git a/test/hui-tests.el b/test/hui-tests.el index 354d32b2aa..7a8a68bf5a 100644 --- a/test/hui-tests.el +++ b/test/hui-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 20-Apr-25 at 15:12:11 by Bob Weiner +;; Last-Mod: 25-Apr-25 at 19:50:39 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -19,7 +19,7 @@ ;;; Code: (require 'ert) -(require 'with-simulated-input) +(require 'ert-x) (require 'el-mock) (require 'hy-test-helpers "test/hy-test-helpers") (require 'hibtypes) @@ -56,7 +56,7 @@ (setenv "HOME" "/tmp") (set-buffer gbut-file-buffer) - (with-simulated-input create-gbut + (ert-simulate-keys (kbd create-gbut) (hact (lambda () (call-interactively 'hui:gbut-create)))) ;; Create using program @@ -66,7 +66,7 @@ (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::link-to-file)) (goto-char (point-max)) ;; Move past button so does not prompt with label - (with-simulated-input edit-gbut + (ert-simulate-keys (kbd edit-gbut) (hact (lambda () (call-interactively 'hui:gbut-edit)))) ;; (set-buffer gbut-file-buffer) @@ -149,7 +149,7 @@ (with-temp-buffer (insert "\"/tmp\"\n") (goto-char 3) - (with-simulated-input "TMP RET" + (ert-simulate-keys "TMP\r" (hui:ibut-label-create) (should (string= "<[TMP]> - \"/tmp\"\n" (buffer-string)))))) @@ -158,7 +158,7 @@ (with-temp-buffer (insert "<[LBL]>: \"/tmp\"\n") (goto-char 14) - (with-simulated-input "TMP RET" + (ert-simulate-keys "TMP\r" (condition-case err (hui:ibut-label-create) (error @@ -183,7 +183,7 @@ (let ((file (make-temp-file "hypb_" nil ".txt"))) (unwind-protect (find-file file) - (with-simulated-input "label RET www-url RET www.hypb.org RET" + (ert-simulate-keys "label\rwww-url\rwww.hypb.org\r" (hui:ebut-create) (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args '("www.hypb.org") :loc file :lbl-key "label")) (hy-delete-file-and-buffer file)))) @@ -194,10 +194,10 @@ Ensure modifying the button but keeping the label does not create a double label (let ((file (make-temp-file "hypb_" nil ".txt"))) (unwind-protect (find-file file) - (with-simulated-input "label RET www-url RET www.hypb.org RET" + (ert-simulate-keys "label\rwww-url\rwww.hypb.org\r" (hui:ebut-create) (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args '("www.hypb.org") :loc file :lbl-key "label")) - (with-simulated-input "RET RET RET RET" + (ert-simulate-keys "\r\r\r\r" (hui:ebut-edit "label") (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args '("www.hypb.org") :loc file :lbl-key "label") (should (string= "<(label)>" (buffer-string))))) @@ -628,7 +628,7 @@ Ensure modifying the button but keeping the label does not create a double label (unwind-protect (progn (find-file file) - (with-simulated-input "ibut RET link-to-rfc RET 123 RET" + (ert-simulate-keys "ibut\rlink-to-rfc\r123\r" (hact (lambda () (call-interactively 'hui:ibut-create)))) (should (string= "<[ibut]> - rfc123" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -642,7 +642,7 @@ Ensure modifying the button but keeping the label does not create a double label (insert "ibut") (set-mark (point-min)) (goto-char (point-max)) - (with-simulated-input "RET link-to-rfc RET 123 RET" + (ert-simulate-keys "\rlink-to-rfc\r123\r" (hact (lambda () (call-interactively 'hui:ibut-create)))) (should (string= "<[ibut]> - rfc123" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -655,7 +655,7 @@ Ensure modifying the button but keeping the label does not create a double label (progn (find-file file) (insert "(sexp)") - (with-simulated-input "ibut RET link-to-rfc RET 123 RET" + (ert-simulate-keys "ibut\rlink-to-rfc\r123\r" (hact (lambda () (call-interactively 'hui:ibut-create)))) (should (string= "(sexp); <[ibut]> - rfc123" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -668,7 +668,7 @@ Ensure modifying the button but keeping the label does not create a double label (find-file file) (insert "\"/tmp\"") (goto-char 3) - (with-simulated-input "label RET" + (ert-simulate-keys "label\r" (hact (lambda () (call-interactively 'hui:ibut-label-create)))) (should (string= "<[label]> - \"/tmp\"" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -682,7 +682,7 @@ With point on label suggest that ibut for rename." (find-file file) (insert "<[label]> - rfc123") (goto-char 3) - (with-simulated-input "M-DEL renamed RET" + (ert-simulate-keys (kbd "M-DEL renamed RET") (hact (lambda () (call-interactively 'hui:ibut-rename)))) (should (string= "<[renamed]> - rfc123" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -695,7 +695,7 @@ With point on label suggest that ibut for rename." (find-file file) (insert "<[label]> - rfc123") (goto-char (point-max)) - (with-simulated-input "label RET M-DEL renamed RET" + (ert-simulate-keys (kbd "label RET M-DEL renamed RET") (hact (lambda () (call-interactively 'hui:ibut-rename)))) (should (string= "<[renamed]> - rfc123" (buffer-string)))) (hy-delete-file-and-buffer file)))) @@ -708,7 +708,7 @@ With point on label suggest that ibut for rename." (find-file file) (insert "<[label]> - rfc123") (goto-char (point-max)) - (with-simulated-input "RET" + (ert-simulate-keys "\r" (should-error (hui:ibut-rename "notalabel") :type 'error))) (hy-delete-file-and-buffer file)))) @@ -828,7 +828,7 @@ With point on label suggest that ibut for rename." (goto-char (point-max)) (split-window) (find-file filea) - (with-simulated-input "label RET" + (ert-simulate-keys "label\r" (hui:ibut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb)) 4)) (should (string= (buffer-string) (concat "<[label]> - " "\"" (file-name-nondirectory fileb) @@ -917,7 +917,7 @@ With point on label suggest that ibut for rename." (goto-char (point-max)) (split-window) (find-file filea) - (with-simulated-input "button RET" + (ert-simulate-keys "button\r" (hui:ebut-link-directly (get-buffer-window) (get-buffer-window (get-file-buffer fileb))) (should (string= (buffer-string) "<(button)>")) @@ -946,7 +946,7 @@ With point on label suggest that ibut for rename." (goto-char (1- (point)))) (split-window) (find-file file) - (with-simulated-input "button RET" + (ert-simulate-keys "button\r" (hui:ebut-link-directly (get-buffer-window) (get-buffer-window dir-buf)) ;; Implicit link should be the `dir' dired directory, ;; possibly minus the final directory '/'. @@ -979,7 +979,7 @@ With point on label suggest that ibut for rename." (mocklet ((gbut:file => global-but-file)) (delete-other-windows) (find-file file) - (with-simulated-input "button RET" + (ert-simulate-keys "button\r" (hui:gbut-link-directly t) (with-current-buffer (find-buffer-visiting global-but-file) (should (string= (buffer-string) @@ -998,7 +998,7 @@ With point on label suggest that ibut for rename." (mocklet ((gbut:file => global-but-file)) (delete-other-windows) (find-file file) - (with-simulated-input "button RET" + (ert-simulate-keys "button\r" (hui:gbut-link-directly) (with-current-buffer (find-buffer-visiting global-but-file) (should (string= (buffer-string) "First\n<(button)>\n")) @@ -1445,7 +1445,7 @@ line 1 (should (string= "abcjkl" (buffer-string))) (should (string= "{def}{ghi}" (car kill-ring)))))) -;; This file can't be byte-compiled without `with-simulated-input' which +;; This file can't be byte-compiled without the `el-mock' which ;; is not part of the actual dependencies, so: ;; Local Variables: ;; no-byte-compile: t diff --git a/test/hy-test-dependencies.el b/test/hy-test-dependencies.el index 39ae9ff90c..b1cde31578 100644 --- a/test/hy-test-dependencies.el +++ b/test/hy-test-dependencies.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 20-Feb-21 at 23:16:00 -;; Last-Mod: 26-Dec-24 at 22:40:40 by Bob Weiner +;; Last-Mod: 25-Apr-25 at 19:28:36 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -36,7 +36,7 @@ (require pkg-symbol)) (mapc (lambda (sym) (hy-test-ensure-package-installed sym)) - '(el-mock with-simulated-input)) + '(el-mock)) ;; Needed when `hypb:display-file-with-logo' uses `org-mode' (setq hsys-org-enable-smart-keys t) diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el index c9ada7d34e..13b6766cb9 100644 --- a/test/hy-test-helpers.el +++ b/test/hy-test-helpers.el @@ -127,5 +127,15 @@ and the default WORD-LENGTH is 4." (defvar hy-test-run-failing-flag nil "Non-nil means test cases that are known to fail will be tried.") +(defun hy-test-word-face-at-region (beg end) + "Non-nil if all chars in region [BEG, END] have `hywiki--word-face'." + (interactive "r") + (let (no-face) + (while (and (< beg end) (not no-face)) + (unless (hywiki-word-face-at-p beg) + (setq no-face t)) + (setq beg (1+ beg))) + (not no-face))) + (provide 'hy-test-helpers) ;;; hy-test-helpers.el ends here diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index 4efdaafb8f..e582fc388f 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -19,7 +19,7 @@ (require 'ert) (require 'el-mock) -(require 'with-simulated-input) +(require 'ert-x) (require 'hy-test-helpers) (require 'hywiki) (require 'hsys-org) @@ -866,10 +866,10 @@ Note special meaning of `hywiki-allow-plurals-flag'." (unwind-protect (progn (find-file file) - (with-simulated-input "RET" + (ert-simulate-keys "\r" (should-error (hywiki-add-bookmark "WikiWord"))) (bookmark-set "bookmark") - (with-simulated-input "bookmark RET" + (ert-simulate-keys "bookmark\r" (hywiki-add-bookmark "WikiWord") (should (equal '(bookmark . "bookmark") (hywiki-get-referent "WikiWord"))))) (hy-delete-file-and-buffer file) @@ -880,7 +880,7 @@ Note special meaning of `hywiki-allow-plurals-flag'." (let ((hywiki-directory (make-temp-file "hywiki" t)) (wikiword "WikiWord")) (unwind-protect - (with-simulated-input "hpath:find RET" + (ert-simulate-keys "hpath:find\r" (hywiki-add-command wikiword) (should (equal '(command . hpath:find) (hywiki-get-referent wikiword)))) @@ -918,7 +918,7 @@ Note special meaning of `hywiki-allow-plurals-flag'." "Verify `hywiki-add-info-index'." (let ((hywiki-directory (make-temp-file "hywiki" t))) (unwind-protect - (with-simulated-input "files RET" + (ert-simulate-keys "files\r" (info "emacs") (hywiki-add-info-index "WikiWord") (should (equal '(info-index . "(emacs)files") (hywiki-get-referent "WikiWord")))) @@ -928,7 +928,7 @@ Note special meaning of `hywiki-allow-plurals-flag'." "Verify `hywiki-add-info-node'." (let ((hywiki-directory (make-temp-file "hywiki" t))) (unwind-protect - (with-simulated-input "(emacs) RET" + (ert-simulate-keys "(emacs)\r" (hywiki-add-info-node "WikiWord") (should (equal '(info-node . "(emacs)") (hywiki-get-referent "WikiWord")))) (hy-delete-dir-and-buffer hywiki-directory)))) @@ -938,10 +938,10 @@ Note special meaning of `hywiki-allow-plurals-flag'." (let ((hywiki-directory (make-temp-file "hywiki" t))) (unwind-protect (progn - (with-simulated-input "ABC RET" + (ert-simulate-keys "ABC\r" (hywiki-add-key-series "WikiWord") (should (equal '(key-series . "{ABC}") (hywiki-get-referent "WikiWord")))) - (with-simulated-input "{ABC} RET" + (ert-simulate-keys "{ABC}\r" (hywiki-add-key-series "WikiWord") (should (equal '(key-series . "{ABC}") (hywiki-get-referent "WikiWord"))))) (hy-delete-dir-and-buffer hywiki-directory)))) @@ -1042,7 +1042,7 @@ up the test." "Verify saving and loading a referent keyseries works ." (hywiki-tests--referent-test (cons 'key-series "{ABC}") - (with-simulated-input "ABC RET" + (ert-simulate-keys "ABC\r" (hywiki-add-key-series wiki-referent)))) ;; FIXME: Not stable. Can sometimes succeed. @@ -1062,7 +1062,7 @@ up the test." (hywiki-tests--referent-test (cons 'bookmark "bmark") (bookmark-set "bmark") - (with-simulated-input "bmark RET" + (ert-simulate-keys "bmark\r" (hywiki-add-bookmark wiki-referent)))) (ert-deftest hywiki-tests--save-referent-bookmark-use-menu () @@ -1085,7 +1085,7 @@ up the test." "Verify saving and loading a referent command works." (hywiki-tests--referent-test (cons 'command #'hywiki-tests--command) - (with-simulated-input "hywiki-tests--command RET" + (ert-simulate-keys "hywiki-tests--command\r" (hywiki-add-command wiki-referent)))) (ert-deftest hywiki-tests--save-referent-command-use-menu () @@ -1154,7 +1154,7 @@ up the test." (hywiki-tests--referent-test (cons 'info-index "(emacs)files") (save-excursion - (with-simulated-input "files RET" + (ert-simulate-keys "files\r" (info "emacs") (hywiki-add-info-index wiki-referent))))) @@ -1177,7 +1177,7 @@ up the test." (cons 'info-node "(emacs)") (save-excursion (unwind-protect - (with-simulated-input "(emacs) RET" + (ert-simulate-keys "(emacs)\r" (hywiki-add-info-node wiki-referent)) (kill-buffer "*info*"))))) @@ -1273,13 +1273,29 @@ See gh#rswgnu/hyperbole/669." (hy-delete-file-and-buffer wiki-page) (hy-delete-dir-and-buffer hywiki-directory))))) +(defun hywiki-tests--word-n-face-at () + "Non-nil if at a WikiWord and it has `hywiki--word-face'." + (cl-destructuring-bind (word beg end) (hywiki-word-at :range) + (when word + (when (hy-test-word-face-at-region beg end) + word)))) + +(defvar hywiki-tests--with-face-test nil + "Non-nil to perform face validation of WikiWord.") + +(defun hywiki-tests--word-at () + "Choose what test to perform based on value of `hywiki-tests--with-face-test'." + (if hywiki-tests--with-face-test + (hywiki-tests--word-n-face-at) + (hywiki-word-at))) + (defun hywiki-tests--verify-hywiki-word (expected) "Verify that `hywiki-word-at' returns t if a wikiword is EXPECTED. If EXPECTED is a string also verify that the wikiword matches the string." (if (not expected) - (should-not (hywiki-word-at)) - (let ((hywiki-word-found (hywiki-word-at))) + (should-not (hywiki-tests--word-at)) + (let ((hywiki-word-found (hywiki-tests--word-at))) (if (stringp expected) (should (string= expected hywiki-word-found)) (should hywiki-word-found)) @@ -1339,9 +1355,16 @@ the function is called." (("(HiHo#s" . "HiHo#s") (" " . "HiHo#s")) (("(HiHo#s" . "HiHo#s") (")" . "HiHo#s")) ; Delimiter part of WikiWord. See below too. (("(HiHo#s" . "HiHo#s") ("-" . "HiHo#s-") ("n" . "HiHo#s-n") (")" . "HiHo#s-n")) - ;; Insert and delete between WikiWords + ;; Insert and delete between WikiWords and non WikiWords (("HiHo" . t) (p3 . t) (" " . "Hi") (p4 . "Ho") (-1 . "HiHo")) (("Hiho" . t) (p3 . t) (" " . "Hi") (p4) (-1 . "Hiho")) + (("hiHo") (p3) (" ") (p4 . "Ho") (-1)) + ;; With double quotes + (("\"HiHo\"" . t) (p4 . t) (" " . "Hi") (p5 . "Ho") (-1 . "HiHo")) + (("\"Hiho\"" . t) (p4 . t) (" " . "Hi") (p5) (-1 . "Hiho")) + (("\"hiHo\"") (p4) (" ") (p5 . "Ho") (-1)) + (("\"Hi\"Ho" . t) (p5 . "Ho") (" " . "Ho") (p4 . "Hi")) + (("Hi\"Ho\"" . t) (p3 . "Hi") (" " . "Hi") (p4) (p5 . "Ho")) ) "List of test cases for WikiWords.") @@ -1359,6 +1382,28 @@ resulting state at point is a WikiWord or not." (hywiki-tests--run-test-case testcase)))) (hy-delete-dir-and-buffer hywiki-directory))))) +(ert-deftest hywiki-tests--wikiword-step-check-verification-with-faces () + "Run the step check to verify WikiWord is identified under change. +Performs each operation from the step check and verifies if the +resulting state at point is a WikiWord or not." + (skip-unless (not noninteractive)) + (hywiki-tests--preserve-hywiki-mode + (let* ((hywiki-directory (make-temp-file "hywiki" t)) + (wikiHiHo (cdr (hywiki-add-page "HiHo"))) + (wikiHiho (cdr (hywiki-add-page "Hiho"))) + (wikiHi (cdr (hywiki-add-page "Hi"))) + (wikiHo (cdr (hywiki-add-page "Ho"))) + (wiki-page-list (list wikiHiHo wikiHiho wikiHi wikiHo)) + (hywiki-tests--with-face-test t)) + (unwind-protect + (progn + (hywiki-mode 1) + (dolist (testcase hywiki-tests--wikiword-step-check) + (with-temp-buffer + (hywiki-tests--run-test-case testcase)))) + (hy-delete-files-and-buffers wiki-page-list) + (hy-delete-dir-and-buffer hywiki-directory))))) + (defconst hywiki-tests--lorem-ipsum "\ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse aliquet diam euismod turpis ultricies, et porta sem blandit. Sed vitae." @@ -1460,6 +1505,28 @@ Insert test in the middle of other text." (should (search-forward v)) (should (string= v (hywiki-word-at))))))))) +(ert-deftest hywiki-tests--filename-same-as-wiki-word () + "Regular files should not be WikiWords even when hywiki-mode is active." + (hywiki-tests--preserve-hywiki-mode + (let* ((hywiki-directory (make-temp-file "hywiki" t)) + (wiki-page (cdr (hywiki-add-page "DEMO"))) + (default-directory hyperb:dir)) + (unwind-protect + (with-temp-buffer + (insert "\"DEMO\" \"DEMO.org\"\n") + (goto-char 2) + (should (looking-at-p "DEMO\" ")) + (hywiki-mode 0) + (should (string= "ibtypes::pathname" (hattr:get (ibut:at-p) 'categ))) + (hywiki-mode 1) + (should (string= "ibtypes::pathname" (hattr:get (ibut:at-p) 'categ))) + (goto-char 9) + ;; Verify that using the org extension selects the WikiWord. + (should (looking-at-p "DEMO\\.org\"")) + (should (string= "ibtypes::hywiki-existing-word" (hattr:get (ibut:at-p) 'categ)))) + (hy-delete-file-and-buffer wiki-page) + (hy-delete-dir-and-buffer hywiki-directory))))) + (provide 'hywiki-tests) ;; This file can't be byte-compiled without the `el-mock' package