From ba9bef1222aa201cf5ac21d6b52caf6a1277932d Mon Sep 17 00:00:00 2001 From: bw Date: Wed, 12 Aug 2026 12:52:17 -0400 Subject: [PATCH 1/3] hsys-denote.el - Remove left over comments on unused dn: prefix --- hsys-denote.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hsys-denote.el b/hsys-denote.el index b2eb967d..3466c167 100644 --- a/hsys-denote.el +++ b/hsys-denote.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 2-Jul-16 at 14:54:14 -;; Last-Mod: 14-Jul-26 at 17:00:54 by Mats Lidell +;; Last-Mod: 12-Aug-26 at 12:35:19 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -150,8 +150,8 @@ denote link." (defact link-to-denote (id-and-section &optional file) "Display a denote entry given by ID-AND-SECTION and optional FILE. -ID-AND-SECTION optionally may be prefixed with \"denote:\" or \"dn:\" and -may be suffixed with: +ID-AND-SECTION optionally may be prefixed with \"denote:\" and may be +suffixed with: 1. #section or ::*section, where section is any exact match to a denote in-file heading; @@ -179,7 +179,7 @@ and ID-AND-SECTION or FILE is not found, trigger an error." (hypb:error "(link-to-denote): File is unreadable: \"%s\"" file)) (if (stringp id-and-section) - ;; Remove any "denote:" or "dn:" prefix + ;; Remove any "denote:" prefix (let ((file-id (denote-extract-id-from-string id-and-section)) (section (when (and (string-match (hys-denote-get-link-regexp) id-and-section) From b635130dfb58071596b3bfe768343c552d23121c Mon Sep 17 00:00:00 2001 From: bw Date: Thu, 13 Aug 2026 00:23:00 -0400 Subject: [PATCH 2/3] hy-test-helpers:with-time - Add to time any part of a function Use in `hywiki-tests--edit'. --- ChangeLog | 3 + test/hy-test-helpers.el | 14 +++- test/hywiki-tests.el | 158 ++++++++++++++++++++-------------------- 3 files changed, 97 insertions(+), 78 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a1a1236..cbb2f6c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* test/hy-test-helpers.el (hy-test-helpers:with-time): Add to time any part + of a function. + 2026-08-04 Bob Weiner * hpath.el (hpath:cache-mswindows-mount-points): Fix 'shell-command-to-string' diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el index b6a71779..aed5a7bd 100644 --- a/test/hy-test-helpers.el +++ b/test/hy-test-helpers.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 15-Jul-26 at 22:00:22 by Mats Lidell +;; Last-Mod: 12-Aug-26 at 18:27:28 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -23,6 +23,18 @@ (require 'hywiki) ;; For `hywiki-word-face-at-p' and (require 'hypb) (eval-when-compile (require 'cl-lib)) +(defmacro hy-test-helpers:with-time (descrip &rest body) + "Log a message of DESCRIP; return the time in seconds to run rest, BODY." + (declare (indent 1) (debug (form body))) + (let ((start (gensym "start")) + (elapsed (gensym "elapsed"))) + `(let* ((,start (float-time)) + (,elapsed 0.0)) + ,@body + (setq ,elapsed (- (float-time) ,start)) + (message "(%s): took %.2f seconds" ,descrip ,elapsed) + ,elapsed))) + (defun hy-test-helpers:consume-input-events () "Use `recursive-edit' to consume the events kbd-key generates." (run-with-timer 0.5 nil (lambda () (if (> (recursion-depth) 0) (exit-recursive-edit)))) diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index 0c977bdf..79610d2c 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -54,6 +54,7 @@ named WikiReferent with a non-page referent type." (defconst hywiki-tests--edit-string-pairs [ + ("(Non#s n)" "(Non#s n") ("\"WikiWord#section with spaces\"" "\"{WikiWord#section} with spaces") ;; shrink highlight to "{WikiWord#section} ("Hi#a cd" "{Hi#ab} cd") ("\"WikiWord#a b c" "\"{WikiWord#a} b") @@ -74,7 +75,6 @@ named WikiReferent with a non-page referent type." ("WikiWord#a b c" "{WikiWord#a} b ") ("HiHo#s " "{HiHo#s} ") ("HiHo#s" "{HiHo#s} ") - ("(Non#s n)" "({Non#s} n") ("WikiWord unhighlighted" " unhighlighted") ;; dehighlight ;; WikiWord below does not highlight since could be an Info node ;; ibut, like "(hyperbole)WikiWord", that we don't want to trigger @@ -85,84 +85,88 @@ named WikiReferent with a non-page referent type." Last two elements are optional.") (ert-deftest hywiki-tests--edit () - (hywiki-tests--preserve-hywiki-mode - (let ((test-num 0) - before - after - name - doc - markedup-before - markedup-after - start - end - hywiki-ref-positions) - (unwind-protect - (progn - (org-mode) - (mapc - (lambda (before-after) - (condition-case err - (progn - (setq before (nth 0 before-after) - after (nth 1 before-after) - name (nth 2 before-after) - doc (nth 3 before-after)) - ;; Ensure all brace delimited HyWikiWords have their pages - ;; created so their references will be highlighted. - (mapc #'hywiki-add-page - (delq nil - (mapcar #'hywiki-get-singular-wikiword - (seq-remove #'string-empty-p - (mapcar #'string-trim - (hywiki-tests--get-brace-strings after)))))) - (unwind-protect - (progn - (pop-to-buffer (current-buffer)) - (erase-buffer) - (hywiki-tests--insert-by-char before) - (hywiki-tests--interpolate-buffer) - ;; Markup before string in temp buffer - ;; Surround any HyWikiWord refs with braces to match after string. - (setq hywiki-ref-positions (hywiki-get-reference-positions)) - (dolist (start-end hywiki-ref-positions) - (setq start (car start-end) - end (cdr start-end)) - (goto-char end) - (hywiki-tests--insert "}") - (goto-char start) - (hywiki-tests--insert "{")) - ;; Store the buffer string for comparison - (setq markedup-before (buffer-string)) - ;; Markup after string - (erase-buffer) - (hywiki-tests--insert after) - (hywiki-tests--interpolate-buffer) - (setq markedup-after (buffer-string)) - ;; Compare markedup-before to markedup-after - (if (or name doc) + (hy-test-helpers:with-time "hywiki-tests--edit" + (hywiki-tests--preserve-hywiki-mode + (let ((test-num 0) + before + after + name + doc + markedup-before + markedup-after + start + end + hywiki-ref-positions) + (unwind-protect + (progn + (org-mode) + (mapc + (lambda (before-after) + (condition-case err + (hy-test-helpers:with-time (format "Test #%d" test-num) + (cl-incf test-num) + (setq before (nth 0 before-after) + after (nth 1 before-after) + name (nth 2 before-after) + doc (nth 3 before-after)) + (message (format "Test #%d: At pos %d, action \"%s\", result \"%s\", name \"%s\", doc \"%s\"" + test-num (point) before after name doc)) + ;; Ensure all brace delimited HyWikiWords expected in + ;; `after' string have their pages created so their + ;; references will be highlighted. + (mapc #'hywiki-add-page + (delq nil + (mapcar #'hywiki-get-singular-wikiword + (seq-remove #'string-empty-p + (mapcar #'string-trim + (hywiki-tests--get-brace-strings after)))))) + (unwind-protect + (progn + (pop-to-buffer (current-buffer)) + (erase-buffer) + (hywiki-tests--insert-by-char before) + (hywiki-tests--interpolate-buffer) + ;; Markup before string in temp buffer + ;; Surround any HyWikiWord refs with braces to match after string. + (setq hywiki-ref-positions (hywiki-get-reference-positions)) + (dolist (start-end hywiki-ref-positions) + (setq start (car start-end) + end (cdr start-end)) + (goto-char end) + (hywiki-tests--insert "}") + (goto-char start) + (hywiki-tests--insert "{")) + ;; Store the buffer string for comparison + (setq markedup-before (buffer-string)) + ;; Markup after string + (erase-buffer) + (hywiki-tests--insert after) + (hywiki-tests--interpolate-buffer) + (setq markedup-after (buffer-string)) + ;; Compare markedup-before to markedup-after + (if (or name doc) + (should (equal (list :test-num test-num + :markedup (format "%S" markedup-before) + :test-name name :doc doc + :before before :after after) + (list :test-num test-num + :markedup (format "%S" markedup-after) + :test-name name :doc doc + :before before :after after))) (should (equal (list :test-num test-num - :markedup (format "%S" markedup-before) - :test-name name :doc doc - :before before :after after) + :markedup (format "%S" markedup-before) + :before before :after after) (list :test-num test-num - :markedup (format "%S" markedup-after) - :test-name name :doc doc - :before before :after after))) - (should (equal (list :test-num test-num - :markedup (format "%S" markedup-before) - :before before :after after) - (list :test-num test-num - :markedup (format "%S" markedup-after) - :before before :after after)))) - (cl-incf test-num)) - (goto-char (point-min)))) - (error (message "%s ---- %S" err (list :markedup markedup-before - :test-num test-num - :before before :after after))))) - hywiki-tests--edit-string-pairs)) - (let ((default-directory hywiki-directory)) - (hy-delete-files-and-buffers - '("AI.org" "FAI.org" "Hi.org" "HiHo.org" "HyWiki.org" "HyWikiW.org" "HyWikiWord.org" "MyWikiWord.org" "Non.org" "Wiki.org"))))))) + :markedup (format "%S" markedup-after) + :before before :after after))))) + (goto-char (point-min)))) + (error (message "%s ---- %S" err (list :markedup markedup-before + :test-num test-num + :before before :after after))))) + hywiki-tests--edit-string-pairs)) + (let ((default-directory hywiki-directory)) + (hy-delete-files-and-buffers + '("AI.org" "FAI.org" "Hi.org" "HiHo.org" "HyWiki.org" "HyWikiW.org" "HyWikiWord.org" "MyWikiWord.org" "Non.org" "Wiki.org")))))))) (defun hywiki-tests--get-brace-strings (s) "Return the substrings in S delimited by curly braces {…}, excluding braces. From 4c4ca3a4c3a59560811b8026a7c021775f89ada4 Mon Sep 17 00:00:00 2001 From: bw Date: Thu, 13 Aug 2026 00:29:09 -0400 Subject: [PATCH 3/3] hywiki-get-referent-hasht - Fix 'hywiki--any-wikiword-regexp-list' Also highlight wikiwords only when the wikiword hash table is non-empty, to fix bug #81594. hywiki-tests--bug-81594-file, hywiki-tests--bug-81594-buffer): Add tests for this. --- ChangeLog | 8 ++++++++ hui-mini.el | 4 ++-- hywiki.el | 6 ++++-- test/hywiki-tests.el | 43 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbb2f6c5..d39a7f59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2026-08-12 Bob Weiner + +* hywiki.el (hywiki-get-referent-hasht): Compute 'hywiki--any-wikiword-regexp-list' + and highlight wikiwords only when the wikiword hash table is non-empty, + to fix bug #81594. + test/hywiki-tests.el (hywiki-tests--bug-81594-file, + hywiki-tests--bug-81594-buffer): Add tests for this. + * test/hy-test-helpers.el (hy-test-helpers:with-time): Add to time any part of a function. diff --git a/hui-mini.el b/hui-mini.el index 32d1ab53..51691916 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: 19-Jul-26 at 09:57:15 by Bob Weiner +;; Last-Mod: 9-Aug-26 at 10:46:08 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1146,7 +1146,7 @@ With a prefix arg, insert a HyWikiWord instead.") ("org-roam-Find" hyrolo-org-roam) ;; ("recent-Files" recentf-open-files) ("Global-Buttons" (find-file (expand-file-name hbmap:filename hbmap:dir-user))) - ;; ("Helm" (menu . helm) "Display Hyperbole helm control menu") + ;; ("Home or Hyperbole" (menu . ...)) ;; ("I") ("Jump-to-Websites" webjump) ("Koutlines" hui:menu-to-personal-section) diff --git a/hywiki.el b/hywiki.el index ecbdfd2f..94e75db3 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: 27-Jul-26 at 10:43:32 by Bob Weiner +;; Last-Mod: 12-Aug-26 at 23:08:13 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2831,7 +2831,9 @@ regexps of wikiwords, if the hash table is out-of-date." hywiki--referent-hasht ;; Rebuild referent hash table (hywiki-make-referent-hasht)) - (unless hywiki--any-wikiword-regexp-list + (when (and (null hywiki--any-wikiword-regexp-list) + hywiki--referent-hasht + (not (hash-empty-p hywiki--referent-hasht))) ;; Compute these expensive regexps (matching 50 ;; HyWikiWords at a time) only if the set of ;; HyWikiWords changed in `hywiki-directory'. diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index 79610d2c..82552322 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 18-May-24 at 23:59:48 -;; Last-Mod: 27-Jul-26 at 17:22:19 by Bob Weiner +;; Last-Mod: 12-Aug-26 at 23:14:43 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2376,6 +2376,47 @@ Verifies the behavior controlled by the variables (let ((hypb:include-major-modes '(dired-mode))) (should (hywiki-potential-buffer-p))))) +(ert-deftest hywiki-tests--bug-81594-file () + "Ensure fix for bug#81594 that scrolled window when typing a HyWikiWord." + ;; We can't use `hywiki-tests--preserve-hywiki-mode' since the + ;; `hywiki-directory' must be empty. + (skip-unless (not noninteractive)) + (let* ((prior-hywiki-mode hywiki-mode) + (hywiki-directory (make-temp-file "hywiki" t)) + (file (make-temp-file "hypb"))) + (unwind-protect + (progn + (hywiki-mode :all) + (find-file file) + (let ((start (window-start))) + (hywiki-tests--insert "\n\n\nC") + (hywiki-tests--command-execute #'self-insert-command 1 ?i) + (should (= start (window-start))))) + (hywiki-mode prior-hywiki-mode) + (hy-delete-file-and-buffer file) + (hy-delete-dir-and-buffer hywiki-directory)))) + +(ert-deftest hywiki-tests--bug-81594-buffer () + "Ensure fix for bug#81594 that scrolled window when typing a HyWikiWord." + ;; We can't use `hywiki-tests--preserve-hywiki-mode' since the + ;; `hywiki-directory' must be empty. + (skip-unless (not noninteractive)) + (let* ((prior-hywiki-mode hywiki-mode) + (hywiki-directory (make-temp-file "hywiki" t))) + (unwind-protect + (progn + (hywiki-mode :all) + (with-temp-buffer + (set-window-buffer (selected-window) (current-buffer)) + (let ((start (window-start))) + (sit-for 0) + (hywiki-tests--insert "\n\n\nC") + (hywiki-tests--command-execute #'self-insert-command 1 ?i) + (sit-for 0) + (should (= start (window-start))))))) + (hywiki-mode prior-hywiki-mode) + (hy-delete-dir-and-buffer hywiki-directory))) + (provide 'hywiki-tests) ;; This file can't be byte-compiled without the `el-mock' package