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

    hywiki.el - Rework to use per-buffer command hooks
    
    Remove use of 'page-name' in hywiki reference functions.
    
    Make hywiki-mode code follow the doc specification.
---
 ChangeLog            |  59 ++++
 hibtypes.el          |  49 +++-
 hsys-activities.el   |  28 +-
 hynote.el            |   6 +-
 hyperbole.el         |   8 +-
 hywiki.el            | 771 +++++++++++++++++++++++++++------------------------
 hywiki/HyWiki.org    |  12 +-
 man/hyperbole.texi   |  26 +-
 test/hywiki-tests.el |  10 +-
 9 files changed, 557 insertions(+), 412 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 965f6eb0a5..e4b52b9069 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,62 @@
+2026-01-06  Bob Weiner  <[email protected]>
+
+* hywiki.el (hywiki-get-buffers-in-windows): Add and call in
+   'hywiki-get-buffers'.
+
+2026-01-05  Bob Weiner  <[email protected]>
+
+* hibtypes.el (hywiki-word): Move from "hywiki.el" to here.
+
+* hyperbole.el: Add (require 'hywiki).
+                (hyperb:init): (hywiki-mode :pages) at the end.
+
+2026-01-02  Bob Weiner  <[email protected]>
+
+* hywiki.el (hywiki-maybe-highlight-page-names): Rename to
+    'hywiki-maybe-highlight-references'.
+            (hywiki-maybe-highlight-page-name): Rename to
+    'hywiki-maybe-highlight-reference'.
+            (hywiki-maybe-highlight-between-page-names): Rename to
+    'hywiki-maybe-highlight-between-references'.
+            (hywiki-maybe-highlight-off-page-name): Rename to
+    'hywiki-maybe-highlight-off-reference'.
+            (hywiki-maybe-highlight-on-page-name): Rename to
+    'hywiki-maybe-highlight-on-reference'.
+            (hywiki-maybe-highlight-word): Rename to
+    'hywiki-maybe-highlight-region-reference'.
+            (hywiki-maybe-dehighlight-page-names): Rename to
+    'hywiki-maybe-dehighlight-references'.
+            (hywiki-maybe-dehighlight-between-page-names): Rename to
+    'hywiki-maybe-dehighlight-between-references'.
+            (hywiki-maybe-dehighlight-off-page-name): Rename to
+    'hywiki-maybe-dehighlight-off-reference'.
+            (hywiki-maybe-dehighlight-on-page-name): Rename to
+    'hywiki-maybe-dehighlight-on-reference'.
+            (hywiki-maybe-dehighlight-page-name): Rename to
+    'hywiki-maybe-dehighlight-reference'.
+
+2025-12-30  Bob Weiner  <[email protected]>
+
+* hywiki.el (hywiki-get-buffers): Add to return active hywiki-mode buffers.
+            (hywiki-word-set-auto-highlighting): Rewrite to account for 
'hywiki-mode'
+    setting before and after this call.  Apply highlighting hooks locally
+    to each buffer.  Remove interactive use.
+            (hywiki-word-highlight-buffers, hywiki-word-dehighlight-buffers): 
Add and use in above function.
+
+2025-12-27  Bob Weiner  <[email protected]>
+
+* hywiki.el (hywiki-word-highlight-flag, hywiki-word-highlight-flag-changed): 
Remove.
+            (hywiki-mode, hywiki-in-page-p): Remove 
'hywiki-word-highlight-flag' and
+    update to support` all 'hywiki-mode' values.
+            (hywiki-maybe-dehighlight-sexp):
+            (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):
+
+* hibtypes.el (hywiki-existing-word):
+  hywiki.el (hywiki-word): Skip if not 'hywiki-active-in-current-buffer-p'.
+
 2025-12-13  Bob Weiner  <[email protected]>
 
 * MANIFEST: Add "HY-TALK/HYPERBOLEQA.kotl" from EmacsConf2025 talk.
diff --git a/hibtypes.el b/hibtypes.el
index ce1b8ed7fe..ed8a83c540 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:     22-Nov-25 at 12:40:34 by Bob Weiner
+;; Last-Mod:      5-Jan-26 at 23:42:19 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -108,8 +108,28 @@
 ;;; Creates and displays personal wiki pages and sections with auto-wikiword 
links
 ;;; ========================================================================
 
-;; Defines `hywiki-word' ibtype
-(load "hywiki" nil t)
+(defib hywiki-word ()
+  "When on a non-existing HyWikiWord, create it and display its referent.
+A call to (hywiki-active-in-current-buffer-p) must return non-nil
+for this to activate.
+
+If the associated HyWiki referent is a page, create it automatically
+unless it is the first HyWiki page to be created, in which case,
+prompt the user whether to create it, to prevent any unexpected HyWiki
+use.
+
+Existing HyWikiWords are handled by the implicit button type
+`hywiki-existing-word'."
+  (when (hywiki-active-in-current-buffer-p)
+    (let* ((wikiword-start-end (hywiki-highlight-word-get-range))
+          (wikiword (nth 0 wikiword-start-end))
+          (start    (nth 1 wikiword-start-end))
+          (end      (nth 2 wikiword-start-end)))
+      (when wikiword
+       (unless (or (ibtypes::pathname-line-and-column)
+                   (ibtypes::pathname))
+         (ibut:label-set wikiword start end)
+         (hact 'hywiki-word-create-and-display wikiword))))))
 
 ;;; ========================================================================
 ;;; Jumps to source line from Python traceback lines
@@ -1713,25 +1733,28 @@ If a boolean function or variable, display its value."
        (error "(action:help): No action button labeled: %s" label)))))
 
 ;;; ========================================================================
-;;; Activates HyWikiWords with existing HyWiki pages.
+;;; Activates HyWikiWords with existing referents.
 ;;; Non-existing HyWikiWords are handled by the (load "hywiki") at a low
 ;;; priority earlier in this file which defines the `hywiki-word' ibtype.
 ;;; ========================================================================
 
 (defib hywiki-existing-word ()
   "On a HyWikiWord with an existing referent, display the referent.
+A call to (hywiki-active-in-current-buffer-p) must return non-nil
+for this to activate.
 
 See the implicit button type `hywiki-word' for creation of referents to
 not yet existing HyWikiWords."
-  (cl-destructuring-bind (wikiword start end)
-      (hywiki-referent-exists-p :range)
-    (when wikiword
-      (unless (or (ibtypes::pathname-line-and-column)
-                 (ibtypes::pathname))
-       (if (and start end)
-           (ibut:label-set wikiword start end)
-         (ibut:label-set wikiword))
-       (hact 'hywiki-find-referent wikiword)))))
+  (when (hywiki-active-in-current-buffer-p)
+    (cl-destructuring-bind (wikiword start end)
+       (hywiki-referent-exists-p :range)
+      (when wikiword
+       (unless (or (ibtypes::pathname-line-and-column)
+                   (ibtypes::pathname))
+         (if (and start end)
+             (ibut:label-set wikiword start end)
+           (ibut:label-set wikiword))
+         (hact 'hywiki-find-referent wikiword))))))
 
 ;;; ========================================================================
 ;;; Inserts completion into minibuffer or other window.
diff --git a/hsys-activities.el b/hsys-activities.el
index 9131ae13ab..433f381fe8 100644
--- a/hsys-activities.el
+++ b/hsys-activities.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:     7-Dec-25 at 22:48:29
-;; Last-Mod:     11-Dec-25 at 22:26:21 by Mats Lidell
+;; Last-Mod:      2-Jan-26 at 21:31:06 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -28,8 +28,15 @@
 ;;; Requirements
 ;;; ************************************************************************
 
+(hypb:require-package 'activities)
 (require 'hypb)
 
+(add-hook 'activities-tabs-mode-hook
+         (lambda ()
+           (when activities-tabs-mode
+             (advice-remove #'activities-resume 
#'activities-tabs-before-resume)
+             (advice-add #'hsys-activities-before-resume :before 
#'activities-tabs-before-resume))))
+
 ;;; ************************************************************************
 ;;; Public declarations
 ;;; ************************************************************************
@@ -55,27 +62,32 @@
 - If activity NAME is not active, switch to its latest state.
 - If activity NAME is active and current, revert to its default state.
 - If activity NAME is active and hsys-activity is called with
-  `current-prefix-arg' set then set the default state."
+  `current-prefix-arg', then update the default state."
   (interactive (list (completing-read "Activity: " (activities-names) nil 
nil)))
-  (hypb:require-package 'activities)
   (let ((activity (activities-named name)))
     (cond ((not activity)
            (activities-define name)
-           (message "Activity %s defined." name))
+           (message "Activity %s defined" name))
           ((let ((current-activity (activities-current)))
              (and current-activity
-                  (string=
+                  (string-equal
                    (activities-name-for activity)
                    (activities-name-for current-activity))))
            (if current-prefix-arg
                (progn
                  (activities-define name :forcep t)
-                 (message "Activity %s set to new default." name))
+                 (message "Activity %s set to new default" name))
              (activities-revert activity)
-             (message "Activity %s reverted." name)))
+             (message "Activity %s reverted" name)))
           (t
            (activities-resume activity)
-           (message "Activity %s resumed." name)))))
+           (message "Activity %s resumed" name)))))
+
+(defun hsys-activities-before-resume (activity)
+  (if (and activities-tabs-mode
+          (tab-switcher-current-tab nil))
+      (activities-revert activity)
+    (activities-resume activity)))
 
 (provide 'hsys-activities)
 ;;; hsys-activities.el ends here
diff --git a/hynote.el b/hynote.el
index 4a01fff18f..e7099e375e 100644
--- a/hynote.el
+++ b/hynote.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    23-Jun-24 at 12:50:37
-;; Last-Mod:      1-Sep-24 at 14:26:02 by Bob Weiner
+;; Last-Mod:      2-Jan-26 at 20:13:25 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -105,7 +105,7 @@ After successfully finding a file and reading it into a 
buffer, run
     (when (and (stringp section) (not (string-prefix-p "#" section)))
       (setq section (concat "#" section)))
     (hpath:find (concat file section))
-    (hywiki-maybe-highlight-page-names)
+    (hywiki-maybe-highlight-references)
     (run-hooks 'hynote-find-file-hook)
     file))
 
@@ -126,7 +126,7 @@ After successfully finding a file and reading it into a 
buffer, run
                        (substring file-stem-name (match-beginning 0))))
        (when file
          (hpath:find (concat file section))
-         (hywiki-maybe-highlight-page-names)
+         (hywiki-maybe-highlight-references)
          (run-hooks 'hynote-find-file-hook)
          file)))))
 
diff --git a/hyperbole.el b/hyperbole.el
index 00ab699ad2..b85a01d908 100644
--- a/hyperbole.el
+++ b/hyperbole.el
@@ -9,7 +9,7 @@
 ;; Maintainer:   Robert Weiner <[email protected]>
 ;; Maintainers:  Robert Weiner <[email protected]>, Mats Lidell <[email protected]>
 ;; Created:      06-Oct-92 at 11:52:51
-;; Last-Mod:      2-Oct-25 at 14:28:52 by Mats Lidell
+;; Last-Mod:      6-Jan-26 at 00:54:01 by Bob Weiner
 ;; Released:     10-Mar-24
 ;; Version:      9.0.2pre
 ;; Keywords:     comm, convenience, files, frames, hypermedia, languages, 
mail, matching, mouse, multimedia, outlines, tools, wp
@@ -180,6 +180,7 @@ Info documentation at \"(hyperbole)Top\".
 (require 'set (expand-file-name "set" hyperb:dir))
 (require 'hypb)
 (require 'hui-select)  ;; This requires 'hvar which defines the var:append 
function.
+(require 'hywiki)
 
 ;;; ************************************************************************
 ;;; Public Variables
@@ -500,7 +501,7 @@ frame, those functions by default still return the prior 
frame."
   ;; loaded parts of Org before his load path is finalized.  It loads
   ;; the newer version of Org, if any, assuming `load-path' is configured
   ;; correctly.
-  (hsys-org-fix-version)
+  ;; (hsys-org-fix-version)
   ;;
   ;; When vertico-mode is used, vertico-mouse-mode is needed for the
   ;; Action Key to properly select completions from the candidate
@@ -509,6 +510,9 @@ frame, those functions by default still return the prior 
frame."
   (when (fboundp #'vertico-mouse-mode)
     (add-hook 'vertico-mode-hook (lambda () (vertico-mouse-mode 1))))
   ;;
+  ;; Set HyWiki page auto-HyWikiWord highlighting and `yank-handled-properties'
+  (hywiki-mode :pages)
+  ;;
   ;; Hyperbole initialization is complete.
   (message "Initializing Hyperbole...done"))
   
diff --git a/hywiki.el b/hywiki.el
index e86769e8e1..2bb55eb28b 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:     30-Nov-25 at 18:06:52 by Bob Weiner
+;; Last-Mod:     11-Jan-26 at 05:58:25 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -24,7 +24,7 @@
 ;;
 ;;  HyWikiWords are also recognized in text buffers after the global
 ;;  minor mode, `hywiki-mode' is enabled via {M-x hywiki-mode RET}.  To
-;;  create or jump to a HyWiki page, simply type out a potential
+;;  create or jump to a HyWiki page, simply type o ut a potential
 ;;  HyWikiWord or move point onto one and press the Action Key {M-RET}.
 ;;  This will create the associated page if it does not exist.  This
 ;;  also highlights any other instances of HyWikiWords across all
@@ -68,15 +68,14 @@
 ;;  When activating a link with a section reference, you will get an
 ;;  error if the section does not exist.
 ;;
-;;  The custom setting, `hywiki-word-highlight-flag' (default = t),
-;;  means HyWikiWords will be auto-highlighted within HyWiki pages.
-;;  Outside of such pages, `hywiki-mode' must also be enabled for such
-;;  auto-highlighting.  Auto-highlighting depends on pre- and
+;;  By default (hywiki-mode = :pages), HyWikiWords are
+;;  auto-highlighted within HyWiki pages only.  Outside of such pages,
+;;  `hywiki-mode' must be set to :all to enable auto-highlighting in
+;;  programming and text modes.  Auto-highlighting depends on pre- and
 ;;  `post-command-hook' settings.  If an error occurs running one of
-;;  these, the associated hook is removed.  To restore the auto-highlight
-;;  hooks either use {M-x hywiki-word-set-auto-highlighting RET} or
-;;  {C-u C-h h h m} to toggle `hywiki-mode'; this also enables
-;;  auto-highlighting if `hywiki-word-highlight-flag' is non-nil.
+;;  these, the associated hook is removed.  To restore the
+;;  auto-highlight hooks use {C-u C-h h h m} to  toggle `hywiki-mode';
+;;  this also enables auto-highlighting when `hywiki-mode' is non-nil.
 
 ;;  The custom setting, `hywiki-exclude-major-modes' (default = nil), is
 ;;  a list of major modes to exclude from HyWikiWord auto-highlighting
@@ -89,7 +88,7 @@
 ;;  (default = '(lisp-interaction-mode)).
 ;;
 ;;  HyWiki adds two implicit button types to Hyperbole:
-;;    `hywiki-word' - creates and displays HyWikiWord referents;
+;;    `hywiki-word'          - create and display HyWikiWord referents;
 ;;    `hywiki-existing-word' - display an existing HyWikiWord referent.
 ;;
 ;;  `hywiki-word' is one of the lowest priority implicit button types
@@ -231,7 +230,7 @@ Each element is of the form: (wikiword . (referent-type . 
referent-value)).")
   "HyWiki hash table for fast WikiWord referent lookup.")
 
 ;; Globally set these values to avoid using 'let' with stack allocations
-;; within `hywiki-maybe-highlight-page-name' frequently.
+;; within `hywiki-maybe-highlight-reference' frequently.
 (defvar hywiki--any-wikiword-regexp-list nil)
 (defvar hywiki--current-page nil)
 (defvar hywiki--highlighting-done-flag t)
@@ -254,25 +253,6 @@ Each element is of the form: (wikiword . (referent-type . 
referent-value)).")
 ;;; Public variables
 ;;; ************************************************************************
 
-(defcustom hywiki-word-highlight-flag t
-  "The default, non-nil value treats HyWikiWords in HyWiki pages as hyperlinks.
-A nil value disables HyWikiWord hyperlink buttons in both HyWiki
-pages and all other buffers (since it also disables `hywiki-mode').
-
-Outside of HyWiki pages, the global minor mode `hywiki-mode' must be
-manually enabled for auto-HyWikiWord highlighting. Interactively, {C-h
-h h m a} does this; programmatically, use `(hywiki-mode :all)' to
-enable it.
-
-Use `hywiki-active-in-current-buffer-p' to determine if HyWikiWord
-hyperlinks are currently active in a buffer or not.
-
-Regardless of this flag, HyWikiWords in Org links and targets are not
-highlighted nor treated as hyperlinks; they are handled normally by Org."
-  :type 'boolean
-  :initialize #'custom-initialize-default
-  :group 'hyperbole-hywiki)
-
 (defcustom hywiki-exclude-major-modes nil
   "List of major modes to exclude from HyWikiWord highlighting and 
recognition."
   :type '(list symbol)
@@ -464,7 +444,7 @@ where PATH is the un-resolvable reference."
 The file must be below `hywiki-directory'.
 
 For reference, this is set when `window-buffer-change-functions' calls
-`hywiki-maybe-highlight-page-names' which calls `hywiki-in-page-p'.")
+`hywiki-maybe-highlight-references' which calls `hywiki-in-page-p'.")
 
 (defcustom hywiki-referent-prompt-flag nil
   "When t, the Action Key and HyWiki/Create always prompt for referent type.
@@ -666,8 +646,8 @@ deletion commands and those in 
`hywiki-non-character-commands'."
                 (hywiki--extend-region
                  (min hywiki--start hywiki--end)
                  (max hywiki--start hywiki--end))
-              (hywiki-maybe-dehighlight-page-names start end)
-              (hywiki-maybe-highlight-page-names start end))))
+              (hywiki-maybe-dehighlight-references start end)
+              (hywiki-maybe-highlight-references start end))))
 
          ((when (or (memq this-command hywiki-non-character-commands)
                     (and (symbolp this-command)
@@ -765,9 +745,9 @@ or activate typed referents such as bookmarks.
 HyWiki minor mode has three states as tracked by the following values
 of the `hywiki-mode' variable:
   - :pages - highlight HyWikiWords in HyWiki pages only (Org files in
-    `hywiki-directory')
-  - :all   - highlight hyWikiWords in all editable buffers except those with
-    a major mode in `hywiki-exclude-major-modes'.
+             `hywiki-directory')
+  - :all   - highlight HyWikiWords in all editable buffers except those
+             with a major mode in `hywiki-exclude-major-modes'.
   - nil    - no highlighting, the mode is disabled.
 
 HyWikiWord references may also include optional suffixes:
@@ -789,6 +769,23 @@ See the Info documentation at \"(hyperbole)HyWiki\".
   :keymap hywiki-mode-map
   :group 'hyperbole-hywiki
   (progn
+    (unless hywiki-mode-map
+      (setq hywiki-mode-map (make-sparse-keymap)))
+    ;; Normalize `hywiki-mode' setting
+    (cond
+     ((or (and (integerp hywiki-mode) (= hywiki-mode 1))
+         (memq hywiki-mode '(:all t)))
+      ;; Enable across all editable buffers
+      (setq hywiki-mode :all))
+     ((or (and (integerp hywiki-mode) (<= hywiki-mode 0))
+         (null hywiki-mode))
+      ;; Disable across all editable buffers.
+      (setq hywiki-mode nil))
+     (t ;; (> hywiki-mode 1)
+      ;; Enable in HyWiki page buffers only
+      (setq hywiki-mode :pages)))
+
+    ;; Normalize `arg' and set mode
     (when (memq arg '(toggle :toggle))
       ;; Toggle across all editable buffers
       (setq arg (if hywiki-mode 1 0)))
@@ -796,53 +793,34 @@ See the Info documentation at \"(hyperbole)HyWiki\".
      ((or (and (integerp arg) (= arg 1))
          (memq arg '(:all t)))
       ;; Enable across all editable buffers
+      (setq arg :all)
       ;; Need hyperbole-mode
-      (require 'hyperbole)
       (unless hyperbole-mode
        (hyperbole-mode 1))
-      (unless hywiki-mode-map
-        (setq hywiki-mode-map (make-sparse-keymap)))
-      ;; Next line triggers a call to `hywiki-word-set-auto-highlighting'.
-      (set-variable 'hywiki-word-highlight-flag t)
-      (setq hywiki-mode :all))
+      (hywiki-word-set-auto-highlighting hywiki-mode arg)
+      (setq hywiki-mode arg))
      ((or (and (integerp arg) (<= arg 0))
          (null arg))
       ;; Disable across all editable buffers.
+      (setq arg nil)
       ;; 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-word-highlight-flag' is nil.
+      ;; HyWiki page buffer, then dehighlight when `hywiki-mode' is nil.
       (hywiki-maybe-highlight-wikiwords-in-frame t)
-      (setq hywiki-mode nil))
+      (setq hywiki-mode arg))
      (t ;; (> arg 1)
       ;; Enable in HyWiki page buffers only
-      ;; Next line triggers a call to `hywiki-word-set-auto-highlighting'.
-      (set-variable 'hywiki-word-highlight-flag t)
-      (setq hywiki-mode :pages)))))
+      (setq arg :pages)
+      ;; Need hyperbole-mode
+      (unless hyperbole-mode
+       (hyperbole-mode 1))
+      (hywiki-word-set-auto-highlighting hywiki-mode arg)
+      (setq hywiki-mode arg)))))
 
 ;;; ************************************************************************
 ;;; Public Implicit Button and Action Types
 ;;; ************************************************************************
 
-(defib hywiki-word ()
-  "When on a non-existing HyWikiWord, create it and display its referent.
-If the associated HyWiki referent is a page, create it automatically
-unless it is the first HyWiki page to be created, in which case,
-prompt the user whether to create it, to prevent any unexpected HyWiki
-use.
-
-Existing HyWikiWords are handled by the implicit button type
-`hywiki-existing-word'."
-  (let* ((wikiword-start-end (hywiki-highlight-word-get-range))
-        (wikiword (nth 0 wikiword-start-end))
-        (start    (nth 1 wikiword-start-end))
-        (end      (nth 2 wikiword-start-end)))
-    (when wikiword
-      (unless (or (ibtypes::pathname-line-and-column)
-                 (ibtypes::pathname))
-       (ibut:label-set wikiword start end)
-       (hact 'hywiki-word-create-and-display wikiword)))))
-
 (defun hywiki-display-referent-type (wikiword referent)
   "Display WIKIWORD REFERENT, a cons of (<referent-type> . <referent-value>).
 Function used to display is \"hywiki-display-<referent-type>\"."
@@ -890,15 +868,15 @@ After successfully finding a referent, run 
`hywiki-display-referent-hook'."
                       wikiword referent)
              ;; Ensure highlight any page name at point in case called as a
              ;; Hyperbole action type
-             (hywiki-maybe-highlight-page-name t)
+             (hywiki-maybe-highlight-reference t)
              (hywiki-display-referent-type wikiword referent)
-             (hywiki-maybe-highlight-page-names)
+             (hywiki-maybe-highlight-references)
              (run-hooks 'hywiki-display-referent-hook)
              referent)))
       ;; When called without a wikiword and outside hywiki-directory,
       ;; just find as a regular file and use next line to highlight
       ;; HyWikiWords only if buffer was not previously highlighted.
-      (hywiki-maybe-highlight-page-names)
+      (hywiki-maybe-highlight-references)
       nil)))
 
 (defun hywiki-help ()
@@ -1014,13 +992,13 @@ with the referent."
 (defun hywiki-active-in-current-buffer-p ()
   "Return non-nil if HyWikiWord links are active in the current buffer.
 Exclude the minibuffer if selected and return nil."
-  (and hywiki-word-highlight-flag
+  (and hywiki-mode
        (not (minibuffer-window-active-p (selected-window)))
        (not (and (boundp 'edebug-active) edebug-active 
(active-minibuffer-window)))
-       (or (derived-mode-p 'kotl-mode)
-          (not (eq (get major-mode 'mode-class) 'special)))
        (not (apply #'derived-mode-p hywiki-exclude-major-modes))
-       (or hywiki-mode (hywiki-in-page-p))))
+       (or (and (eq hywiki-mode :pages) (hywiki-in-page-p))
+          (derived-mode-p 'kotl-mode)
+          (not (eq (get major-mode 'mode-class) 'special)))))
 
 (defun hywiki-add-activity (wikiword)
   "Make WIKIWORD resume a prompted for activity.
@@ -1546,7 +1524,7 @@ simplifies to:
   (barf-if-buffer-read-only)
   ;; Need to be explicit about the region here so does not use markers
   ;; from a region pointing to another buffer
-  (hywiki-maybe-highlight-page-names (point-min) (point-max))
+  (hywiki-maybe-highlight-references (point-min) (point-max))
   (let ((make-index (hywiki-org-get-publish-property :makeindex))
        org-link
        wikiword-and-section
@@ -1745,8 +1723,15 @@ After successfully finding any kind of referent, run
   ;; included.
   (cl-destructuring-bind (start end)
       (hywiki--extend-region start end)
-    (hywiki-maybe-highlight-page-names start (min end (point-max)))))
+    (hywiki-maybe-highlight-references start (min end (point-max)))))
+
+(defun hywiki-highlight-page ()
+  "Rehighlight all HyWikiWord references when in a HyWiki page."
+  (interactive)
+  (setq hywiki-buffer-highlighted-state nil)
+  (hywiki-maybe-highlight-references))
 
+;;;###autoload
 (defun hywiki-map-words (func)
   "Apply FUNC across highlighted HyWikiWords in the current buffer and return 
nil.
 This temporarily expands the buffer so all HyWikiWord references are processed.
@@ -1852,7 +1837,7 @@ This includes the delimiters: (), {}, <>, [] and \"\" 
(double quotes)."
   "Insert at point a link to a HyWiki page."
   (interactive "*")
   (insert (hywiki-word-read "Link to HyWiki page: "))
-  (hywiki-maybe-highlight-page-name))
+  (hywiki-maybe-highlight-reference))
 
 (defun hywiki-maybe-dehighlight-balanced-pairs ()
   "Before or after a balanced delimiter, dehighlight HyWikiWords within.
@@ -1923,90 +1908,7 @@ Ignore return value; it has no meaning."
               ;; Dehighlight HyWikiWords in any string following point
               (hywiki-maybe-dehighlight-sexp 1)))))))
 
-(defun hywiki-maybe-highlight-balanced-pairs ()
-  "Before or after a balanced delimiter, highlight HyWikiWords within.
-Include: (), {}, <>, [] and \"\" (double quotes).  Exclude Org links
-and radio targets.
-
-Range is limited to the previous, current and next lines, as HyWikiWord
-references are limited to two lines maximum.
-
-Return t if no errors and a pair was found, else nil."
-  (save-excursion
-    (save-restriction
-      (if (hywiki--buttonized-region-p)
-         (narrow-to-region hywiki--buttonize-start hywiki--buttonize-end)
-       ;; Limit balanced pair checks to two lines around point for speed
-       (narrow-to-region (line-beginning-position 0) (line-end-position 2)))
-
-      (let ((result t))
-       (condition-case nil
-           ;; char-before
-           (cond ((memq (char-before) '(?\[ ?\<))
-                  (goto-char (1- (point)))
-                  ;; Highlight any HyWikiWords within single opening
-                  ;; square or angle brackets
-                  ;; Dehighlight HyWikiWords within double opening square
-                  ;; or angle brackets, as these are Org links and targets
-                  (hywiki-maybe-highlight-org-element-forward))
-                 ((memq (char-before) '(?\( ?\{))
-                  ;; Highlight any HyWikiWords within opening parens or braces
-                  (goto-char (1- (point)))
-                  (hywiki-maybe-highlight-sexp 1))
-                 ((and (eq (char-before) ?\")
-                       (hypb:in-string-p))
-                  (goto-char (1- (point)))
-                  (hywiki-maybe-highlight-sexp 1))
-                 ((memq (char-before) '(?\] ?\>))
-                  ;; Dehighlight HyWikiWords within double closing square
-                  ;; or angle brackets, as these are Org links and targets
-                  (hywiki-maybe-highlight-org-element-backward))
-                 ((memq (char-before) '(?\) ?\}))
-                  ;; Highlight any HyWikiWords within closing parens or braces
-                  (hywiki-maybe-highlight-sexp -1))
-                 ((and (eq (char-before) ?\")
-                       (not (hypb:in-string-p)))
-                  ;; Highlight HyWikiWords in any string preceding point
-                  (hywiki-maybe-highlight-sexp -1))
-                 (t (setq result nil)))
-         (error (setq result nil)))
-
-       (when result
-         (condition-case nil
-             ;; char-after
-             (cond ((memq (char-after) '(?\[ ?\<))
-                    ;; Highlight any HyWikiWords within single opening
-                    ;; square or angle brackets
-                    ;; Dehighlight HyWikiWords within double opening square
-                    ;; or angle brackets, as these are Org links and targets
-                    (hywiki-maybe-highlight-org-element-forward))
-                   ((memq (char-after) '(?\( ?\{))
-                    ;; Highlight any HyWikiWords within opening parens or 
braces
-                    (hywiki-maybe-highlight-sexp 1))
-                   ((and (eq (char-after) ?\")
-                         (hypb:in-string-p))
-                    (goto-char (1+ (point)))
-                    (hywiki-maybe-highlight-sexp -1))
-                   ((memq (char-after) '(?\] ?\>))
-                    (goto-char (1+ (point)))
-                    ;; Highlight any HyWikiWords within single closing
-                    ;; square or angle brackets
-                    ;; Dehighlight HyWikiWords within double closing square
-                    ;; or angle brackets, as these are Org links and targets
-                    (hywiki-maybe-highlight-org-element-backward))
-                   ((memq (char-after) '(?\) ?\}))
-                    ;; Highlight any HyWikiWords within closing parens or 
braces
-                    (goto-char (1+ (point)))
-                    (hywiki-maybe-highlight-sexp -1))
-                   ((and (eq (char-after) ?\")
-                         (not (hypb:in-string-p)))
-                    ;; Highlight HyWikiWords in any string following point
-                    (hywiki-maybe-highlight-sexp 1))
-                   (t (setq result nil)))
-           (error (setq result nil))))
-       (when result t)))))
-
-(defun hywiki-maybe-dehighlight-between-page-names ()
+(defun hywiki-maybe-dehighlight-between-references ()
   "Dehighlight any non-Org link HyWiki page#section between point.
 If in a programming mode, must be within a comment or string.  Use
 `hywiki-word-face' to dehighlight."
@@ -2031,38 +1933,49 @@ If in a programming mode, must be within a comment or 
string.  Use
                    (equal (hywiki-referent-exists-p :range)
                           '(nil nil nil))
                    ;; non-existing wikiword
-                   (hywiki-maybe-dehighlight-on-page-name)))
+                   (hywiki-maybe-dehighlight-on-reference)))
             t)))
        ((looking-at "[ \t\n\r\f]")
-        (hywiki-maybe-dehighlight-off-page-name)
-        (hywiki-maybe-dehighlight-on-page-name))))
+        (hywiki-maybe-dehighlight-off-reference)
+        (hywiki-maybe-dehighlight-on-reference))))
 
-(defun hywiki-maybe-dehighlight-off-page-name ()
+(defun hywiki-maybe-dehighlight-off-reference ()
   "Dehighlight any non-Org link HyWiki page#section at or one char before 
point.
 If on a whitespace character or at end of buffer, handle
 dehighlighting for any previous word or punctuation.  If
 in a programming mode, must be within a comment."
   ;; Dehighlight any page name at point
-  (hywiki-maybe-dehighlight-page-name
+  (hywiki-maybe-dehighlight-reference
    ;; Flag on-page-name if on a whitespace character
    (or (= (point) (point-max))
        (= (if (char-after) (char-syntax (char-after)) 0) ? ))))
 
-(defun hywiki-maybe-dehighlight-on-page-name ()
+(defun hywiki-maybe-dehighlight-on-reference ()
   "Dehighlight any non-Org link HyWiki page#section at or one char before 
point.
 If not on a whitespace character, handle dehighlighting for any
 page/section name or punctuation.  If in a programming mode, must
 be within a comment."
   ;; Dehighlight any page name at point
-  (hywiki-maybe-dehighlight-page-name
+  (hywiki-maybe-dehighlight-reference
    ;; Flag on-page-name if not on a whitespace character
    (and (/= (point) (point-max))
        (/= (if (char-after) (char-syntax (char-after)) 0) ? ))))
 
+(defun hywiki-maybe-dehighlight-org-element-backward ()
+  "Dehighlight HyWikiWords within a closing double/single square/angle 
bracket."
+  (hywiki--maybe-de/highlight-org-element-backward 
#'hywiki-maybe-dehighlight-sexp))
+
+(defun hywiki-maybe-dehighlight-org-element-forward ()
+  "Dehighlight HyWikiWords within an opening double/single square/angle 
bracket."
+  (hywiki--maybe-de/highlight-org-element-forward 
#'hywiki-maybe-dehighlight-sexp))
+
 ;;;###autoload
-(defun hywiki-maybe-dehighlight-page-name (&optional on-page-name)
+(defun hywiki-maybe-dehighlight-reference (&optional on-reference)
   "Dehighlight any non-Org link HyWiki page#section at or one char before 
point.
-With optional ON-PAGE-NAME non-nil, assume point is within the page or
+A call to `hywiki-active-in-current-buffer-p' at point must return non-nil or
+this function does nothing.
+
+With optional ON-REFERENCE non-nil, assume point is within the page or
 section name.  Otherwise, if `pre-command-hook' has set
 `hywiki--buttonize-start' `hywiki--buttonize-end' global variables,
 use these as the region in which to dehighlight.
@@ -2078,7 +1991,7 @@ If in a programming mode, must be within a comment.  Use
                 ;; Non-nil if match is inside a comment or a string
                 (or (nth 4 (syntax-ppss)) (hypb:in-string-p))
               t)
-            (or on-page-name
+            (or on-reference
                 (and (characterp last-command-event)
                      (string-match (regexp-quote
                                     (char-to-string (char-syntax 
last-command-event)))
@@ -2093,14 +2006,14 @@ If in a programming mode, must be within a comment.  Use
            (narrow-to-region hywiki--buttonize-start hywiki--buttonize-end)
            (goto-char hywiki--buttonize-start))
 
-         (unless on-page-name
+         (unless on-reference
            ;; after page name
            (skip-syntax-backward ">-"))
 
          (hywiki-maybe-dehighlight-balanced-pairs)
 
          (unless hywiki--highlighting-done-flag
-           (unless on-page-name
+           (unless on-reference
              ;; May be a non-delimiter but HyWikiWord ending punctuation to
              ;; skip past
              (skip-chars-backward (hywiki-get-buttonize-characters)))
@@ -2129,9 +2042,192 @@ If in a programming mode, must be within a comment.  Use
                                              'face hywiki-word-face))))))))
 
 ;;;###autoload
-(defun hywiki-maybe-highlight-page-name (&optional on-page-name)
+(defun hywiki-maybe-dehighlight-references (&optional region-start region-end)
+  "Dehighlight any highlighted HyWiki page names in a HyWiki buffer/region.
+With optional REGION-START and REGION-END positions (active region
+interactively), limit dehighlighting to the region.
+
+Does nothing if either `hywiki-buffer-highlighted-state' is set to \='d
+or a call to `hywiki-active-in-current-buffer-p' at point returns non-nil."
+  (interactive (when (use-region-p) (list (region-beginning) (region-end))))
+  (unless (or (eq hywiki-buffer-highlighted-state 'd)
+             (hywiki-active-in-current-buffer-p))
+    (hproperty:but-clear-all-in-list
+     (hproperty:but-get-all-in-region
+      (if (markerp region-start)
+         (if (marker-position region-start)
+             region-start
+           (point-min))
+       (or region-start (point-min)))
+      (if (markerp region-end)
+         (if (marker-position region-end)
+             region-end
+           (point-max))
+       (or region-end (point-max)))
+      'face hywiki-word-face))
+    (unless (or region-start region-end)
+      (setq hywiki-buffer-highlighted-state 'd))))
+
+(defun hywiki-maybe-dehighlight-sexp (direction-number)
+  "Dehighlight any HyWikiWord within single square/angle bracket.
+DIRECTION-NUMBER is 1 for forward scanning and -1 for backward scanning."
+  ;; Enable dehighlighting in HyWiki pages
+  (let ((hywiki-mode))
+    (hywiki--maybe-de/highlight-sexp
+     #'hywiki-maybe-dehighlight-references direction-number)))
+
+;;;###autoload
+(defun hywiki-maybe-highlight-balanced-pairs ()
+  "Before or after a balanced delimiter, highlight HyWikiWords within.
+Include: (), {}, <>, [] and \"\" (double quotes).  Exclude Org links
+and radio targets.
+
+Range is limited to the previous, current and next lines, as HyWikiWord
+references are limited to two lines maximum.
+
+Return t if no errors and a pair was found, else nil."
+  (save-excursion
+    (save-restriction
+      (if (hywiki--buttonized-region-p)
+         (narrow-to-region hywiki--buttonize-start hywiki--buttonize-end)
+       ;; Limit balanced pair checks to two lines around point for speed
+       (narrow-to-region (line-beginning-position 0) (line-end-position 2)))
+
+      (let ((result t))
+       (condition-case nil
+           ;; char-before
+           (cond ((memq (char-before) '(?\[ ?\<))
+                  (goto-char (1- (point)))
+                  ;; Highlight any HyWikiWords within single opening
+                  ;; square or angle brackets
+                  ;; Dehighlight HyWikiWords within double opening square
+                  ;; or angle brackets, as these are Org links and targets
+                  (hywiki-maybe-highlight-org-element-forward))
+                 ((memq (char-before) '(?\( ?\{))
+                  ;; Highlight any HyWikiWords within opening parens or braces
+                  (goto-char (1- (point)))
+                  (hywiki-maybe-highlight-sexp 1))
+                 ((and (eq (char-before) ?\")
+                       (hypb:in-string-p))
+                  (goto-char (1- (point)))
+                  (hywiki-maybe-highlight-sexp 1))
+                 ((memq (char-before) '(?\] ?\>))
+                  ;; Dehighlight HyWikiWords within double closing square
+                  ;; or angle brackets, as these are Org links and targets
+                  (hywiki-maybe-highlight-org-element-backward))
+                 ((memq (char-before) '(?\) ?\}))
+                  ;; Highlight any HyWikiWords within closing parens or braces
+                  (hywiki-maybe-highlight-sexp -1))
+                 ((and (eq (char-before) ?\")
+                       (not (hypb:in-string-p)))
+                  ;; Highlight HyWikiWords in any string preceding point
+                  (hywiki-maybe-highlight-sexp -1))
+                 (t (setq result nil)))
+         (error (setq result nil)))
+
+       (when result
+         (condition-case nil
+             ;; char-after
+             (cond ((memq (char-after) '(?\[ ?\<))
+                    ;; Highlight any HyWikiWords within single opening
+                    ;; square or angle brackets
+                    ;; Dehighlight HyWikiWords within double opening square
+                    ;; or angle brackets, as these are Org links and targets
+                    (hywiki-maybe-highlight-org-element-forward))
+                   ((memq (char-after) '(?\( ?\{))
+                    ;; Highlight any HyWikiWords within opening parens or 
braces
+                    (hywiki-maybe-highlight-sexp 1))
+                   ((and (eq (char-after) ?\")
+                         (hypb:in-string-p))
+                    (goto-char (1+ (point)))
+                    (hywiki-maybe-highlight-sexp -1))
+                   ((memq (char-after) '(?\] ?\>))
+                    (goto-char (1+ (point)))
+                    ;; Highlight any HyWikiWords within single closing
+                    ;; square or angle brackets
+                    ;; Dehighlight HyWikiWords within double closing square
+                    ;; or angle brackets, as these are Org links and targets
+                    (hywiki-maybe-highlight-org-element-backward))
+                   ((memq (char-after) '(?\) ?\}))
+                    ;; Highlight any HyWikiWords within closing parens or 
braces
+                    (goto-char (1+ (point)))
+                    (hywiki-maybe-highlight-sexp -1))
+                   ((and (eq (char-after) ?\")
+                         (not (hypb:in-string-p)))
+                    ;; Highlight HyWikiWords in any string following point
+                    (hywiki-maybe-highlight-sexp 1))
+                   (t (setq result nil)))
+           (error (setq result nil))))
+       (when result t)))))
+
+(defun hywiki-maybe-highlight-between-references ()
+  "Highlight any non-Org link HyWiki page#section names between point.
+
+If in a programming mode, must be within a comment.  Use
+`hywiki-word-face' to highlight.  Do not highlight references to
+the current page unless they have sections attached."
+  (cond ((hproperty:char-property-range (point) 'face hywiki-word-face))
+       ((cl-destructuring-bind (word start end)
+            (hywiki-highlight-word-get-range)
+          (when (and start end)
+            (save-excursion
+              (goto-char start)
+              (when (hywiki-referent-exists-p word)
+                ;; existing wikiword
+                (hywiki-maybe-highlight-on-reference)))
+            t)))
+       ((cl-destructuring-bind (start end)
+            (hywiki-at-range-delimiter)
+          (when (and start end)
+            (save-excursion
+              (goto-char (1+ start))
+              (skip-syntax-forward "-" (line-end-position))
+              (unless (equal (hywiki-referent-exists-p :range)
+                             '(nil nil nil))
+                ;; existing wikiword
+                (hywiki-maybe-highlight-on-reference)))
+            t)))
+       ((looking-at "[ \t\n\r\f]")
+        (hywiki-maybe-highlight-off-reference)
+        (hywiki-maybe-highlight-on-reference))
+       (t (hywiki-maybe-highlight-on-reference))))
+
+(defun hywiki-maybe-highlight-off-reference ()
+  "Highlight any non-Org link HyWiki page#section at or one char before point.
+If at bobp or any preceding char is non-whitespace and any following
+character is whitespace or at eobp, handle highlighting for any previous
+word or punctuation.
+
+If in a programming mode, must be within a comment.  Use
+`hywiki-word-face' to highlight.  Do not highlight references to
+the current page unless they have sections attached."
+  (hywiki-maybe-highlight-reference
+   ;; flag on-reference if on a whitespace character
+   (and (or (= (point) (point-max))
+           (= (if (char-after) (char-syntax (char-after)) 0) ?\ ))
+       (or (= (point) (point-min))
+           (/= (if (char-before) (char-syntax (char-before)) 0) ?\ )))))
+
+(defun hywiki-maybe-highlight-on-reference ()
+  "Highlight any non-Org link HyWiki page#section at or one char before point.
+If not on a whitespace character, handle highlighting for any page/section
+name or punctuation.
+
+If in a programming mode, must be within a comment.  Use
+`hywiki-word-face' to highlight.  Do not highlight references to
+the current page unless they have sections attached."
+  (hywiki-maybe-highlight-reference
+   ;; flag on-reference if not on a whitespace character
+   (and (/= (point) (point-max))
+       (/= (if (char-after) (char-syntax (char-after)) 0) ? ))))
+
+;;;###autoload
+(defun hywiki-maybe-highlight-reference (&optional on-reference)
   "Highlight any non-Org link HyWikiWord#section at or one char before point.
-With optional ON-PAGE-NAME non-nil, assume point is within the page or
+A call to `hywiki-active-in-current-buffer-p' at point must return non-nil or
+this function does nothing.
+
+With optional ON-REFERENCE non-nil, assume point is within the page or
 section name.  Otherwise, if a HyWiki per-character hook has set
 `hywiki--buttonize-start' `hywiki--buttonize-end' global variables,
 use these as the region to highlight.
@@ -2146,7 +2242,7 @@ the current page unless they have sections attached."
                 ;; Non-nil if match is inside a comment or string
                 (or (nth 4 (syntax-ppss)) (hypb:in-string-p))
               t)
-            ;;  (or on-page-name
+            ;;  (or on-reference
             ;;  (string-match (regexp-quote (char-to-string (char-syntax 
last-command-event)))
             ;;                " _()<>$.\"'"))
              (not executing-kbd-macro)
@@ -2157,14 +2253,14 @@ the current page unless they have sections attached."
          (when (hywiki--buttonized-region-p)
            (goto-char hywiki--buttonize-start))
 
-         (unless on-page-name
+         (unless on-reference
            ;; after page name
            (skip-syntax-backward ">-"))
 
          (unless (or hywiki--highlighting-done-flag
                      (hywiki-maybe-highlight-balanced-pairs))
 
-           (unless on-page-name
+           (unless on-reference
              ;; May be a non-delimiter but HyWikiWord ending punctuation to
              ;; skip past
              (skip-chars-backward (hywiki-get-buttonize-characters)
@@ -2200,7 +2296,7 @@ the current page unless they have sections attached."
                                            'face hywiki-word-face))
                        (if (> (length hywiki--buts) 1)
                            (progn (hproperty:but-clear-all-in-list 
hywiki--buts)
-                                  (hywiki-maybe-highlight-page-names
+                                  (hywiki-maybe-highlight-references
                                    hywiki--start hywiki--end))
                          ;; There is only one existing button
                          (setq hywiki--buts (car hywiki--buts)
@@ -2209,9 +2305,9 @@ the current page unless they have sections attached."
                          (unless (and (= hywiki--start hywiki--but-start)
                                       (= hywiki--end hywiki--but-end))
                            (hproperty:but-delete hywiki--buts)
-                           (hywiki-maybe-highlight-page-names
+                           (hywiki-maybe-highlight-references
                             hywiki--start hywiki--end)))
-                     (hywiki-maybe-highlight-page-names
+                     (hywiki-maybe-highlight-references
                       hywiki--start hywiki--end))))
              ;; Remove any potential earlier highlighting since the
              ;; previous word may have changed.
@@ -2226,134 +2322,19 @@ the current page unless they have sections attached."
                        hywiki--but-end   (hproperty:but-end hywiki--buts))
                  (hproperty:but-delete hywiki--buts)))))))))
 
-(defun hywiki-maybe-highlight-between-page-names ()
-  "Highlight any non-Org link HyWiki page#section names between point.
-
-If in a programming mode, must be within a comment.  Use
-`hywiki-word-face' to highlight.  Do not highlight references to
-the current page unless they have sections attached."
-  (cond ((hproperty:char-property-range (point) 'face hywiki-word-face))
-       ((cl-destructuring-bind (word start end)
-            (hywiki-highlight-word-get-range)
-          (when (and start end)
-            (save-excursion
-              (goto-char start)
-              (when (hywiki-referent-exists-p word)
-                ;; existing wikiword
-                (hywiki-maybe-highlight-on-page-name)))
-            t)))
-       ((cl-destructuring-bind (start end)
-            (hywiki-at-range-delimiter)
-          (when (and start end)
-            (save-excursion
-              (goto-char (1+ start))
-              (skip-syntax-forward "-" (line-end-position))
-              (unless (equal (hywiki-referent-exists-p :range)
-                             '(nil nil nil))
-                ;; existing wikiword
-                (hywiki-maybe-highlight-on-page-name)))
-            t)))
-       ((looking-at "[ \t\n\r\f]")
-        (hywiki-maybe-highlight-off-page-name)
-        (hywiki-maybe-highlight-on-page-name))
-       (t (hywiki-maybe-highlight-on-page-name))))
-
-(defun hywiki-maybe-highlight-off-page-name ()
-  "Highlight any non-Org link HyWiki page#section at or one char before point.
-If at bobp or any preceding char is non-whitespace and any following
-character is whitespace or at eobp, handle highlighting for any previous
-word or punctuation.
-
-If in a programming mode, must be within a comment.  Use
-`hywiki-word-face' to highlight.  Do not highlight references to
-the current page unless they have sections attached."
-  (hywiki-maybe-highlight-page-name
-   ;; flag on-page-name if on a whitespace character
-   (and (or (= (point) (point-max))
-           (= (if (char-after) (char-syntax (char-after)) 0) ?\ ))
-       (or (= (point) (point-min))
-           (/= (if (char-before) (char-syntax (char-before)) 0) ?\ )))))
-
-(defun hywiki-maybe-highlight-on-page-name ()
-  "Highlight any non-Org link HyWiki page#section at or one char before point.
-If not on a whitespace character, handle highlighting for any page/section
-name or punctuation.
-
-If in a programming mode, must be within a comment.  Use
-`hywiki-word-face' to highlight.  Do not highlight references to
-the current page unless they have sections attached."
-  (hywiki-maybe-highlight-page-name
-   ;; flag on-page-name if not on a whitespace character
-   (and (/= (point) (point-max))
-       (/= (if (char-after) (char-syntax (char-after)) 0) ? ))))
-
-(defun hywiki-maybe-dehighlight-org-element-backward ()
-  "Dehighlight HyWikiWords within a closing double/single square/angle 
bracket."
-  (hywiki--maybe-de/highlight-org-element-backward 
#'hywiki-maybe-dehighlight-sexp))
-
 (defun hywiki-maybe-highlight-org-element-backward ()
   "Highlight HyWikiWords with point at a single closing square/angle bracket.
 Dehighlight HyWikiWords when on a double closing square/angle bracket,
 since Org mode highlights those."
   (hywiki--maybe-de/highlight-org-element-backward 
#'hywiki-maybe-highlight-sexp))
 
-(defun hywiki-maybe-dehighlight-org-element-forward ()
-  "Dehighlight HyWikiWords within an opening double/single square/angle 
bracket."
-  (hywiki--maybe-de/highlight-org-element-forward 
#'hywiki-maybe-dehighlight-sexp))
-
 (defun hywiki-maybe-highlight-org-element-forward ()
   "Highlight HyWikiWords with point at a single opening square/angle bracket.
 Dehighlight HyWikiWords when on a double opening square/angle bracket,
 since Org mode highlights those."
   (hywiki--maybe-de/highlight-org-element-forward 
#'hywiki-maybe-highlight-sexp))
 
-(defun hywiki-maybe-dehighlight-sexp (direction-number)
-  "Dehighlight any HyWikiWord within single square/angle bracket.
-DIRECTION-NUMBER is 1 for forward scanning and -1 for backward scanning."
-  ;; Enable dehighlighting in HyWiki pages
-  (let ((hywiki-word-highlight-flag))
-    (hywiki--maybe-de/highlight-sexp
-     #'hywiki-maybe-dehighlight-page-names direction-number)))
-
-(defun hywiki-maybe-highlight-sexp (direction-number)
-  "Highlight any HyWikiWord within single square/angle bracket.
-DIRECTION-NUMBER is 1 for forward scanning and -1 for backward scanning."
-  (hywiki--maybe-de/highlight-sexp
-   #'hywiki-maybe-highlight-page-names direction-number))
-
-;;;###autoload
-(defun hywiki-maybe-dehighlight-page-names (&optional region-start region-end)
-  "Dehighlight any highlighted HyWiki page names in a HyWiki buffer/region.
-With optional REGION-START and REGION-END positions (active region
-interactively), limit dehighlighting to the region."
-  (interactive (when (use-region-p) (list (region-beginning) (region-end))))
-  (unless (or (eq hywiki-buffer-highlighted-state 'd)
-             (hywiki-active-in-current-buffer-p))
-    (hproperty:but-clear-all-in-list
-     (hproperty:but-get-all-in-region
-      (if (markerp region-start)
-         (if (marker-position region-start)
-             region-start
-           (point-min))
-       (or region-start (point-min)))
-      (if (markerp region-end)
-         (if (marker-position region-end)
-             region-end
-           (point-max))
-       (or region-end (point-max)))
-      'face hywiki-word-face))
-    (unless (or region-start region-end)
-      (setq hywiki-buffer-highlighted-state 'd))))
-
-;;###autoload
-(defun hywiki-highlight-page ()
-  "Rehighlight all HyWikiWord references when in a HyWiki page."
-  (interactive)
-  (setq hywiki-buffer-highlighted-state nil)
-  (hywiki-maybe-highlight-page-names))
-
-;;###autoload
-(defun hywiki-maybe-highlight-page-names (&optional region-start region-end 
skip-lookups-update-flag)
+(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.
 With optional REGION-START and REGION-END positions or markers (active
 region interactively), limit highlight adjustment to the region.  With
@@ -2364,8 +2345,8 @@ 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 the
-value of `hywiki-word-highlight-flag' is changed."
+disabled.  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
@@ -2398,8 +2379,8 @@ value of `hywiki-word-highlight-flag' is changed."
                ;; whole buffer is being processed; this prevents an
                ;; error when called from `hywiki-maybe-highlight-sexp'.
                (unless (and region-start region-end)
-                 (let ((hywiki-word-highlight-flag))
-                   (hywiki-maybe-dehighlight-page-names)))
+                 (let ((hywiki-mode))
+                   (hywiki-maybe-dehighlight-references)))
                (dolist (hywiki-words-regexp hywiki--any-wikiword-regexp-list)
                  (goto-char (point-min))
                  (let ((highlight-in-comments-and-strings-only
@@ -2434,7 +2415,7 @@ value of `hywiki-word-highlight-flag' is changed."
                                       ;; include a #section.
                                       (unless (string-equal 
hywiki--current-page
                                                             
(buffer-substring-no-properties hywiki--start hywiki--end))
-                                        (hywiki-maybe-highlight-word 
hywiki--start hywiki--end))))))))))
+                                        
(hywiki-maybe-highlight-region-reference hywiki--start hywiki--end))))))))))
 
                ;; Disable dehighlighting of HyWikiWords between [] and <>.
                ;;
@@ -2473,14 +2454,20 @@ value of `hywiki-word-highlight-flag' is changed."
                hywiki-org-link-type-required 
hywiki--save-org-link-type-required)))
 
     ;; Otherwise, 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-word-highlight-flag' is nil.
-    (hywiki-maybe-dehighlight-page-names region-start region-end))
+    ;; 'hywiki-mode' is disabled or set to ':pages' and this is not a
+    ;; HyWiki page buffer. If this is a HyWiki page buffer, then
+    ;; dehighlight when `hywiki-mode' is disabled.
+    (hywiki-maybe-dehighlight-references region-start region-end))
   (unless (hyperb:stack-frame '(hywiki-maybe-highlight-wikiwords-in-frame))
     (hywiki-maybe-directory-updated))
   nil)
 
+(defun hywiki-maybe-highlight-sexp (direction-number)
+  "Highlight any HyWikiWord within single square/angle bracket.
+DIRECTION-NUMBER is 1 for forward scanning and -1 for backward scanning."
+  (hywiki--maybe-de/highlight-sexp
+   #'hywiki-maybe-highlight-references direction-number))
+
 (defun hywiki-maybe-highlight-wikiwords-in-frame (frame &optional 
skip-lookups-update-flag)
   "Highlight all non-Org link HyWiki page names displayed in FRAME.
 If FRAME is t, then highlight in all windows across all frames, even
@@ -2495,15 +2482,12 @@ the current page unless they have sections attached."
        ;; Display buffer before `normal-mode' triggers possibly
        ;; long-running font-locking
        (sit-for 0)
-       (hywiki-maybe-highlight-page-names nil nil skip-lookups-update-flag)))
+       (hywiki-maybe-highlight-references nil nil skip-lookups-update-flag)))
    nil frame)
   (hywiki-maybe-directory-updated))
 
 (defun hywiki-in-page-p ()
-  "Return non-nil if the current buffer is a HyWiki page.
-If this is a HyWiki page and `hywiki-word-highlight-flag' is non-nil
-\(the default), also enable auto-highlighting of HyWikiWords as they
-are typed in the buffer."
+  "Return non-nil if the current buffer is a HyWiki page."
   (or hywiki-page-flag
       (and buffer-file-name
           (string-prefix-p (expand-file-name hywiki-directory)
@@ -2515,6 +2499,29 @@ are typed in the buffer."
   (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."
+  (apply #'set:create
+        (apply #'nconc (mapcar (lambda (frame) (mapcar #'window-buffer
+                                                       (window-list frame)))
+                               (frame-list)))))
+
+(defun hywiki-get-buffers (hywiki-buffer-mode)
+  "Return the list of window buffers active for HYWIKI-BUFFER-MODE.
+See the function documentation for `hywiki-mode' for valid input
+values (the states of `hywiki-mode')."
+  (when hywiki-mode
+    (delq nil (mapcar (lambda (buf)
+                       (with-current-buffer buf
+                         (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))
+                                  (derived-mode-p 'kotl-mode)
+                                  (not (eq (get major-mode 'mode-class) 
'special)))
+                              buf)))
+                     (hywiki-get-buffers-in-windows)))))
+
 (defun hywiki-get-page-file (file-stem-name)
   "Return possibly non-existent path in `hywiki-directory' from FILE-STEM-NAME.
 FILE-STEM-NAME should not contain a directory and may have or may omit
@@ -3352,8 +3359,8 @@ non-nil or this will return nil."
     (when range-flag
       '(nil nil nil))))
 
-(defun hywiki-maybe-highlight-word (start end)
-  "Conditionally highlight HyWiki referent between START and END.
+(defun hywiki-maybe-highlight-region-reference (start end)
+  "Conditionally highlight HyWiki reference between START and END.
 Do not highlight if any face from `hywiki-ignore-face-list' appears
 within the given region, e.g. ignore HyWikiWords used in Org links or
 Hyperbole button names."
@@ -3375,7 +3382,7 @@ This does not test whether a referent exists for the 
HyWikiWord; call
 `hywiki-referent-exists-p' without an argument for that.
 
 A call to `hywiki-active-in-current-buffer-p' at point must return
-non-nil or this will return nil."
+non-nil or this will return \\='(nil nil nil)."
   (cl-destructuring-bind (wikiword start end)
       (hywiki-word-at :range)
     ;; Ensure wikiword in buffer is highlighted before
@@ -3383,7 +3390,7 @@ non-nil or this will return nil."
     (when (and wikiword start end
               (not (hproperty:but-get start 'face hywiki-word-face))
               (hywiki-referent-exists-p wikiword))
-      (hywiki-maybe-highlight-word start end))
+      (hywiki-maybe-highlight-region-reference start end))
     (list wikiword start end)))
 
 (defun hywiki-highlight-word-move-range ()
@@ -3509,52 +3516,89 @@ If point is on one, press RET immediately to use that 
one."
                     (hywiki-get-page-list)
                     nil nil nil nil (hywiki-word-at-point))))
 
-(defun hywiki-word-highlight-flag-changed (symbol set-to-value operation 
_where)
-  "Watch function for variable ``hywiki-word-highlight-flag'.
-Function is called with 4 arguments: (SYMBOL SET-TO-VALUE OPERATION WHERE).
-Highlight/dehighlight HyWiki page names across all frames on change."
-  (unless (memq operation '(let unlet)) ;; not setting global value
-    (set symbol set-to-value)
-    (hywiki-word-set-auto-highlighting set-to-value)))
+(defun hywiki-word-set-auto-highlighting (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-set-auto-highlighting (arg)
-  "With a prefix ARG, turn on HyWikiWord auto-highlighting.
-Otherwise, turn it off.
+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-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.
 
 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."
-  (interactive "P")
-  (if arg
-      ;; enable
-      (progn
-       (when hywiki-word-highlight-flag
-         (add-hook 'pre-command-hook      'hywiki-word-store-around-point 95)
-          (add-hook 'post-command-hook     'hywiki-word-highlight-post-command 
95)
-         (add-hook 'post-self-insert-hook 
'hywiki-word-highlight-post-self-insert)
-         (add-hook 'window-buffer-change-functions
-                   'hywiki-maybe-highlight-wikiwords-in-frame)
-         (add-to-list 'yank-handled-properties
-                      '(hywiki-word-face . hywiki-highlight-on-yank))
-         (hywiki-maybe-highlight-wikiwords-in-frame t))
-       (when (called-interactively-p 'interactive)
-         (if hywiki-word-highlight-flag
-             (message "HyWikiWord page auto-highlighting enabled")
-           (message "`hywiki-word-highlight-flag' must first be set to t to 
enable auto-highlighting"))))
-    ;; disable
-    (remove-hook 'pre-command-hook      'hywiki-word-store-around-point)
-    (remove-hook 'post-command-hook     'hywiki-word-highlight-post-command)
-    (remove-hook 'post-self-insert-hook 
'hywiki-word-highlight-post-self-insert)
-    (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))
-    (when (called-interactively-p 'interactive)
-      (message "HyWikiWord page auto-highlighting disabled"))))
+  (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)
+  "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-to-list 'yank-handled-properties
+              '(hywiki-word-face . hywiki-highlight-on-yank))
+  (hywiki-maybe-highlight-wikiwords-in-frame t)
+  (when (called-interactively-p 'interactive)
+    (message "HyWikiWord auto-highlighting enabled")))
+
+(defun hywiki-word-dehighlight-buffers (buffers)
+  "Disable auto-highlighting of HyWikiWords in BUFFERS."
+  (interactive)
+  (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))
+  (when (called-interactively-p 'interactive)
+    (message "HyWikiWord auto-highlighting disabled")))
 
 ;;; ************************************************************************
 ;;; Private functions
@@ -3798,7 +3842,7 @@ the HyWikiWord reference."
                                      (setq hywiki--range nil)))
                                  ))))))
     ;; Dehighlight if point is on or between a HyWikiWord
-    (hywiki-maybe-dehighlight-between-page-names)))
+    (hywiki-maybe-dehighlight-between-references)))
 
 (defun hywiki--maybe-rehighlight-at-point ()
   "Dehighlight any existing HyWikiWord when needed.
@@ -3810,16 +3854,16 @@ This must be called within a `save-excursion' or it may 
move point."
   (hywiki--maybe-dehighlight-at-point)
 
   ;; Highlight wikiwords around point as needed
-  (hywiki-maybe-highlight-on-page-name)
+  (hywiki-maybe-highlight-on-reference)
 
   (when (hywiki--buttonized-region-p)
     (hywiki--maybe-de/highlight-sexp
-     #'hywiki-maybe-highlight-page-names 1
+     #'hywiki-maybe-highlight-references 1
      hywiki--buttonize-start hywiki--buttonize-end))
 
   (when (= (char-syntax (or (char-before) 0)) ?\ )
     (goto-char (1- (point))))
-  (hywiki-maybe-highlight-between-page-names))
+  (hywiki-maybe-highlight-between-references))
 
 ;;; ************************************************************************
 ;;; Private initializations
@@ -3848,13 +3892,6 @@ This must be called within a `save-excursion' or it may 
move point."
 ;; Use for its side effects, setting variables
 (eval-after-load "ox-publish" '(hywiki-org-get-publish-project))
 
-(add-variable-watcher 'hywiki-word-highlight-flag
-                     'hywiki-word-highlight-flag-changed)
-
-;; Set HyWiki page auto-HyWikiWord highlighting and `yank-handled-properties'
-(hywiki-word-highlight-flag-changed 'hywiki-word-highlight-flag
-                                   hywiki-word-highlight-flag 'set nil)
-
 ;; Ensure HyWiki referent lookup table is initialized as are HyWiki Org
 ;; Publish settings.
 (hywiki-set-directory 'hywiki-directory hywiki-directory)
diff --git a/hywiki/HyWiki.org b/hywiki/HyWiki.org
index 009fb89ac5..009930b4fe 100644
--- a/hywiki/HyWiki.org
+++ b/hywiki/HyWiki.org
@@ -50,13 +50,11 @@ Hyperbole's Action Key does the right thing in this context.
 
 * HyWiki Settings
 
-The custom setting, 'hywiki-word-highlight-flag' (default = 't'),
-means HyWikiWords will be auto-highlighted within HyWiki pages.
-Outside of such pages, 'hywiki-mode' must also be enabled for such
-auto-highlighting.
-
-The custom setting, 'hywiki-exclude-major-modes' (default = 'nil'), is
-a list of major modes to exclude from HyWikiWord auto-highlighting and
+By default, HyWikiWords are auto-highlighted within HyWiki pages.
+Outside of such pages, 'hywiki-mode' must be set to `:all' to enable
+auto-highlighting in programming and text buffers.  The custom
+setting, 'hywiki-exclude-major-modes' (default = 'nil'), is a list of
+major modes to exclude from HyWikiWord auto-highlighting and
 recognition.
 
 Within programming modes, HyWikiWords are highlighted and hyperlinked
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index f76d523254..c30a2738ae 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7,7 +7,7 @@
 @c Author:       Bob Weiner
 @c
 @c Orig-Date:     6-Nov-91 at 11:18:03
-@c Last-Mod:      7-Dec-25 at 20:30:10 by Bob Weiner
+@c Last-Mod:     27-Dec-25 at 22:18:46 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -4622,6 +4622,24 @@ Disable highlighting HyWikiWord references everywhere.  
The
 @{M-x hywiki-mode @key{RET}@} will also toggle between disabling
 HyWikiWords everywhere and enabling them in all editable buffers.
 
+---------
+  "The default, non-nil value treats HyWikiWords in HyWiki pages as hyperlinks.
+A nil value disables HyWikiWord hyperlink buttons in both HyWiki
+pages and all other buffers (since it also disables `hywiki-mode').
+
+Outside of HyWiki pages, the global minor mode `hywiki-mode' must be
+manually enabled for auto-HyWikiWord highlighting. Interactively, {C-h
+h h m a} does this; programmatically, use `(hywiki-mode :all)' to
+enable it.
+
+Use `hywiki-active-in-current-buffer-p' to determine if HyWikiWord
+hyperlinks are currently active in a buffer or not.
+
+Regardless of this flag, HyWikiWords in Org links and targets are not
+highlighted nor treated as hyperlinks; they are handled normally by Org."
+--------
+
+
 @cindex HyWikiWord highlighting
 As HyWikiWords are typed, highlighting occurs after a trailing
 whitespace or punctuation character is added, or when the HyWikiWord
@@ -4630,12 +4648,6 @@ single square brackets.  Since Org links use double 
square brackets
 and Org targets use double or triple angle brackets, HyWikiWords
 within these delimiters are ignored once the brackets are in place.
 
-@vindex hywiki-word-highlight-flag
-The custom setting, @code{hywiki-word-highlight-flag} (default =
-@samp{t}), means HyWikiWords will be auto-highlighted within HyWiki
-pages.  Outside of such pages, @code{hywiki-mode} must also be enabled
-for such auto-highlighting.
-
 @vindex hywiki-exclude-major-modes
 @cindex HyWiki exclude modes
 The custom setting, @code{hywiki-exclude-major-modes} (default =
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 4fdfdb1589..7069393646 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:     22-Nov-25 at 13:35:42 by Bob Weiner
+;; Last-Mod:      2-Jan-26 at 20:13:25 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -615,11 +615,11 @@ 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-word-highlight-flag t))
+         (hywiki-mode t))
     (unwind-protect
         (with-current-buffer (find-file-noselect wiki-page)
           (should (hywiki-active-in-current-buffer-p))
-          (let ((hywiki-word-highlight-flag nil))
+          (let ((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)))
@@ -2052,7 +2052,7 @@ face is verified during the change."
         (hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
 
 (ert-deftest hywiki-tests--maybe-highlight-page-names ()
-  "Verify `hywiki-maybe-highlight-page-names'.
+  "Verify `hywiki-maybe-highlight-references'.
 Start and stop point of all highlighted regions in the buffer, as
 computed by `hywiki-tests--hywiki-face-regions', are compared to the
 expected result."
@@ -2077,7 +2077,7 @@ expected result."
                     (overlay-regions (cdr v)))
                (with-temp-buffer
                   (insert input)
-                 (hywiki-maybe-highlight-page-names (point-min) (point-max))
+                 (hywiki-maybe-highlight-references (point-min) (point-max))
                  ;; Verify Overlays
                   (ert-info ((format "Text '%s' => Expected overlays '%s'" 
input overlay-regions))
                     (should (equal (hywiki-tests--hywiki-face-regions) 
overlay-regions)))))))

Reply via email to