branch: externals/hyperbole
commit 89a1f11e44633de5f1de2a7c56a6ff047429ffc9
Merge: b860a75af4 79d47960d1
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #825 from rswgnu/rsw
hywiki-mode - Update to 3 states and use symbol values for each
---
ChangeLog | 11 +++++++
hui-menu.el | 15 +++++++--
hui-mini.el | 45 ++++++++++++++++++++-------
hywiki.el | 91 +++++++++++++++++++++++++++++++-----------------------
man/hyperbole.texi | 69 ++++++++++++++++++++++++-----------------
5 files changed, 149 insertions(+), 82 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b3d345555..d75da4ef5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2025-11-30 Bob Weiner <[email protected]>
+* hui-menu.el (hui-menu-options): Fix display of 'Org-M-RET' submenu options
+ by adding an extra 'list' call.
+
+* hywiki.el (hywiki-mode): Redo 'hywiki-mode' global minor mode to support
WikiWords
+ in all editable buffers or just in HyWiki pages. Update doc string
accordingly.
+ man/hyperbole.texi (HyWikiWords): Update 'hywiki-mode' doc.
+ hui-menu.el (hui-menu-hywiki):
+ hui-mini.el (hui:menu-hywiki): Add submenu to set 1 of 3 'hywiki-mode'
states.
+ (hui:menu-read-from-minibuffer): Highlight selected item from
above
+ state menu.
+
* hyrolo.py: Add support for "~/.rolo.org" HyRolo file. Report an error
but continue if any given file in the list does not exist. Make Python
script
executable.
diff --git a/hui-menu.el b/hui-menu.el
index 630ffaa051..d496fa9fe0 100644
--- a/hui-menu.el
+++ b/hui-menu.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 28-Oct-94 at 10:59:44
-;; Last-Mod: 29-Aug-25 at 03:45:17 by Bob Weiner
+;; Last-Mod: 30-Nov-25 at 17:56:58 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -270,7 +270,7 @@ Return t if cutoff, else nil."
'("----")
(hui-menu-browser "Display-Web-Searches-in"
hyperbole-web-search-browser-function)
'("----")
- hui-menu-org-meta-return-options
+ (list hui-menu-org-meta-return-options)
'("----")
'(("Smart-Key-Press-at-Eol"
"----"
@@ -314,7 +314,16 @@ Return t if cutoff, else nil."
(when (fboundp 'consult-grep) ;; allow for autoloading
["Grep-Consult-Pages" hywiki-consult-grep t])
["Help" hywiki-help t]
- ["HyWiki-Mode-Toggle" hywiki-mode t]
+ '("HyWiki-Mode"
+ ["HyWiki-Pages-Only" (hywiki-mode :pages)
+ :style radio :selected (when (boundp 'hywiki-mode)
+ (eq hywiki-mode :pages))]
+ ["All-Editable-Buffers" (hywiki-mode :all)
+ :style radio :selected (when (boundp 'hywiki-mode)
+ (eq hywiki-mode :all))]
+ ["Nowhere" (hywiki-mode nil)
+ :style radio :selected (when (boundp 'hywiki-mode)
+ (null hywiki-mode))])
["HyWiki-Tag-Find" hywiki-tags-view t]
["Insert-HyWiki-Link" hywiki-insert-link t]
hui-menu-org-meta-return-options
diff --git a/hui-mini.el b/hui-mini.el
index 9e5beea63b..ac09f62648 100644
--- a/hui-mini.el
+++ b/hui-mini.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 15-Oct-91 at 20:13:17
-;; Last-Mod: 31-Aug-25 at 13:41:47 by Bob Weiner
+;; Last-Mod: 30-Nov-25 at 17:51:11 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -406,20 +406,33 @@ With optional ARG, enable iff ARG is positive."
(message "Menu key highlighting is on")))
(defun hui:menu-read-from-minibuffer (prompt &optional initial-contents keymap
read
- hist default-value inherit-input-method)
+ hist default-value
inherit-input-method)
"Hyperbole minibuffer menu replacement for `read-from-minibuffer'.
Allows custom handling of menu lines before selecting an item."
+ (when (and (stringp initial-contents)
+ (string-prefix-p "HyWiki Mode" initial-contents))
+ (let* ((hywiki-mode-options (cddr (assq 'cust-hywiki-mode hui:menus)))
+ (hywiki-mode-option-lookups (mapcar (lambda (option)
+ (cons (car (last (nth 1 option)))
+ (car option)))
+ hywiki-mode-options))
+ (hywiki-mode-current-name (cdr (assq hywiki-mode
hywiki-mode-option-lookups))))
+ (when (and (stringp hywiki-mode-current-name) (stringp initial-contents))
+ (setq initial-contents (replace-regexp-in-string (regexp-quote
hywiki-mode-current-name)
+ (concat "=="
hywiki-mode-current-name "==")
+ initial-contents)))))
+
(when (and (stringp initial-contents)
(string-prefix-p "Org M-RET" initial-contents))
(let* ((org-m-ret-options (cddr (assq 'cust-org hui:menus)))
- (option-lookups (mapcar (lambda (option)
- (cons (car (last (nth 1 option)))
- (car option)))
- org-m-ret-options))
- (current-name (cdr (assq hsys-org-enable-smart-keys
option-lookups))))
- (when (and (stringp current-name) (stringp initial-contents))
- (setq initial-contents (replace-regexp-in-string (regexp-quote
current-name)
- (concat "=="
current-name "==")
+ (org-option-lookups (mapcar (lambda (option)
+ (cons (car (last (nth 1 option)))
+ (car option)))
+ org-m-ret-options))
+ (org-current-name (cdr (assq hsys-org-enable-smart-keys
org-option-lookups))))
+ (when (and (stringp org-current-name) (stringp initial-contents))
+ (setq initial-contents (replace-regexp-in-string (regexp-quote
org-current-name)
+ (concat "=="
org-current-name "==")
initial-contents)))))
(setq initial-contents (hui:menu-maybe-highlight-item-keys initial-contents))
(read-from-minibuffer prompt initial-contents keymap read
@@ -803,6 +816,14 @@ command instead. Typically prevents clashes over {\\`C-c'
/}."
(("Smart Key press at eol scrolls>")
("Proportionally" (setq smart-scroll-proportional t))
("Windowful" (setq smart-scroll-proportional nil))))
+ '(cust-hywiki-mode .
+ (("HyWiki Mode>")
+ ("All-Editable-Buffers" (hywiki-mode :all)
+ "HyWikiWords are highlighted and active in buffers outside of the
HyWiki page directory.")
+ ("HyWiki-Pages-Only" (hywiki-mode :pages)
+ "HyWikiWords are highlighted and active only in within the HyWiki
page directory.")
+ ("Nowhere" (hywiki-mode nil)
+ "HyWikiWords are disabled everywhere.")))
'(cust-keys .
(("Change Keys>")
("ActionKey" (hui:bind-key #'hkey-either))
;; {M-RET}
@@ -1049,8 +1070,8 @@ support underlined faces as well."
"Display Hyperbole manual section on HyWiki.")
'("Link" hywiki-add-path-link
"Prompt for and add a HyWikiWord that links to a path and possible
position.")
- '("ModeToggle" hywiki-mode
- "Toggle whether HyWikiWords are highlighted and active in buffers
outside of the HyWiki page directory.")
+ '("ModeSet/" (menu . cust-hywiki-mode)
+ "Set hywiki-mode state to determine where HyWikiWord references are
recognized.")
'("Org-M-RET/" (menu . cust-org)
"Set how much of Hyperbole Smart Key behavior is enabled in Org
mode.")
'("Publish" hywiki-publish-to-html
diff --git a/hywiki.el b/hywiki.el
index aed1f7ba0c..e86769e8e1 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: 22-Nov-25 at 13:09:38 by Bob Weiner
+;; Last-Mod: 30-Nov-25 at 18:06:52 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -75,7 +75,7 @@
;; `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 h m} to toggle `hywiki-mode'; this also enables
+;; {C-u C-h h h m} to toggle `hywiki-mode'; this also enables
;; auto-highlighting if `hywiki-word-highlight-flag' is non-nil.
;; The custom setting, `hywiki-exclude-major-modes' (default = nil), is
@@ -260,8 +260,9 @@ 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; programmatically,
-use `(hywiki-mode 1) to enable it.
+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.
@@ -757,28 +758,28 @@ deletion commands and those in
`hywiki-non-character-commands'."
(define-minor-mode hywiki-mode
"Toggle HyWiki global minor mode with \\[hywiki-mode].
-HyWiki automatically highlights and turns instances of known
-HyWikiWords into implicit buttons if they are within buffers with
-files attached from `hywiki-directory'. Such buttons either link
-to HyWiki pages or activate typed referents such as bookmarks.
+HyWiki minor mode automatically highlights and turns HyWikiWord
+references into implicit buttons that either link to HyWiki pages
+or activate typed referents such as bookmarks.
-HyWiki Minor Mode enables the same behavior in most other text and
-programming buffers except those with a major mode in
-`hywiki-exclude-major-modes'.
+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'.
+ - nil - no highlighting, the mode is disabled.
HyWikiWord references may also include optional suffixes:
- - a #section reference that links to a HyWiki page Org headline or
- other outline file. Spaces in the headline must be converted
- to dash characters for proper recognition;
+ - a #section reference that links to a HyWiki page Org headline or
+ other outline file. Spaces in the headline must be converted
+ to dash characters for proper recognition;
- - optionally followed by :L<line-number>:C<column-number>
- where the column part is also optional. If a section is
- given, the line number is relative to the section and the
- section headline is line 1.
-
-When hywiki-mode is enabled, the `hywiki-mode' variable is
-non-nil.
+ - optionally followed by :L<line-number>:C<column-number>
+ where the column part is also optional. If a section is
+ given, the line number is relative to the section and the
+ section headline is line 1.
See the Info documentation at \"(hyperbole)HyWiki\".
@@ -787,23 +788,37 @@ See the Info documentation at \"(hyperbole)HyWiki\".
:lighter hywiki-mode-lighter
:keymap hywiki-mode-map
:group 'hyperbole-hywiki
- (if hywiki-mode
- ;; Enable mode.
- (progn
- ;; 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))
- ;; Disable mode.
- ;; 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-highlight-wikiwords-in-frame t)))
+ (progn
+ (when (memq arg '(toggle :toggle))
+ ;; Toggle across all editable buffers
+ (setq arg (if hywiki-mode 1 0)))
+ (cond
+ ((or (and (integerp arg) (= arg 1))
+ (memq arg '(:all t)))
+ ;; Enable across all editable buffers
+ ;; 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))
+ ((or (and (integerp arg) (<= arg 0))
+ (null arg))
+ ;; Disable across all editable buffers.
+ ;; 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-highlight-wikiwords-in-frame t)
+ (setq hywiki-mode nil))
+ (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)))))
;;; ************************************************************************
;;; Public Implicit Button and Action Types
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 78c985b209..7b2298bb7e 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: 29-Nov-25 at 12:24:05 by Bob Weiner
+@c Last-Mod: 30-Nov-25 at 18:03:22 by Bob Weiner
@c %**start of header (This is for running Texinfo on a region.)
@setfilename hyperbole.info
@@ -30,7 +30,7 @@
@set txicodequoteundirected
@set txicodequotebacktick
-@set UPDATED November 29, 2025
+@set UPDATED November 30, 2025
@set UPDATED-MONTH November 2025
@set EDITION 9.0.2pre
@set VERSION 9.0.2pre
@@ -4168,13 +4168,13 @@ menubar. Here is the Hyperbole Menubar Menu and its
Find submenu.
@float Image,image:Hyperbole Menu
@caption{Hyperbole Menubar Menu}
-@image{im/menu-hyperbole,,5in,Hyperbole Menu}
+@image{im/menu-hyperbole,5in,,Hyperbole Menu}
@end float
@page
@float Image,image:Find Menu
@caption{Find Menubar Menu}
-@image{im/menu-find,,5in,Find Menu}
+@image{im/menu-find,5in,,Find Menu}
@end float
@sp 1
@@ -4500,17 +4500,18 @@ highlighting of HyWikiWords in Org files within
h p} you can publish any updated part of your HyWiki to an HTML
directory for export to the web.
+@float Image,image:HyWiki Page
+@caption{HyWiki Page}
+@image{im/hywiki-page,3.5in,,HyWiki Page}
+@end float
+@sp 1
+
@menu
* HyWikiWords::
* Publish HyWiki::
* HyWiki Menu::
@end menu
-@float Image,image:HyWiki Page
-@caption{HyWiki Page}
-@image{im/hywiki-page,,3.5in,HyWiki Page}
-@end float
-@sp 1
@node HyWikiWords, Publish HyWiki, HyWiki, HyWiki
@section HyWikiWords
@@ -4573,17 +4574,6 @@ links are highlighted regardless of whether associated
sections exist
or not. When activating a link with a section reference, you will get
an error if the section does not exist.
-@cindex HyWikiWord, outside the wiki
-@cindex hywiki-mode
-@cindex toggle hywiki-mode
-@findex hywiki-mode
-@kindex C-h h h t
-HyWikiWords can also be highlighted and treated as hyperlinks in
-non-special text and programming buffers outside of the
-@code{hywiki-directory} when the global minor mode, @code{hywiki-mode}
-is enabled. Toggle it via @bkbd{C-h h h t} or @bkbd{M-x hywiki-mode
-@key{RET}}.
-
@vindex hywiki-org-link-type-required
@vindex hsys-org-enable-smart-keys
@cindex override Org M-RET
@@ -4601,15 +4591,36 @@ whose page has not yet been created, set
Action Key does the right thing in this context.
@cindex HyWikiWord contexts
+@cindex HyWikiWord, outside the wiki
+@cindex hywiki-mode
+@findex hywiki-mode
+@kindex C-h h h m
Once Hyperbole has been loaded and activated, HyWikiWords (with or
-without delimiters) are automatically highlighted and active in
-the following contexts:
+without delimiters) are automatically highlighted and active based
+on the setting of @code{hywiki-mode}. Set it with @bkbd{C-h h h m}
+ModeToggle into one of these three states:
-@itemize @bullet
-@item HyWiki page buffers;
-@item non-special text buffers, after `hywiki-mode' is enabled;
-@item comments of programming buffers, after `hywiki-mode' is enabled.
-@end itemize
+@table @kbd
+@item All-Editable-Buffers
+This is the default setting. Highlight HyWikiWord references within
+HyWiki page buffers only. The @code{hywiki-mode} variable is set to
+@samp{:pages}.
+
+@vindex hywiki-exclude-major-modes
+@item HyWiki-Pages-Only
+Highlight HyWikiWord references within all editable buffers except
+those with major modes in @code{hywiki-exclude-major-modes}. The
+@code{hywiki-mode} variable is set to @samp{:all}.
+
+@item Nowhere
+Disable highlighting HyWikiWord references everywhere. The
+@code{hywiki-mode} variable is set to @samp{nil}.
+@end table
+
+@cindex toggle hywiki-mode
+@noindent
+@{M-x hywiki-mode @key{RET}@} will also toggle between disabling
+HyWikiWords everywhere and enabling them in all editable buffers.
@cindex HyWikiWord highlighting
As HyWikiWords are typed, highlighting occurs after a trailing
@@ -5439,7 +5450,7 @@ read the following sections explaining commands.
@float Image,image:Koutline Menu
@caption{Koutline Menu}
-@image{im/menu-koutline,,6in,Koutline Menu}
+@image{im/menu-koutline,6in,,Koutline Menu}
@end float
@sp 1
@@ -8869,7 +8880,7 @@ below the Hyperbole menubar menu, as seen here.
@float Image,image:Customize Menu
@caption{Hyperbole Customize Menu}
-@image{im/menu-customization,,3.5in,Hyperbole Customize Menu}
+@image{im/menu-customization,3.5in,,Hyperbole Customize Menu}
@end float
@sp 1