branch: externals/hyperbole
commit ef2947bab82d5d043c4d21071bb6512e4c142c64
Author: bw <[email protected]>
Commit: bw <[email protected]>

    hywiki.el - Enable window-change-based HyWikiWord highlighting
---
 ChangeLog                |  13 +++++-
 hywiki.el                | 111 ++++++++++++++++++++++++-----------------------
 test/hsys-org-tests.el   |   3 +-
 test/hywiki-tests.el     |  92 +++++++++++++++++++--------------------
 test/hywiki-yki-tests.el |  11 ++---
 5 files changed, 123 insertions(+), 107 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4b52b9069..53b87cd116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-01-12  Bob Weiner  <[email protected]>
+
+* hywiki.el: (hywiki-word-highlight-in-buffers, 
hywiki-word-highlight-in-frame):
+    Add to support window-change-based HyWikiWord highlighting.
+
+2026-01-11  Bob Weiner  <[email protected]>
+
+* test/hsys-org-tests.el (hsys-org:org-link-at-p): Fix 4th test
+    by ensuring hywiki-mode is off.
+
 2026-01-06  Bob Weiner  <[email protected]>
 
 * hywiki.el (hywiki-get-buffers-in-windows): Add and call in
@@ -52,7 +62,8 @@
             (hywiki-active-in-current-buffer-p):
             (hywiki-word-set-auto-highlighting): Replace 
'hywiki-word-highlight-flag'
     with 'hywiki-mode'.
-  test/hywiki-tests.el (hywiki-tests--active-in-current-buffer-p):
+  test/hywiki-tests.el (hywiki-tests--active-in-current-buffer-p): Change let 
of
+    'hywiki-mode' to function call to set the minor mode.
 
 * hibtypes.el (hywiki-existing-word):
   hywiki.el (hywiki-word): Skip if not 'hywiki-active-in-current-buffer-p'.
diff --git a/hywiki.el b/hywiki.el
index 2bb55eb28b..c19103298c 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:     11-Jan-26 at 05:58:25 by Bob Weiner
+;; Last-Mod:     13-Jan-26 at 01:04:15 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -734,6 +734,8 @@ deletion commands and those in 
`hywiki-non-character-commands'."
           ;; Not inside a comment or a string
           (not (or (nth 4 (syntax-ppss)) (hypb:in-string-p))))))
 
+(defvar hywiki-prior-mode nil)
+
 ;;;###autoload
 (define-minor-mode hywiki-mode
   "Toggle HyWiki global minor mode with \\[hywiki-mode].
@@ -797,7 +799,7 @@ See the Info documentation at \"(hyperbole)HyWiki\".
       ;; Need hyperbole-mode
       (unless hyperbole-mode
        (hyperbole-mode 1))
-      (hywiki-word-set-auto-highlighting hywiki-mode arg)
+      (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
       (setq hywiki-mode arg))
      ((or (and (integerp arg) (<= arg 0))
          (null arg))
@@ -806,7 +808,7 @@ See the Info documentation at \"(hyperbole)HyWiki\".
       ;; Dehighlight HyWikiWords in this buffer when 'hywiki-mode' is
       ;; disabled and this is not a HyWiki page buffer. If this is a
       ;; HyWiki page buffer, then dehighlight when `hywiki-mode' is nil.
-      (hywiki-maybe-highlight-wikiwords-in-frame t)
+      (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
       (setq hywiki-mode arg))
      (t ;; (> arg 1)
       ;; Enable in HyWiki page buffers only
@@ -814,9 +816,15 @@ See the Info documentation at \"(hyperbole)HyWiki\".
       ;; Need hyperbole-mode
       (unless hyperbole-mode
        (hyperbole-mode 1))
-      (hywiki-word-set-auto-highlighting hywiki-mode arg)
+      (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
       (setq hywiki-mode arg)))))
 
+(defun hywiki-mode-around-advice (hywiki-mode-fn &optional arg)
+  (setq hywiki-prior-mode hywiki-mode)
+  (funcall hywiki-mode-fn arg))
+
+(advice-add 'hywiki-mode :around #'hywiki-mode-around-advice)
+
 ;;; ************************************************************************
 ;;; Public Implicit Button and Action Types
 ;;; ************************************************************************
