branch: externals/hyperbole commit 60099124566990a1ffe55106bce045a48927de8a Author: Mats Lidell <mats.lid...@lidells.se> Commit: Mats Lidell <mats.lid...@lidells.se>
Add type of but in error message, renamed but parameter --- ChangeLog | 4 +++- hbut.el | 34 +++++++++++++++++----------------- test/hbut-tests.el | 8 +++++++- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7aa2d4fec..843706b2e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2024-02-08 Mats Lidell <ma...@gnu.org> +2024-02-11 Mats Lidell <ma...@gnu.org> * test/hbut-tests.el (hbut-tests--ebut-act-calls-hbut-act) (hbut-tests--ibut-act-calls-hbut-act): Add test for new act functions @@ -13,6 +13,8 @@ falling back on hbut:current check that it is of the same type as the call. +2024-02-08 Mats Lidell <ma...@gnu.org> + * test/hyrolo-tests.el: Make hide tests more forgiving about hiding section headers. Allows test cases to be used with different versions of org. diff --git a/hbut.el b/hbut.el index 22c27d55c2..e1884e862e 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: 8-Feb-24 at 15:39:49 by Mats Lidell +;; Last-Mod: 11-Feb-24 at 23:43:08 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -122,17 +122,17 @@ indicating the source of any of its Hyperbole buttons.") "*Non-nil value saves button data when button source is saved. Nil disables saving.") -(defun ebut:act (&optional hbut) - "Perform action for optional explicit Hyperbole button symbol HBUT. +(defun ebut:act (&optional ebut) + "Perform action for optional explicit Hyperbole button symbol EBUT. Default is the symbol hbut:current." (interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole button: " (ebut:alist) - nil t nil 'hbut)))) - (unless hbut - (setq hbut 'hbut:current)) - (if (ebut:is-p hbut) - (hbut:act hbut) - (error "(ebut:act): Must be called with an ebut or hbut:current must be an ebut"))) + nil t nil 'ebut)))) + (unless ebut + (setq ebut 'hbut:current)) + (if (ebut:is-p ebut) + (hbut:act ebut) + (error "(ebut:act): Expected an ebut but got a but of type %s" (hattr:get ebut 'categ)))) (defun ebut:act-label (label) "Activate Hyperbole explicit button with LABEL from the current buffer." @@ -1704,17 +1704,17 @@ Keys in optional KEY-SRC or the current buffer." ;;; ibut class - Implicit Hyperbole Buttons ;;; ======================================================================== -(defun ibut:act (&optional hbut) - "Perform action for optional implicit Hyperbole button symbol HBUT. +(defun ibut:act (&optional ibut) + "Perform action for optional implicit Hyperbole button symbol IBUT. Default is the symbol hbut:current." (interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole button: " (ibut:alist) - nil t nil 'hbut)))) - (unless hbut - (setq hbut 'hbut:current)) - (if (ibut:is-p hbut) - (hbut:act hbut) - (error "(ibut:act): Must be called with an ibut or hbut:current must be an ibut"))) + nil t nil 'ibut)))) + (unless ibut + (setq ibut 'hbut:current)) + (if (ibut:is-p ibut) + (hbut:act ibut) + (error "(ebut:act): Expected an ibut but got a but of type %s" (hattr:get ibut 'categ)))) (defun ibut:act-label (label) "Activate Hyperbole implicit button with <[LABEL]> from the current buffer." diff --git a/test/hbut-tests.el b/test/hbut-tests.el index 991f875fe0..f8a6574bb2 100644 --- a/test/hbut-tests.el +++ b/test/hbut-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-may-21 at 09:33:00 -;; Last-Mod: 8-Feb-24 at 15:38:21 by Mats Lidell +;; Last-Mod: 11-Feb-24 at 23:35:14 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -748,6 +748,9 @@ See #10 for the proper way to add an ibutton name. (should (ebut:act))) (mocklet ((ebut:is-p => nil)) (should-error (ebut:act 'button)) + (should-error (ebut:act))) + (progn + (hattr:clear 'hbut:current) (should-error (ebut:act)))) (ert-deftest hbut-tests--ibut-act-calls-hbut-act () @@ -760,6 +763,9 @@ See #10 for the proper way to add an ibutton name. (should (ibut:act))) (mocklet ((ibut:is-p => nil)) (should-error (ibut:act 'button)) + (should-error (ibut:act))) + (progn + (hattr:clear 'hbut:current) (should-error (ibut:act)))) ;; This file can't be byte-compiled without the `el-mock' package (because of