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

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

[elpa] externals/transient 4de5812992 15/25: transient-scope: Fix recent


From: Jonas Bernoulli
Subject: [elpa] externals/transient 4de5812992 15/25: transient-scope: Fix recent regression
Date: Tue, 3 Dec 2024 14:35:02 -0500 (EST)

branch: externals/transient
commit 4de5812992ef93fcd80ef1d12a6e1db7f7cd315d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    transient-scope: Fix recent regression
    
    [1: d0cba152] failed to take into account that this function is also
    useful when setting up a prefix, in which case it should be called
    without an argument.
    
    Also clarify that the argument should be used when this function is
    called from a suffix command.
    
    1: 2024-11-22 d0cba152dc708b1cf9028539ac5204469057027b
       transient-scope: Add PREFIX argument
---
 CHANGELOG         |  4 +++-
 lisp/transient.el | 31 +++++++++++++++++--------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 544042c066..a3ca05086b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,7 +7,9 @@
 - Added documentation for ~inapt-if*~ slots to manual.  179545a6
 
 - ~transient-args~ and ~transient-scope~ now both take a prefix command or
-  a list of prefix commands as argument.
+  a list of prefix commands as argument.  ~transient-scope~ can still be
+  called without an argument, but that should only be done in functions
+  that take part in setting up a menu, not in a suffix command.
 
 - Added new generic function ~transient-prefix-value~, giving finer
   control over how the value returned by ~transient-args~ is determined.
diff --git a/lisp/transient.el b/lisp/transient.el
index 74c045a511..02f8352399 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -3728,24 +3728,27 @@ a default implementation, which is a noop.")
 ;;;; Get
 
 (defun transient-scope (&optional prefix)
-  "Return the scope of the transient prefix command PREFIX, or nil.
+  "Return the scope of the active or current transient prefix command.
 
-If the current command wasn't invoked from any prefix, return nil.
+If optional PREFIX is nil, return the scope of the active prefix; the
+prefix whose menu is active or being setup.  In suffix commands it is
+rarely, if ever, appropriate to call this function like this.
 
-If PREFIX is non-nil, it must a single prefix or a list of prefixes.
-If, and only if, the current prefix is one of these prefixes, return
-its scope, otherwise return nil.
-
-If PREFIX is nil (for backward compatibility it may also be omitted),
-return the scope of the current prefix, regardless of which prefix it
-is.  This usage is rarely appropriate; it is better to be explicit.
+If PREFIX is a prefix command or a list of such commands, then return
+its scope, if, and only if, either the active prefix or the prefix from
+which the current suffix command was invoked, is one of these prefixes.
+Otherwise return nil.
 
 Return the value of the corresponding object's `scope' slot."
-  (declare (advertised-calling-convention (prefix) "0.8.0"))
-  (and transient-current-command
-       (or (not prefix)
-           (memq transient-current-command (ensure-list prefix)))
-       (oref (transient-prefix-object) scope)))
+  (if prefix
+      ;; Prefer the current over the active prefix.  If the opposite is
+      ;; appropriate, one should call this function without an argument.
+      (and-let* ((obj (or transient-current-prefix transient--prefix)))
+        (and (memq (oref obj command)
+                   (ensure-list prefix))
+             (oref obj scope)))
+    (and transient--prefix
+         (oref transient--prefix scope))))
 
 ;;; History
 



reply via email to

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