@@ -2335,18 +2343,19 @@ since Org mode highlights those."
   (hywiki--maybe-de/highlight-org-element-forward 
#'hywiki-maybe-highlight-sexp))
 
 (defun hywiki-maybe-highlight-references (&optional region-start region-end 
skip-lookups-update-flag)
-  "Highlight each non-Org link HyWiki page#section in a buffer/region.
+  "Highlight each non-Org link HyWiki page#section in the current 
buffer/region.
 With optional REGION-START and REGION-END positions or markers (active
 region interactively), limit highlight adjustment to the region.  With
 optional SKIP-LOOKUPS-UPDATE-FLAG non-nil, HyWiki lookup tables
 should have already been updated and this is skipped.
 
-Use `hywiki-word-face' to highlight.  Do not highlight references to
-the current page unless they have sections attached.
+Use `hywiki-word-face' to highlight.  Do not highlight references
+to the current page unless they have sections attached.
 
-Dehighlight buffers other than HyWiki pages when `hywiki-mode' is
-disabled.  Highlight/dehighlight HyWiki page buffers whenever
-`hywiki-mode' is enabled/disabled."
+HyWiki mode must be active in the current buffer for highlighting
+to occur; otherwise, highlighting is removed and disabled in the
+current buffer.  Highlight/dehighlight HyWiki page buffers
+whenever `hywiki-mode' is enabled/disabled."
   (interactive (when (use-region-p) (list (region-beginning) (region-end))))
   ;; Avoid doing many lets for efficiency.
   ;; Highlight HyWikiWords throughout buffers where `hywiki-mode' is enabled
@@ -2499,15 +2508,17 @@ the current page unless they have sections attached."
   (file-name-sans-extension (file-name-nondirectory
                             (or (hypb:buffer-file-name) (buffer-name)))))
 
-(defun hywiki-get-buffers-in-windows ()
-  "Return the set of buffers attached to windows where `hywiki-mode' is 
active."
+(defun hywiki-get-buffers-in-windows (&rest frames)
+  "Return the set of buffers in all windows where `hywiki-mode' is active.
+This applies to all windows in all live frames or can be filtered to optional
+rest of arguments FRAMES."
   (apply #'set:create
         (apply #'nconc (mapcar (lambda (frame) (mapcar #'window-buffer
                                                        (window-list frame)))
-                               (frame-list)))))
+                               (or frames (frame-list))))))
 
