From 0f779b9e1a2677dd44e3148bf73952a805e7c781 Mon Sep 17 00:00:00 2001
From: bw
Date: Thu, 25 Jun 2026 13:45:23 -0400
Subject: [PATCH] hywiki-add/display-command - Extend to handle arbitary
arguments
This allows HyWikiWords to use all Hyperbole action types.
---
ChangeLog | 22 +++-
README.md.html | 4 +-
hbut.el | 6 +-
hmouse-drv.el | 14 ++-
hui-mini.el | 7 +-
hui.el | 4 +-
hywiki.el | 56 +++++----
man/hyperbole.html | 280 ++++++++++++++++++++++++++++---------------
man/hyperbole.info | Bin 670306 -> 674473 bytes
man/hyperbole.pdf | Bin 1707100 -> 1710173 bytes
man/hyperbole.texi | 99 ++++++++++++---
test/hui-tests.el | 4 +-
test/hywiki-tests.el | 15 ++-
13 files changed, 358 insertions(+), 153 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5d50a2be..61cc1c0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2026-06-25 Bob Weiner
+
+* test/hywiki-tests.el (hywiki-tests--command): Fix interactive call
+ which was missing wikiword argument.
+
+* hywiki.el (hywiki-add-command, hywiki-display-command): Generalize
+ to handle the arguments of any Emacs command or Hyperbole actype.
+ Now a referent can be any type of Hyperbole button action.
+ test/hywiki-tests.el (hywiki-tests--add-command): Update to handle
+ above changes.
+
+* hywiki.el (hywiki-referent-menu): Extend 'Create' doc string to explain
+ how to get a prompt for a referent type rather than just linking
+ to a HyWiki page.
+ man/hyperbole.texi (HyWiki Menu): Extend 'Create' doc and document all
+ potentially prompted for HyWikiWord referent types.
+
+* hmouse-drv.el (hkey-help): When on a HyWikiWord, include attributes
+ 'referent-type' and 'referent-value' in help display.
+
2026-06-24 Bob Weiner
* test/hasht-tests.el: Add.
@@ -10477,7 +10497,7 @@ name with 'name' and 'name-key'.
with 'hpath:symlink-referent'.
(smart-symlink-expand): Remove this function.
-* hbut.el (ibut:to-text): Fix so does not move point if lbl-key end up nil.
+* hbut.el (ibut:to-text): Fix so does not move point if lbl-key ends up nil.
2023-01-28 Bob Weiner
diff --git a/README.md.html b/README.md.html
index 1be051fb..ffb911f0 100644
--- a/README.md.html
+++ b/README.md.html
@@ -5,8 +5,8 @@
look here.]
[We work on Hyperbole as a gift to the Emacs community and request
you send us a thank you or a testimonial describing your usage if you
-like Hyperbole to rsw@gnu.org].
+like Hyperbole to rsw@gnu.org].
- GNU
diff --git a/hbut.el b/hbut.el
index c244ed14..ec46e78d 100644
--- a/hbut.el
+++ b/hbut.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 18-Sep-91 at 02:57:09
-;; Last-Mod: 14-Jun-26 at 15:13:00 by Bob Weiner
+;; Last-Mod: 24-Jun-26 at 19:47:03 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -450,7 +450,7 @@ button is found in the current buffer."
;; Error when on a read-only part of a buffer's text
(when (plist-member (text-properties-at (point)) 'read-only)
- (hypb:error "(ebut:operate): Point must not be on a read-only Org element"))
+ (hypb:error "(ebut:operate): Point must not be on a read-only text section"))
;; Error when on an implicit button
(when (or (eq (hattr:get 'hbut:current 'categ) 'implicit)
(string-prefix-p "ibtypes::" (symbol-name (hattr:get 'hbut:current 'categ))))
@@ -2543,7 +2543,7 @@ Summary of operations based on inputs (name arg from \\='hbut:current attrs):
;; Error when on a read-only part of a buffer's text
(when (plist-member (text-properties-at (point)) 'read-only)
- (hypb:error "(ibut:operate): Point must not be on a read-only Org element"))
+ (hypb:error "(ibut:operate): Point must not be on a read-only text section"))
;; Error when on an explicit button
(when (eq (hattr:get 'hbut:current 'categ) 'explicit)
(hypb:error "(ibut:operate): Point must not be on an explicit button: %s"
diff --git a/hmouse-drv.el b/hmouse-drv.el
index b52ad809..d88703f1 100644
--- a/hmouse-drv.el
+++ b/hmouse-drv.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 04-Feb-90
-;; Last-Mod: 28-Sep-25 at 12:22:16 by Bob Weiner
+;; Last-Mod: 25-Jun-26 at 08:53:26 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1177,7 +1177,17 @@ documentation is found."
(categ (hattr:get 'hbut:current 'categ))
(attributes (nthcdr 2 (hattr:list 'hbut:current)))
(but-def-symbol (htype:def-symbol
- (if (eq categ 'explicit) actype categ))))
+ (if (eq categ 'explicit) actype categ)))
+ (wikiword-referent
+ (when (eq (htype:def-symbol actype) 'link-to-wikiword)
+ (hywiki-get-referent
+ (hattr:get 'hbut:current 'lbl-key)))))
+
+ (when wikiword-referent
+ (hattr:set 'hbut:current 'referent-type
+ (car wikiword-referent))
+ (hattr:set 'hbut:current 'referent-value
+ (cdr wikiword-referent)))
(princ (format "%s %s SPECIFICS:\n"
(or but-def-symbol
diff --git a/hui-mini.el b/hui-mini.el
index 63379ba8..816249c0 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: 22-Mar-26 at 23:15:20 by Bob Weiner
+;; Last-Mod: 25-Jun-26 at 09:52:07 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1064,7 +1064,10 @@ support underlined faces as well."
'("BacklinkConsult" hywiki-consult-backlink
"Use Consult to select a backlink (reference) to a prompted for HyWikiWord."))
'("Create" hywiki-word-create-and-display
- "Create and display a new or existing HyWikiWord referent, prompting with any existing referent names.")
+ "Create and display a new or existing HyWikiWord referent, prompting with any existing referent names.
+With either `hywiki-referent-prompt-flag' set or optional prefix ARG,
+prompt for and choose a typed referent, otherwise, create and/or display
+a HyWiki page. See `hywiki-referent-menu' for valid referent types.")
'("DiredHyWiki" hywiki-directory-edit
"Display and edit HyWiki directory.")
'("EditPage" hywiki-find-page
diff --git a/hui.el b/hui.el
index 73f58163..7c5ee01f 100644
--- a/hui.el
+++ b/hui.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 21:42:03
-;; Last-Mod: 19-Jun-26 at 00:26:54 by Bob Weiner
+;; Last-Mod: 25-Jun-26 at 09:58:50 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1655,7 +1655,7 @@ Trigger an error if DEFAULT-ACTYPE is invalid."
(with-current-buffer but-buf
(when buffer-read-only
(setq err
- (format "(%s) Read-only error in Hyperbole button buffer '%s'. Use {%s} to enable edits."
+ (format "(%s) Read-only error in buffer '%s'. Use {%s} to enable edits."
func-name (buffer-name but-buf) (hmouse-read-only-toggle-key)))))
(when err
(pop-to-buffer but-buf)
diff --git a/hywiki.el b/hywiki.el
index 36a891ba..f45873b9 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: 18-Jun-26 at 09:15:55 by Bob Weiner
+;; Last-Mod: 25-Jun-26 at 13:00:30 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -327,7 +327,7 @@ included in the list, `hywiki-include-special-modes'."
(defcustom hywiki-include-special-modes
'(elfeed-search-mode elfeed-show-mode eww-mode kotl-mode)
- "List of `special' major modes to include in HyWikiWord highlighting and recognition.
+ "List of `special' major modes with HyWikiWord highlighting and recognition.
By default, all special modes, like Dired, are excluded. A major mode
included here will override its inclusion in `hywiki-exclude-major-modes'."
:type '(list symbol)
@@ -1089,7 +1089,7 @@ After successfully finding a referent, run `hywiki-display-referent-hook'."
(delq nil
(list
'("HyWiki Add>")
- (when (fboundp #'activities-new)
+ (when (fboundp #'activities-new)
'("Activity" (hywiki-add-activity hkey-value)
"Add a HyWikiWord that activates a saved activity from the Activities package."))
'("Bookmark" (hywiki-add-bookmark hkey-value)
@@ -1127,7 +1127,8 @@ After successfully finding a referent, run `hywiki-display-referent-hook'."
'("orgRoamNode" (hywiki-add-org-roam-node hkey-value)
"Add a HyWikiWord that displays an Org Roam node given its title.")
'("Sexp" (hywiki-add-sexpression hkey-value)
- "Add a HyWikiWord that evaluates an Elisp sexpression.")))
+ "Add a HyWikiWord that evaluates an Elisp sexpression.")
+ ))
"Menu of HyWikiWord custom referent types of the form:
\(LABEL-STRING ACTION-SEXP DOC-STR)."
:set (lambda (var value) (set-default var value))
@@ -1158,8 +1159,8 @@ an error is triggered."
(defun hywiki-create-referent (wikiword &optional message-flag)
"Prompt for, add to HyWiki lookups and return a WIKIWORD custom referent.
-With optional prefix arg MESSAGE-FLAG non-nil, display a minibuffer message
-with the referent."
+With optional prefix arg MESSAGE-FLAG non-nil or when called interactively,
+display a minibuffer message with the referent."
(interactive (list nil current-prefix-arg))
(unless (stringp wikiword)
(setq wikiword (hywiki-word-read-new "Create/Edit HyWikiWord: ")))
@@ -1201,7 +1202,7 @@ use `hywiki-active-in-current-buffer-p' for that."
(not (apply #'derived-mode-p hywiki-exclude-major-modes))))))
(defun hywiki-add-activity (wikiword)
- "Make WIKIWORD resume a prompted for activity.
+ "Make WIKIWORD resume a prompted for, existing activity.
If WIKIWORD is invalid, trigger a `user-error' if called interactively
or return nil if not.
@@ -1249,10 +1250,10 @@ calling this function."
(bookmark-jump bookmark)))
(defun hywiki-add-command (wikiword)
- "Set a custom command symbol for WIKIWORD and return it.
-Command is the symbol used in the definition expression, which
-may be an Emacs command or a Hyperbole action type. When invoked,
-it receives the single argument of WIKIWORD.
+ "Make WIKIWORD invoke a prompted for command with arguments and return it.
+Interactively, use any existing HyWikiWord at point or read an existing or
+valid new one. Command is the symbol used in the definition expression,
+which may be an Emacs command or a Hyperbole action type.
If WIKIWORD is invalid, trigger a `user-error' if called interactively
or return nil if not.
@@ -1263,13 +1264,25 @@ Use `hywiki-get-referent' to determine whether WIKIWORD exists prior to
calling this function."
(interactive (list (or (hywiki-word-at)
(hywiki-word-read-new "Add/Edit HyWikiWord: "))))
- (let ((command (hui:actype nil (format "Command for %s: " wikiword))))
- (hywiki-add-referent wikiword (cons 'command command))))
+ (when (string-empty-p wikiword)
+ (error "(hywiki-add-command): No HyWikiWord specified"))
+
+ (let* ((command (hui:actype nil (format "Command for %s: " wikiword)))
+ (args (hargs:actype-get command)))
+ (hywiki-add-referent wikiword
+ (if (equal args (list wikiword))
+ (cons 'command command)
+ (cons 'command (cons command args))))))
(defun hywiki-display-command (wikiword command)
- (if (fboundp command)
- (actype:act command wikiword)
- (error "(hywiki-display-command): Unbound referent command, '%s'" command)))
+ (cond ((consp command)
+ ;; arbitrary list of arguments
+ (apply 'actype:act command))
+ ((symbolp command)
+ ;; single arg of wikiword is sent to command
+ (actype:act command wikiword))
+ (t (error "(hywiki-display-command): Unbound referent command, '%s'"
+ command))))
(defun hywiki-add-find (wikiword)
"Make WIKIWORD grep across `hywiki-directory' for matches to itself.
@@ -1523,13 +1536,14 @@ Use `hywiki-get-referent' to determine whether a HyWiki page exists."
(user-error "(hywiki-add-page): Invalid HyWikiWord: '%s'; must be capitalized, all alpha" page-name))))
;;;###autoload
-(defun hywiki-word-create (wikiword &optional arg)
+(defun hywiki-word-create (wikiword &optional ref-type-flag)
"Create a HyWiki referent for WIKIWORD and return it; don't display it.
This replaces any existing referent the WIKIWORD may have.
-With either `hywiki-referent-prompt-flag' set or optional prefix ARG,
-prompt for and choose a typed referent, otherwise, create and/or display
-a HyWiki page. See `hywiki-referent-menu' for valid referent types.
+With either `hywiki-referent-prompt-flag' set or optional prefix
+REF-TYPE-FLAG, prompt for and choose a typed referent, otherwise, create
+and/or display a HyWiki page. See `hywiki-referent-menu' for valid referent
+types.
Use `hywiki-get-referent' to test for and retrieve an existing HyWikiWord
referent."
@@ -1542,7 +1556,7 @@ referent."
"referent"
"page"))))
current-prefix-arg))
- (if (or arg hywiki-referent-prompt-flag)
+ (if (or ref-type-flag hywiki-referent-prompt-flag)
(hywiki-create-referent wikiword t)
(hywiki-create-page wikiword t)))
diff --git a/man/hyperbole.html b/man/hyperbole.html
index 9cb5697c..532f8e97 100644
--- a/man/hyperbole.html
+++ b/man/hyperbole.html
@@ -4,7 +4,7 @@