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

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

[elpa] externals/transient a6ce1950e4 102/366: transient-args: Fall back


From: Jonas Bernoulli
Subject: [elpa] externals/transient a6ce1950e4 102/366: transient-args: Fall back to set, saved or default value
Date: Tue, 25 Jan 2022 18:54:31 -0500 (EST)

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

    transient-args: Fall back to set, saved or default value
---
 docs/transient.org |  8 ++++++++
 lisp/transient.el  | 14 ++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index a834d00bc9..721ed28a63 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -1002,6 +1002,14 @@ function, which for infix arguments serves about the 
same purpose as
 
 - Function: transient-args &optional prefix
 
+  This function returns the value of the transient prefix command
+  PREFIX.
+
+  If the current command was invoked from the transient prefix command
+  PREFIX, then it returns the active infix arguments.  If the current
+  command was not invoked from PREFIX, then it returns the set, saved
+  or default value for PREFIX.
+
 - Variable: current-transient-suffixes
 
   The suffixes of the transient from which this suffix command was
diff --git a/lisp/transient.el b/lisp/transient.el
index 39cb7874ac..f1dd34954e 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -2320,8 +2320,18 @@ commands."
 ;;;; Get
 
 (defun transient-args (prefix)
-  (and (eq current-transient-command prefix)
-       (delq nil (mapcar 'transient-infix-value current-transient-suffixes))))
+  "Return the value of the transient prefix command PREFIX.
+If the current command was invoked from the transient prefix
+command PREFIX, then return the active infix arguments.  If
+the current command was not invoked from PREFIX, then return
+the set, saved or default value for PREFIX."
+  (if (eq current-transient-command prefix)
+      (delq nil (mapcar 'transient-infix-value current-transient-suffixes))
+    (let ((transient--prefix nil)
+          (transient--layout nil)
+          (transient--suffixes nil))
+      (transient--init-objects prefix nil nil)
+      (delq nil (mapcar 'transient-infix-value transient--suffixes)))))
 
 (defun transient-get-value ()
   (delq nil (mapcar 'transient-infix-value current-transient-suffixes)))



reply via email to

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