diff --git a/ChangeLog b/ChangeLog index cfab4896..57b87a4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2026-06-28 Bob Weiner + +* hmouse-drv.el (hkey-help): Improve to: + 1. show the doc for custom actype:help functions for the Assist Key + (in addition to ibtype:help functions, e.g. see hsys-youtube.el. + 2. with the Assist Key on an Action button, show the doc for its + actype. + 3. with the Assist Key, comment out removal of the 'actype' and + 'action' button attributes, as seeing them can be helpful. + +* hibtypes.el (texinfo-ref): Update to handle references to @anchor + locations. Update doc string for this and that only info (no + Texinfo) manuals are displayed if a cross-reference is outside + of the current Texinfo manual. + hactypes.el (link-to-texinfo-node): Update to handle references + to @anchor. + man/hyperbole.texi (link-to-Info-node): Update doc to match. + 2026-06-27 Bob Weiner * man/hyperbole.texi (Smart Key - Hyperbole Buttons): Cross-reference diff --git a/hactypes.el b/hactypes.el index 1981530a..b4eeb092 100644 --- a/hactypes.el +++ b/hactypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 23-Sep-91 at 20:34:36 -;; Last-Mod: 18-Jun-26 at 10:01:03 by Bob Weiner +;; Last-Mod: 28-Jun-26 at 09:48:58 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -521,9 +521,8 @@ suffix." (hypb:error "(link-to-Info-index-entry): Invalid Info index item: `%s'" index-item))) (defact link-to-Info-node (string) - "Display an Info node given by STRING. -If not found, try to display it as an Info index item. -STRING must be a string of the form \"(filename)name\" or + "Display an Info node, anchor or index position given by STRING. +STRING must be of the form: \"(filename)name\" or \"filename.info#name\". During button creation, completion for both filename and node names is available. Filename may be given without the .info suffix in the format with parentheses." @@ -736,14 +735,14 @@ Return t if found, nil if not." (funcall (actype:action 'link-to-regexp-match) (regexp-quote string) n source buffer-p)) -(defact link-to-texinfo-node (file node) - "Display the Texinfo FILE and NODE (a string). +(defact link-to-texinfo-node (file node-or-anchor) + "Display the Texinfo FILE and NODE-OR-ANCHOR (a string). FILE may be a string or nil, in which case the current buffer is used." - (interactive "fTexinfo file to link to: \nsNode within file to link to: ") - (if (stringp node) - ;; Remove any tabs or newlines that might be in node name. - (setq node (replace-regexp-in-string "[ \t\n\r\f]+" " " (string-trim node) t t)) - (setq node "Top")) + (interactive "fTexinfo file to link to: \nsNode or anchor within file to link to: ") + (if (stringp node-or-anchor) + ;; Remove any tabs or newlines that might be in node-or-anchor name. + (setq node-or-anchor (replace-regexp-in-string "[ \t\n\r\f]+" " " (string-trim node-or-anchor) t t)) + (setq node-or-anchor "Top")) (let (node-point) (when (equal file "hyperbole.texi") (setq file (expand-file-name file (hpath:expand "${hyperb:dir}/man/")))) @@ -752,17 +751,18 @@ FILE may be a string or nil, in which case the current buffer is used." (setq file (hypb:buffer-file-name))) (save-excursion (goto-char (point-min)) - (if (re-search-forward (format "^@node[ \t]+%s *[,\n\r]" node) nil t) - (setq node-point (match-beginning 0)) - (hypb:error "(link-to-texinfo-node): Non-existent node: \"%s%s\"" - (if file - (format "(%s)" (file-name-nondirectory file)) - "") - node))) + (cond ((or (re-search-forward (format "^@node[ \t]+%s *[,\n\r]" node-or-anchor) nil t) + (re-search-forward (format "^@anchor{%s}" node-or-anchor) nil t)) + (setq node-point (match-beginning 0))) + (t (hypb:error "(link-to-texinfo-node): Non-existent location: \"%s%s\"" + (if file + (format "(%s)" (file-name-nondirectory file)) + "") + node-or-anchor)))) (if file (hact 'link-to-file file node-point) - (hypb:error "(link-to-texinfo-node): Non-existent node: \"%s\"" - node)))) + (hypb:error "(link-to-texinfo-node): Non-existent location: \"%s\"" + node-or-anchor)))) (defact link-to-web-search (service-name search-term) "Search web SERVICE-NAME for SEARCH-TERM. diff --git a/hibtypes.el b/hibtypes.el index d335de80..79d3aa9a 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: 27-Jun-26 at 18:36:25 by Bob Weiner +;; Last-Mod: 28-Jun-26 at 09:27:49 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1375,10 +1375,12 @@ Patch applies diffs to source code." Supported Texinfo constructs are node, menu item, @xref, @pxref, @ref, @code, @findex, @var or @vindex. -If point is within the braces of a cross-reference, the associated -Info node is shown. If point is to the left of the braces but after -the @ symbol and the reference is to a node within the current -Texinfo file, then the Texinfo node is shown. +If poin is on a reference to a node or anchor outside of the current Texinfo +manual, then the associated Info node is shown. Otherwise, if point is +within the braces of a cross-reference, the associated Info node is shown. +If point is to the left of the braces but after the @ symbol and the +reference is to a node or anchor within the current Texinfo file, then the +Texinfo node or anchor is shown. For @code, @findex, @var and @vindex references, the associated documentation string is displayed." diff --git a/hmouse-drv.el b/hmouse-drv.el index 4ee08d5a..ef47c5e7 100644 --- a/hmouse-drv.el +++ b/hmouse-drv.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-90 -;; Last-Mod: 26-Jun-26 at 12:36:25 by Bob Weiner +;; Last-Mod: 28-Jun-26 at 12:32:38 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1110,17 +1110,17 @@ documentation is found." (assist-flag assisting) (pred-point (point-marker)) hkey-form pred pred-value call calls cmd-sym doc) - (unwind-protect - (while (and (null pred-value) (setq hkey-form (car hkey-forms))) - (or (setq pred (car hkey-form) - pred-value (hypb:eval-debug pred)) - (setq hkey-forms (cdr hkey-forms))) - ;; Any Smart Key predicate should leave point unchanged. - ;; Trigger an error if not. - (unless (equal (point-marker) pred-point) - (hypb:error "(Hyperbole): `%s' predicate left point at %s and failed to restore it to %s" pred (point) pred-point))) - (set-marker pred-point nil)) - (if pred-value + (unwind-protect + (while (and (null pred-value) (setq hkey-form (car hkey-forms))) + (or (setq pred (car hkey-form) + pred-value (hypb:eval-debug pred)) + (setq hkey-forms (cdr hkey-forms))) + ;; Any Smart Key predicate should leave point unchanged. + ;; Trigger an error if not. + (unless (equal (point-marker) pred-point) + (hypb:error "(Hyperbole): `%s' predicate left point at %s and failed to restore it to %s" pred (point) pred-point))) + (set-marker pred-point nil)) + (if pred-value (setq call (if assisting (cddr hkey-form) (cadr hkey-form)) @@ -1149,10 +1149,11 @@ documentation is found." (let* ((actype (or (actype:elisp-symbol (hattr:get 'hbut:current 'actype)) (hattr:get 'hbut:current 'actype))) + (actype-doc-flag (and (symbolp actype) + (fboundp actype) + (documentation actype))) (assist-function-flag (and assisting - (symbolp actype) - (fboundp actype) - (documentation actype))) + actype-doc-flag)) (condition (car hkey-form)) (temp-buffer-show-hook (lambda (buf) @@ -1179,14 +1180,14 @@ documentation is found." ;; Print Hyperbole button attributes (when (memq cmd-sym '(hui:hbut-act hui:hbut-help)) (let* ;; (lbl-key (hattr:get 'hbut:current 'lbl-key)) - ((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))) - (wikiword-referent - (when (eq (htype:def-symbol actype) 'link-to-wikiword) - (hywiki-get-referent - (hattr:get 'hbut:current 'lbl-key))))) + ((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))) + (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 @@ -1202,12 +1203,14 @@ documentation is found." (categ "IMPLICIT BUTTON") (t "ACTION TYPE")))) - (when (and assisting - (or (plist-member attributes 'actype) - (plist-member attributes 'action))) - (setq attributes (copy-sequence attributes)) - (hypb:remove-from-plist attributes 'actype) - (hypb:remove-from-plist attributes 'action)) + + ;; (when (and assisting + ;; (not (eq categ (ibtype:elisp-symbol 'action))) + ;; (or (plist-member attributes 'actype) + ;; (plist-member attributes 'action))) + ;; (setq attributes (copy-sequence attributes)) + ;; (hypb:remove-from-plist attributes 'actype) + ;; (hypb:remove-from-plist attributes 'action)) (hattr:report attributes) (unless (or assisting (eq categ 'explicit) @@ -1215,28 +1218,46 @@ documentation is found." (not (fboundp categ)) (null (documentation categ))) ;; Include implicit button's ibtype doc - (princ (format "\n%s\n" + (princ (format "\n%s ACTION KEY SPECIFICS:\n" + (htype:names 'ibtypes categ))) + (princ (format "%s\n" (replace-regexp-in-string "^" " " (documentation categ) nil t)))) - (if assisting - (let* ((ibtype-name (htype:names 'ibtypes categ)) - (custom-help-func (when (stringp ibtype-name) - (intern-soft - (concat ibtype-name ":help")))) - (type-help-func (or (and custom-help-func - (fboundp custom-help-func) - custom-help-func) - 'hbut:report))) - (princ (format "\n%s ASSIST KEY SPECIFICS:\n%s\n" - type-help-func - (replace-regexp-in-string - "^" " " (documentation type-help-func) - nil t)))) - (when assist-function-flag - (princ (format "\n%s ACTION KEY SPECIFICS:\n%s\n" - (or (actype:def-symbol actype) actype) - (replace-regexp-in-string "^" " " (documentation actype) - nil t))))) + (when assisting + (let* ((ibtype-name (htype:names 'ibtypes categ)) + (custom-help-func (when (stringp ibtype-name) + (intern-soft + (concat ibtype-name ":help")))) + (type-help-func (or (and custom-help-func + (fboundp custom-help-func) + custom-help-func) + 'hbut:report))) + (princ (format "\n%s ASSIST KEY SPECIFICS:\n%s\n" + type-help-func + (replace-regexp-in-string + "^" " " (documentation type-help-func) + nil t))))) + + ;; Display possibly custom actype :help documentation for + ;; an Action button + (when (or (not assisting) + (eq (htype:def-symbol categ) 'action)) + (let* ((actype-name (or (htype:names 'actypes actype) + (symbol-name actype))) + (custom-help-func (when (stringp actype-name) + (intern-soft + (concat actype-name ":help")))) + (type-help-func (or (and custom-help-func + (fboundp custom-help-func) + custom-help-func) + actype))) + (princ (format "\n%s ACTYPE SPECIFICS:\n%s\n" + (or (htype:names 'actypes type-help-func) + (symbol-name type-help-func)) + (replace-regexp-in-string + "^" " " (documentation type-help-func) + nil t))))) + (terpri))) ;; Print Emacs push-button attributes @@ -1258,8 +1279,8 @@ documentation is found." (unless assist-function-flag (princ (format "A %s of the %s %sKey" (if mouse-flag - (if mouse-drag-flag "drag" "click") - "press") + (if mouse-drag-flag "DRAG" "CLICK") + "PRESS") (if assisting "Assist" "Action") (if mouse-flag "Mouse " ""))) (terpri) diff --git a/man/hyperbole.texi b/man/hyperbole.texi index c65c030b..667a104c 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: 28-Jun-26 at 00:20:55 by Bob Weiner +@c Last-Mod: 28-Jun-26 at 09:49:02 by Bob Weiner @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -3554,10 +3554,11 @@ available. Filename may be given without the .info suffix." @findex actypes link-to-Info-node @item link-to-Info-node -Display an Info NODE. NODE must be a string of the form -(filename)nodename. During button creation, completion for both -filename and nodename is available. Filename may be given without the -.info suffix. +Display an Info node, anchor or index position given by STRING. +STRING must be of the form: ``(filename)name'' or +``filename.info#name''. During button creation, completion for both +filename and node names is available. Filename may be given without +the .info suffix. @findex actypes link-to-ibut @item link-to-ibut