branch: externals/hyperbole commit 12e714d824d37006ae1487bb369362988a6b5e50 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Move xref extensions to new "hsys-xref.el". Add ibut API extensions Add ibut:is-type-p and change 'ibut:at-type-p'. Add 'hbut:actype' and 'ibut:type'. --- ChangeLog | 29 +++++++++++++++++++++++++---- MANIFEST | 1 + Makefile | 4 ++-- hbut.el | 36 +++++++++++++++++++++++++----------- hmouse-tag.el | 31 +++---------------------------- 5 files changed, 56 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c7275ec39..e00a45532f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2024-01-07 Bob Weiner <r...@gnu.org> + +* hbut.el (hbut:actype, ibut:type): Add for Hyperbole API use. + (ibut:at-type-p): Rewrite using 'ibtype:elisp-symbol' and + 'ibut:type'. + (ibut:is-type-p): Add to give both an ibut and a type for + comparison and API use. + (ibtype:def-symbol, hattr:report): Change call from 'make-symbol' + to 'intern' for efficiency. + +* hmouse-tag.el (smart-tags-noselect-function): Change function reference + to new name, 'hsys-xref-definition'. + +* MANIFEST: + Makefile (EL_COMPILE): + hsys-xref.el (hsys-xref-definitions): Move xref utility functions + from "hmouse-tag.el" to here and add Hyperbole unique hsys- prefix. + 2024-01-06 Mats Lidell <ma...@gnu.org> * Makefile (HYPB_ERT_BATCH, HYPB_ERT_BATCH_BT): Add command line arg to @@ -8704,11 +8722,13 @@ for expanded Org mode reference handling. * hbut.el (gbut:ibut-key-list): Added. -* hui.el (hui:hbut-term-highlight, hui:hbut-term-unhighlight): Fixed so save-excursion is outermost. +* hui.el (hui:hbut-term-highlight, hui:hbut-term-unhighlight): Fixed so + save-excursion is outermost. 2019-06-29 Bob Weiner <r...@gnu.org> -* hbut.el (ebut:get, ebut:at-p, ebut:label-to-key, ibut:at-type-p): Simplified conditionals using 'when'. +* hbut.el (ebut:get, ebut:at-p, ebut:label-to-key, ibut:at-type-p): Simplified + conditionals using 'when'. (ibut:label-start, ibut:label-end, ibut:label-p, ibut:get, ibut:next-occurrence, ibut:label-regexp): Added. (hbut:label-regexp): Added to support labeled implicit buttons too. @@ -8717,8 +8737,9 @@ for expanded Org mode reference handling. 2019-06-23 Bob Weiner <r...@gnu.org> -* hsys-org.el: Added many new predicates and code to handle navigation between Org - mode internal links and their targets, as well as radio target definitions and their links. +* hsys-org.el: Added many new predicates and code to handle navigation between + Org mode internal links and their targets, as well as radio target + definitions and their links. (hsys-org-mode-function, hsys-org-mode-p): Added to determine when hsys-org actions are activated. diff --git a/MANIFEST b/MANIFEST index 3b57d005ab..94948cea89 100644 --- a/MANIFEST +++ b/MANIFEST @@ -103,6 +103,7 @@ hsys-flymake.el - Add missing source buffer keymap to flymake linter hsys-org.el - GNU Hyperbole support functions for Org mode hsys-org-roam.el - GNU Hyperbole support functions for Org Roam hsys-www.el - GNU Hyperbole support for Emacs W3 World-Wide Web (WWW) browsing +hsys-xref.el - GNU Hyperbole support functions for "xref.el" hsys-youtube.el - Action buttons to play timestamped segments of Youtube videos * --- HYPERBOLE TEST CASES --- diff --git a/Makefile b/Makefile index c5dbc38630..e58eae5ad5 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Author: Bob Weiner # # Orig-Date: 15-Jun-94 at 03:42:38 -# Last-Mod: 6-Jan-24 at 16:59:43 by Mats Lidell +# Last-Mod: 7-Jan-24 at 14:27:34 by Bob Weiner # # Copyright (C) 1994-2023 Free Software Foundation, Inc. # See the file HY-COPY for license information. @@ -183,7 +183,7 @@ EL_COMPILE = hact.el hactypes.el hargs.el hbdata.el hbmap.el hbut.el \ hinit.el hload-path.el hmail.el hmh.el hmoccur.el hmouse-info.el \ hmouse-drv.el hmouse-key.el hmouse-mod.el hmouse-sh.el hmouse-tag.el \ hpath.el hrmail.el hsettings.el hsmail.el hsys-flymake.el hsys-org.el \ - hsys-org-roam.el hsys-www.el hsys-youtube.el htz.el \ + hsys-org-roam.el hsys-www.el hsys-xref.el hsys-youtube.el htz.el \ hycontrol.el hui-jmenu.el hui-menu.el hui-mini.el hui-mouse.el hui-select.el \ hui-treemacs.el hui-window.el hui.el hvar.el hversion.el hypb.el hyperbole.el \ hyrolo-demo.el hyrolo-logic.el hyrolo-menu.el hyrolo.el hywconfig.el set.el hypb-ert.el \ diff --git a/hbut.el b/hbut.el index 8781701a74..678a01cdad 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: 6-Jan-24 at 00:40:15 by Bob Weiner +;; Last-Mod: 7-Jan-24 at 20:13:36 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -976,7 +976,7 @@ Ignore nil valued attributes. Return t unless no attributes are printed." val (prin1-to-string val))) (string-match "\\`actypes::" str)) - (make-symbol (substring str (match-end 0)))) + (intern (substring str (match-end 0)))) (t val))))))) has-attr))) @@ -1081,6 +1081,11 @@ Default is the symbol hbut:current." atype (or action (actype:action atype))))) +(defun hbut:actype (hbut) + "Return action type for Hyperbole button symbol HBUT." + (when (hbut:is-p hbut) + (hattr:get hbut 'actype))) + (defun hbut:at-p () "Return symbol for explicit or implicit Hyperbole button at point or nil. Then use (hbut:act) to activate the button. @@ -1725,17 +1730,21 @@ excluding delimiters, not just one." (defun ibut:at-type-p (ibut-type-symbol) "Return non-nil if point is on a button of type IBUT-TYPE-SYMBOL. -Point must be on the button itself and not its name, if any. +Point may be on the button text or its preceding name. The return value is a list of the type's action type symbol and associated arguments from the button." - (when (and ibut-type-symbol (symbolp ibut-type-symbol)) - (let ((type-name (symbol-name ibut-type-symbol))) - (unless (string-match "::" type-name) - (setq ibut-type-symbol (intern-soft (concat "ibtypes::" type-name)))) - (when ibut-type-symbol - (let ((hrule:action #'actype:identity)) - (funcall ibut-type-symbol)))))) + (and (setq ibut-type-symbol (ibtype:elisp-symbol ibut-type-symbol)) + (let ((ibut (ibut:at-p))) + (and ibut (eq (ibut:type ibut) ibut-type-symbol))))) + +(defun ibut:is-type-p (ibut ibut-type-symbol) + "Return non-nil if IBUT is a button of type IBUT-TYPE-SYMBOL. +Use `ibut:at-type-p' to test the type of the implicit button at point." + (when (setq ibut-type-symbol (ibtype:elisp-symbol ibut-type-symbol)) + (unless (ibut:is-p ibut) + (setq ibut nil)) + (and ibut (eq (ibut:type ibut) ibut-type-symbol)))) (defun ibut:set-name-and-label-key-p (&optional start-delim end-delim) "Set ibut name, lbl-key, lbl-start/end attributes in \\='hbut:current. @@ -2843,6 +2852,11 @@ Return the symbol for the button if found, else nil." name-key (current-buffer)))) +(defun ibut:type (ibut) + "Return full implicit type name for IBUT, else nil." + (when (ibut:is-p ibut) + (hattr:get ibut 'categ))) + ;;; ------------------------------------------------------------------------ (defconst ibut:label-start "<[" "String matching the start of a Hyperbole implicit button label.") @@ -3082,7 +3096,7 @@ is returned." ibtype (symbol-name ibtype)))) (when (string-match "\\`ibtypes::" name) - (make-symbol (substring name (match-end 0)))))) + (intern (substring name (match-end 0)))))) (defun ibtype:delete (type) "Delete an implicit button TYPE (a symbol). diff --git a/hmouse-tag.el b/hmouse-tag.el index de1d0644ab..ae64e23b86 100644 --- a/hmouse-tag.el +++ b/hmouse-tag.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 5-Jan-24 at 23:01:12 by Mats Lidell +;; Last-Mod: 7-Jan-24 at 14:34:32 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -27,32 +27,7 @@ ;; command. (load "etags.elc" t nil t))) -(require 'xref) -;; Fix next xref function to handle when called at beginning of buffer -(defun xref--item-at-point () - (get-text-property - (max (point-min) (if (eolp) (1- (point)) (point))) - 'xref-item)) -(defun xref-definitions (identifier) - "Return a list of all definitions of string IDENTIFIER." - (let* ((elisp-flag (smart-emacs-lisp-mode-p)) - (xref-backend (or (and elisp-flag - (fboundp 'ert-test-boundp) - (ert-test-boundp identifier) - (boundp 'xref-etags-mode) - 'etags) - (xref-find-backend))) - (xref-items (xref-backend-definitions xref-backend identifier))) - xref-items)) -(defun xref-definition (identifier) - "Return the first definition of string IDENTIFIER." - (car (xref-definitions identifier))) -(defun xref-item-buffer (item) - "Return the buffer in which xref ITEM is defined." - (marker-buffer (save-excursion (xref-location-marker (xref-item-location item))))) -(defun xref-item-position (item) - "Return the buffer position where xref ITEM is defined." - (marker-position (save-excursion (xref-location-marker (xref-item-location item))))) +(require 'hsys-xref) ;;; ************************************************************************ ;;; Public declarations @@ -1554,7 +1529,7 @@ to look. If no tags file is found, an error is signaled." "Return the best available function for finding a tag definition. The function does not select the tag definition." (car (delq nil (mapcar (lambda (func) (if (fboundp func) func)) - #'(xref-definition find-tag-noselect find-tag-internal))))) + #'(hsys-xref-definition find-tag-noselect find-tag-internal))))) (provide 'hmouse-tag)