-(defun hywiki-get-buffers (hywiki-buffer-mode)
-  "Return the list of window buffers active for HYWIKI-BUFFER-MODE.
+(defun hywiki-get-buffers (hywiki-mode-status)
+  "Return the list of window buffers active for HYWIKI-BUFFER-STATUS.
 See the function documentation for `hywiki-mode' for valid input
 values (the states of `hywiki-mode')."
   (when hywiki-mode
@@ -2516,7 +2527,7 @@ values (the states of `hywiki-mode')."
                          (and (not (and (boundp 'edebug-active) edebug-active 
(active-minibuffer-window)))
                               (not (apply #'derived-mode-p 
hywiki-exclude-major-modes))
                               (not (string-prefix-p " " (buffer-name buf)))
-                              (or (and (eq hywiki-buffer-mode :pages) 
(hywiki-in-page-p))
+                              (or (and (eq hywiki-mode-status :pages) 
(hywiki-in-page-p))
                                   (derived-mode-p 'kotl-mode)
                                   (not (eq (get major-mode 'mode-class) 
'special)))
                               buf)))
@@ -3148,6 +3159,8 @@ or this will return nil."
 
 (defun hywiki-word-at (&optional range-flag)
   "Return potential HyWikiWord and optional #section:Lnum:Cnum at point or nil.
+`hywiki-mode' must be enabled or this will return nil.
+
 If the HyWikiWord is delimited, point must be within the delimiters.
 This works regardless of whether the HyWikiWord has been highlighted
 or not.
@@ -3541,62 +3554,52 @@ auto-highlighting."
         (error "(hywiki-word-set-auto-highlighting): Inputs must be nil, 
:pages or :all, not '%s' and '%s'"
                hywiki-from-mode hywiki-to-mode))))
 
-(defun hywiki-word-set-auto-highlighting-buffers (hywiki-from-mode 
hywiki-to-mode)
-  "Set HyWikiWord auto-highlighting based on HYWIKI-FROM-MODE HYWIKI-TO-MODE.
-Highlight only those buffers attached to windows.
+(defun hywiki-word-highlight-in-frame (frame)
+  "Auto-highlight HyWikiWords in `hywiki-mode' buffers displayed FRAME."
+  (hywiki-word-highlight-in-buffers (hywiki-get-buffers-in-windows frame)))
 
-Auto-highlighting uses pre- and post-command hooks.  If an error
-occurs with one of these hooks, the problematic hook is removed.
-Invoke this command with a prefix argument to restore the
-auto-highlighting."
-  (cond ((eq hywiki-from-mode hywiki-to-mode)
-        nil)
-       ((null hywiki-from-mode)
-        (hywiki-word-highlight-buffers (hywiki-get-buffers hywiki-to-mode)))
-       ((and (eq hywiki-from-mode :all)   (eq hywiki-to-mode :pages))
-        (hywiki-word-dehighlight-buffers (set:difference (hywiki-get-buffers 
hywiki-from-mode)
-                                                         (hywiki-get-buffers 
hywiki-to-mode))))
-       ((and (eq hywiki-from-mode :pages) (eq hywiki-to-mode :all))
-        (hywiki-word-highlight-buffers (set:difference (hywiki-get-buffers 
hywiki-from-mode)
-                                                       (hywiki-get-buffers 
hywiki-to-mode))))
-       ((or (and (eq hywiki-from-mode :all)   (eq hywiki-to-mode nil))
-            (and (eq hywiki-from-mode :pages) (eq hywiki-to-mode nil)))
-        (hywiki-word-dehighlight-buffers (hywiki-get-buffers 
hywiki-from-mode)))
-       (t
-        (error "(hywiki-word-set-auto-highlighting): Inputs must be nil, 
:pages or :all, not '%s' and '%s'"
-               hywiki-from-mode hywiki-to-mode))))
-
-(defun hywiki-word-highlight-buffers (buffers)
+(defun hywiki-word-highlight-in-buffers (buffers)
   "Auto-highlight HyWikiWords in BUFFERS."
-  (interactive)
   (dolist (buf buffers)
     (with-current-buffer buf
       (add-hook 'pre-command-hook      'hywiki-word-store-around-point 95 
:local)
       (add-hook 'post-command-hook     'hywiki-word-highlight-post-command 95 
:local)
-      (add-hook 'post-self-insert-hook 'hywiki-word-highlight-post-self-insert 
:local)))
-  (add-hook 'window-buffer-change-functions
-           'hywiki-maybe-highlight-wikiwords-in-frame)
+      (add-hook 'post-self-insert-hook 'hywiki-word-highlight-post-self-insert 
95 :local)
+      ;; Display buffer before `normal-mode' triggers possibly
+      ;; long-running font-locking
+      (sit-for 0)
+      (hywiki-maybe-highlight-references nil nil t)))
+  ;; Rebuild lookup tables if any HyWiki page name has changed
+  (hywiki-get-referent-hasht)
+  (hywiki-maybe-directory-updated))
+
+(defun hywiki-word-highlight-buffers (buffers)
+  "Setup to auto-highlight HyWikiWords in BUFFERS."
+  (interactive)
+  (add-hook 'window-buffer-change-functions 'hywiki-word-highlight-in-frame)
   (add-to-list 'yank-handled-properties
               '(hywiki-word-face . hywiki-highlight-on-yank))
-  (hywiki-maybe-highlight-wikiwords-in-frame t)
+  (hywiki-word-highlight-in-buffers buffers)
   (when (called-interactively-p 'interactive)
     (message "HyWikiWord auto-highlighting enabled")))
 
 (defun hywiki-word-dehighlight-buffers (buffers)
   "Disable auto-highlighting of HyWikiWords in BUFFERS."
   (interactive)
+  (remove-hook 'window-buffer-change-functions 'hywiki-word-highlight-in-frame)
+  (setq yank-handled-properties
+       (delete '(hywiki-word-face . hywiki-highlight-on-yank)
+               yank-handled-properties))
   (dolist (buf buffers)
     (with-current-buffer buf
       (remove-hook 'pre-command-hook      'hywiki-word-store-around-point 
:local)
       (remove-hook 'post-command-hook     'hywiki-word-highlight-post-command 
:local)
-      (remove-hook 'post-self-insert-hook 
'hywiki-word-highlight-post-self-insert :local)))
-  (hywiki-mode 0) ;; also dehighlights HyWikiWords outside of HyWiki pages
-  (remove-hook 'window-buffer-change-functions
-              'hywiki-maybe-highlight-wikiwords-in-frame)
-  (hywiki-maybe-highlight-wikiwords-in-frame t)
-  (setq yank-handled-properties
-       (delete '(hywiki-word-face . hywiki-highlight-on-yank)
-               yank-handled-properties))
+      (remove-hook 'post-self-insert-hook 
'hywiki-word-highlight-post-self-insert :local)
+      ;; Display buffer before `normal-mode' triggers possibly
+      ;; long-running font-locking
+      (sit-for 0)
+      (hywiki-maybe-dehighlight-references)))
+  (hywiki-maybe-directory-updated)
   (when (called-interactively-p 'interactive)
     (message "HyWikiWord auto-highlighting disabled")))
 
diff --git a/test/hsys-org-tests.el b/test/hsys-org-tests.el
index a10103c3dc..37df30b40c 100644
--- a/test/hsys-org-tests.el
+++ b/test/hsys-org-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <[email protected]>
 ;;
 ;; Orig-Date:    23-Apr-21 at 20:55:00
-;; Last-Mod:     22-Nov-25 at 12:07:27 by Bob Weiner
+;; Last-Mod:     11-Jan-26 at 09:55:03 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -82,6 +82,7 @@
       ;; Out side of org-mode
       (erase-buffer)
       (fundamental-mode)
+      (hywiki-mode nil)
       (insert "[[hy:HyWiki]]\n\n")
       (goto-char 3)
       (ert-info ("Accept link if unknown HyWiki button")
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 7069393646..8eb85c95e3 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:      2-Jan-26 at 20:13:25 by Bob Weiner
+;; Last-Mod:     11-Jan-26 at 10:42:51 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -77,7 +77,7 @@ Last two elements are optional.")
         (with-temp-buffer
           (hywiki-tests--preserve-hywiki-mode
            (org-mode)
-           (hywiki-mode 1)
+           (hywiki-mode :all)
            (mapc
             (lambda (before-after)
               (condition-case err
@@ -259,10 +259,10 @@ This is for simulating the command loop."
 (ert-deftest hywiki-tests--verify-preserve-hywiki-mode ()
   "Verify `hywiki-tests--preserve-hywiki-mode' restores `hywiki-mode'."
   (hywiki-tests--preserve-hywiki-mode
-    (hywiki-mode 1)
+    (hywiki-mode :all)
     (hywiki-tests--preserve-hywiki-mode
       (should hywiki-mode)
-      (hywiki-mode 0)
+      (hywiki-mode nil)
       (should-not hywiki-mode))
     (should hywiki-mode)))
 
@@ -302,7 +302,7 @@ This is for simulating the command loop."
           (wikifile "WikiWord.org"))
       (unwind-protect
           (with-temp-buffer
-           (hywiki-mode 1)
+           (hywiki-mode :all)
             (insert "[[hy:WikiWord]]")
             (goto-char 4)
             (action-key)
@@ -317,7 +317,7 @@ This is for simulating the command loop."
           (hywiki-directory (make-temp-file "hywiki" t)))
       (unwind-protect
           (with-temp-buffer
-           (hywiki-mode 1)
+           (hywiki-mode :all)
             (insert "[[hy:WikiWord]]")
             (goto-char 6)
             (should (string= "WikiWord" (hywiki-word-at)))
@@ -341,7 +341,7 @@ This is for simulating the command loop."
                 (should (file-exists-p hywiki-page-file))
               (should-not (file-exists-p hywiki-page-file)))
             (with-temp-buffer
-             (hywiki-mode 1)
+             (hywiki-mode :all)
               (insert "WikiWord\n")
               (goto-char 4)
               (action-key)
@@ -368,7 +368,7 @@ This is for simulating the command loop."
             (dolist (v sections)
               (insert (format "%s\nbody\n" v)))
             (save-buffer)
-           (hywiki-mode 1)
+           (hywiki-mode :all)
             (dolist (v sections)
               (with-temp-buffer
                 (insert "WikiWord#" (cadr (split-string v " ")))
@@ -393,7 +393,7 @@ line 1
 line 2
 ")
             (save-buffer)
-           (hywiki-mode 1)
+           (hywiki-mode :all)
             (dolist (l '(1 2))
               (dolist (c '("" ":C0" ":C5"))
                 (with-temp-buffer
@@ -414,11 +414,11 @@ line 2
           (hywiki-directory (make-temp-file "hywiki" t)))
       (unwind-protect
           (with-temp-buffer
-            (hywiki-mode 0)
+            (hywiki-mode nil)
             (insert "WikiWord")
             (goto-char 4)
             (should-not (hywiki-word-at))
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (should (string= "WikiWord" (hywiki-word-at))))
         (hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
 
@@ -431,7 +431,7 @@ line 2
           (wiki-page (cdr referent)))
       (unwind-protect
           (with-current-buffer (find-file-noselect wiki-page)
-            (hywiki-mode 0)
+            (hywiki-mode :pages)
             (insert "PotentialWikiWord")
            (newline nil t)
             (goto-char 4)
@@ -447,7 +447,7 @@ line 2
           (hywiki-directory (make-temp-file "hywiki" t)))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
 
           ;; Matches a WikiWord
           (dolist (v '("WikiWord" "[WikiWord]" "[[WikiWord]]" "{WikiWord}" 
"(WikiWord)"
@@ -501,7 +501,7 @@ line 2
               (if (string= "WikiWord" (hywiki-word-at))
                  (should v)
                (should-not v)))))
-      (hywiki-mode 0)
+      (hywiki-mode nil)
       (hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
 
 (ert-deftest hywiki-tests--at-wikiword-finds-word-and-section ()
@@ -516,7 +516,7 @@ line 2
                    )))
       (unwind-protect
           (with-temp-buffer
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (dolist (w words)
               (let ((in (if (stringp w) w (car w)))
                     (expect (if (stringp w) w (cdr w))))
@@ -532,7 +532,7 @@ line 2
     (let ((hywiki-directory (make-temp-file "hywiki" t)))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer
               (insert "WikiWord#section rest is ignored")
               (goto-char 4)
@@ -559,7 +559,7 @@ HyWikiWord reference."
     (let ((hywiki-directory (make-temp-file "hywiki" t)))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer           ; Delimited string allow space
               (insert "\"WikiWord#section rest\"")
               (goto-char 4)
@@ -615,17 +615,17 @@ HyWikiWord reference."
   "Verify `hywiki-active-in-current-buffer-p'."
   (let* ((hywiki-directory (make-temp-file "hywiki" t))
          (wiki-page (cdr (hywiki-add-page "WikiWord")))
-         (hywiki-mode t))
+         (hywiki-mode :all))
     (unwind-protect
         (with-current-buffer (find-file-noselect wiki-page)
           (should (hywiki-active-in-current-buffer-p))
-          (let ((hywiki-mode nil))
-            (should-not (hywiki-active-in-current-buffer-p)))
+          (hywiki-mode nil)
+          (should-not (hywiki-active-in-current-buffer-p))
           (let ((hywiki-exclude-major-modes (list 'org-mode)))
             (should-not (hywiki-active-in-current-buffer-p)))
-         (let (hywiki-mode)
-            (mocklet ((hywiki-in-page-p => nil))
-              (should-not (hywiki-active-in-current-buffer-p))))
+         (hywiki-mode nil)
+          (mocklet ((hywiki-in-page-p => nil))
+            (should-not (hywiki-active-in-current-buffer-p)))
           (dired-mode)
           (should-not (hywiki-active-in-current-buffer-p)))
       (hy-delete-file-and-buffer wiki-page)
@@ -758,7 +758,7 @@ Both mod-time and checksum must be changed for a test to 
return true."
            (wikipage (cdr (hywiki-add-page "WikiWord"))))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer
               (insert "WikiWor")
              (hywiki-tests--command-execute #'self-insert-command 1 ?d)
@@ -781,7 +781,7 @@ Both mod-time and checksum must be changed for a test to 
return true."
       (unwind-protect
           (progn
             (with-temp-buffer
-              (hywiki-mode 0)
+              (hywiki-mode nil)
               (insert "WikiWor")
              (hywiki-tests--command-execute #'self-insert-command 1 ?d)
               (goto-char 4)
@@ -796,7 +796,7 @@ Both mod-time and checksum must be changed for a test to 
return true."
            (wikipage (cdr (hywiki-add-page "WikiWord"))))
       (unwind-protect
           (with-temp-buffer
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (insert "Wikiord ")
             (goto-char 5)
             (should (looking-at-p "ord "))
@@ -822,7 +822,7 @@ Both mod-time and checksum must be changed for a test to 
return true."
       (unwind-protect
           (progn
             (with-temp-buffer
-              (hywiki-mode 1)
+              (hywiki-mode :all)
               (insert "WikiWord")
               (hywiki-tests--command-execute #'self-insert-command 1 ? )
               (goto-char 1)
@@ -848,7 +848,7 @@ Both mod-time and checksum must be changed for a test to 
return true."
            (wikipage (cdr (hywiki-add-page "WikiWord"))))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer
              (setq default-directory hywiki-directory)
               (insert "WikiWord#section:L2:C4")
@@ -985,7 +985,7 @@ body B
             ;; Create temp buffers with WikiWord links to the target
             ;; WikiWord page and verify they work.
             (with-temp-buffer
-              (hywiki-mode 1)
+              (hywiki-mode :all)
               (let (wiki-link
                    expected-str-at-pos)
                (condition-case err-msg
@@ -1616,7 +1616,7 @@ See gh#rswgnu/hyperbole/669."
     (let* ((hywiki-directory (make-temp-file "hywiki" t))
            (wiki-page (cdr (hywiki-add-page "WikiWord"))))
       (with-temp-buffer
-        (hywiki-mode 0)
+        (hywiki-mode nil)
         (insert "WikiWor")
         (hywiki-tests--command-execute #'self-insert-command 1 ?d)
         (goto-char 4)
@@ -1624,7 +1624,7 @@ See gh#rswgnu/hyperbole/669."
       (unwind-protect
           (progn
             (with-temp-buffer
-              (hywiki-mode 1)
+              (hywiki-mode :all)
               (insert "WikiWor")
              (hywiki-tests--command-execute #'self-insert-command 1 ?d)
               (goto-char 4)
@@ -1764,7 +1764,7 @@ resulting state at point is a WikiWord or not."
            (hywiki-tests--with-face-test nil))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (dolist (testcase hywiki-tests--wikiword-step-check)
               (with-temp-buffer
                 (hywiki-tests--run-test-case testcase))))
@@ -1784,7 +1784,7 @@ is a WikiWord at point or not."
            (wiki-page-list (list wikiHiHo wikiHiho wikiHi wikiHo)))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (dolist (testcase hywiki-tests--wikiword-step-check)
               (with-temp-buffer
                 (hywiki-tests--run-test-case testcase))))
@@ -1804,7 +1804,7 @@ Insert test in the middle of other text."
            (hywiki-tests--with-face-test nil))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer
               (insert hywiki-tests--lorem-ipsum)
               (goto-char (/ (point-max) 2))
@@ -1838,7 +1838,7 @@ face is verified during the change."
            (wiki-page (cdr (hywiki-add-page "WikiWord"))))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-temp-buffer
               (emacs-lisp-mode)
               (insert "\
@@ -1863,7 +1863,7 @@ face is verified during the change."
            (wiki-page (cdr (hywiki-add-page "WikiWord"))))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
 
             ;; Matches a WikiWord
             (dolist (v '("WikiWord" "[WikiWord]" "[[WikiWord]]" "{WikiWord}" 
"(WikiWord)"
@@ -1907,7 +1907,7 @@ face is verified during the change."
   (hywiki-tests--preserve-hywiki-mode
     (unwind-protect
         (let ((words '("Foo" "Bar" "Baz" "Qux")))
-          (hywiki-mode 1)
+          (hywiki-mode :all)
           (with-temp-buffer
             (emacs-lisp-mode)
             (insert
@@ -1932,9 +1932,9 @@ face is verified during the change."
             (insert "\"DEMO\" \"DEMO.org\"\n")
             (goto-char 2)
             (should (looking-at-p "DEMO\" "))
-            (hywiki-mode 0)
+            (hywiki-mode nil)
             (should (ibtype:test-p 'pathname))
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (should (ibtype:test-p 'pathname))
             (goto-char 9)
             ;; Verify that using the org extension selects the WikiWord.
@@ -1951,7 +1951,7 @@ face is verified during the change."
            (hywiki-page-with-section (expand-file-name "WikiWord.org#section" 
hywiki-directory)))
       (unwind-protect
           (with-temp-buffer
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (insert "WikiWord#section")
             (goto-char 4)
             (action-key)
@@ -1969,7 +1969,7 @@ face is verified during the change."
            (hywiki-tests--with-face-test t))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (dolist (testcase
                      '((("\"Hi#a b c\"") (p3 . "Hi#a b c") (p11) (-1) (p3 . 
"Hi#a") (p10) ("\"") (p3 . "Hi#a b c"))
                        (("(Hi#s n)" . "Hi#s n") (-1) (p3 . "Hi#s") (p8) (")" . 
"Hi#s n"))))
@@ -1987,7 +1987,7 @@ face is verified during the change."
            (hywiki-tests--with-face-test t))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             ;; Left part of WikiWord yanked in.
             (with-temp-buffer
               (insert "i#s")
@@ -2041,7 +2041,7 @@ face is verified during the change."
            wikiHo)
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-current-buffer (find-file wikiHi)
               (insert "Ho")
               (save-buffer)
@@ -2062,7 +2062,7 @@ expected result."
           (wikiword (cdr (hywiki-add-page "WiWo"))))
       (unwind-protect
          (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (dolist (v `(("WiWo" . ((1 . 5)))
                          ("WiWo text" . ((1 . 5)))
                          ("WiWo WiWo" . ((1 . 5) (6 . 10)))
@@ -2131,7 +2131,7 @@ expected result."
            (wikiHo (cdr (hywiki-add-page "Ho"))))
       (unwind-protect
           (progn
-            (hywiki-mode 1)
+            (hywiki-mode :all)
             (with-current-buffer (find-file wikiHo)
               (insert "123"))
             (with-current-buffer (find-file wikiHi)
@@ -2145,7 +2145,7 @@ expected result."
   "Verify `hywiki-mode' called interactively toggles mode."
   (hywiki-tests--preserve-hywiki-mode
     (with-temp-buffer
-      (hywiki-mode 1)
+      (hywiki-mode :all)
       (should hywiki-mode)
       ;; Toggle
       (call-interactively #'hywiki-mode)
diff --git a/test/hywiki-yki-tests.el b/test/hywiki-yki-tests.el
index 487b00a725..4257a58257 100644
--- a/test/hywiki-yki-tests.el
+++ b/test/hywiki-yki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    13-Jul-25 at 19:50:37
-;; Last-Mod:     16-Nov-25 at 11:16:45 by Bob Weiner
+;; Last-Mod:     11-Jan-26 at 10:35:55 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -177,13 +177,14 @@ Each test is constructed as three phases:
                   (should (string= stop 
(hywiki-test--get-buffer-text-with-point-and-highlight)))))
        (unwind-protect
            (progn
+            (hywiki-mode :all)
              (ert-info ("1" :prefix "Verify point, no highlighting:")
-               (pre: "hej^hopp")
-               (post: "hej^hopp"))
+               (pre: "non^wikiword")
+               (post: "non^wikiword"))
              (ert-info ("2" :prefix "Verify point, no highlighting: ")
-               (pre: "hej^hopp")
+               (pre: "non^wikiword")
                (forward-char 1)
-               (post: "hejh^opp"))
+               (pre: "nonw^ikiword"))
              (ert-info ("3" :prefix "Verify highlighting: ")
                (pre: "^Hi")
                (post: "^<Hi>"))

Reply via email to