emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 4bf1bc3ca2 126/143: Check ebut:act and ibut:a


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 4bf1bc3ca2 126/143: Check ebut:act and ibut:act is called with the right but category
Date: Mon, 19 Feb 2024 15:59:26 -0500 (EST)

branch: externals/hyperbole
commit 4bf1bc3ca26c3e9ff997904b806f249a0ee9f2a5
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: Mats Lidell <mats.lidell@lidells.se>

    Check ebut:act and ibut:act is called with the right but category
---
 ChangeLog          |  8 ++++++--
 hbut.el            | 14 +++++++++++---
 test/hbut-tests.el | 24 +++++++++++++++++++-----
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 58c8369af7..b7aa2d4fec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,17 @@
 2024-02-08  Mats Lidell  <matsl@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.
+    (hbut-tests--ibut-act-calls-hbut-act): Add test for new act functions
+    with error cases.
 
 * hui-menu.el (hui-menu-explicit-buttons): Use ebut:act-label.
 
 * hbut.el (ibut:act-label, ebut:act-label): Rename ebut:act and ibut:act
     since they take a label as arg.
-    (ebut:act, ibut:act): Add new act functions taking a hbut as arg.
+    (ebut:act, ibut:act): Add new act functions taking a hbut as
+    arg. Allow only to be called with ebut or ibut respectively. If
+    falling back on hbut:current check that it is of the same type as the
+    call.
 
 * test/hyrolo-tests.el: Make hide tests more forgiving about hiding
     section headers. Allows test cases to be used with different versions
diff --git a/hbut.el b/hbut.el
index 18592c5b0d..22c27d55c2 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:      2-Feb-24 at 22:11:13 by Mats Lidell
+;; Last-Mod:      8-Feb-24 at 15:39:49 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -128,7 +128,11 @@ Default is the symbol hbut:current."
   (interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole 
button: "
                                                 (ebut:alist)
                                                 nil t nil 'hbut))))
-  (hbut:act 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")))
 
 (defun    ebut:act-label (label)
   "Activate Hyperbole explicit button with LABEL from the current buffer."
@@ -1706,7 +1710,11 @@ Default is the symbol hbut:current."
   (interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole 
button: "
                                                 (ibut:alist)
                                                 nil t nil 'hbut))))
-  (hbut:act 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")))
 
 (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 09ab17d3cf..991f875fe0 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    30-may-21 at 09:33:00
-;; Last-Mod:      2-Feb-24 at 22:16:49 by Mats Lidell
+;; Last-Mod:      8-Feb-24 at 15:38:21 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -740,13 +740,27 @@ See #10 for the proper way to add an ibutton name.
 
 (ert-deftest hbut-tests--ebut-act-calls-hbut-act ()
   "Verify `ebut:act' calls `hbut:act'."
-  (mocklet (((hbut:act 'button) => t))
-    (should (ebut:act 'button))))
+  (mocklet (((hbut:act 'button) => t)
+            ((ebut:is-p 'button) => t))
+    (should (ebut:act 'button)))
+  (mocklet (((hbut:act 'hbut:current) => t)
+            ((ebut:is-p 'hbut:current) => t))
+    (should (ebut:act)))
+  (mocklet ((ebut:is-p => nil))
+    (should-error (ebut:act 'button))
+    (should-error (ebut:act))))
 
 (ert-deftest hbut-tests--ibut-act-calls-hbut-act ()
   "Verify `ibut:act' calls `hbut:act'."
-  (mocklet (((hbut:act 'button) => t))
-    (should (ibut:act 'button))))
+  (mocklet (((hbut:act 'button) => t)
+            ((ibut:is-p 'button) => t))
+    (should (ibut:act 'button)))
+  (mocklet (((hbut:act 'hbut:current) => t)
+            ((ibut:is-p 'hbut:current) => t))
+    (should (ibut:act)))
+  (mocklet ((ibut:is-p => nil))
+    (should-error (ibut:act 'button))
+    (should-error (ibut:act))))
 
 ;; This file can't be byte-compiled without the `el-mock' package (because of
 ;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]