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

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

[elpa] externals/transient d33fe5abaf 101/366: Split new transient-get-v


From: Jonas Bernoulli
Subject: [elpa] externals/transient d33fe5abaf 101/366: Split new transient-get-value from transient-args
Date: Tue, 25 Jan 2022 18:54:31 -0500 (EST)

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

    Split new transient-get-value from transient-args
    
    Going forward `transient-args' is only intended for use by regular
    suffix commands that consume the arguments.
    
    The new `transient-get-value' is intended primarily for indirect use
    by special suffix commands that set or save the value.  More precisely
    by the methods `transient-set-value' and `transient-save-value', which
    are used by the commands `transient-set' and `transient-save' (as well
    as by the internal `transient--history-push').
---
 docs/transient.org |  9 ---------
 lisp/transient.el  | 29 +++++++++++------------------
 2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index b22710725a..a834d00bc9 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -1002,15 +1002,6 @@ function, which for infix arguments serves about the 
same purpose as
 
 - Function: transient-args &optional prefix
 
-  This function returns the value of the transient from which the
-  current suffix was called.  If the current suffix command was not
-  called from a transient, then it returns ~nil~.
-
-  If optional PREFIX is non-~nil~, then it should be a symbol, a
-  transient prefix command.  In that case the value of the transient
-  is only returned if the suffix was invoked from *that* transient.
-  Otherwise ~nil~ is returned.
-
 - 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 152397239a..39cb7874ac 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -2033,20 +2033,6 @@ around `scroll-down-command' (which see)."
          (message "No suspended transient command"))))
 
 ;;; Value
-;;;; Core
-
-(defun transient-args (&optional prefix)
-  "Return the value of the transient from which the current suffix was called.
-
-If optional PREFIX is non-nil, then it should be a symbol, a
-transient prefix command.  In that case only return the value
-of the transient if the suffix was actually invoked from that
-transient.  Otherwise return nil."
-  (and (or (not prefix)
-           (eq prefix current-transient-command))
-       (delq nil (mapcar 'transient-infix-value
-                         current-transient-suffixes))))
-
 ;;;; Init
 
 (cl-defgeneric transient-init-scope (obj)
@@ -2319,19 +2305,26 @@ commands."
       (cl-call-next-method obj value))))
 
 (cl-defmethod transient-set-value ((obj transient-prefix))
-  (oset (oref obj prototype) value (transient-args))
+  (oset (oref obj prototype) value (transient-get-value))
   (transient--history-push obj))
 
 ;;;; Save
 
 (cl-defmethod transient-save-value ((obj transient-prefix))
-  (let ((value (transient-args)))
+  (let ((value (transient-get-value)))
     (oset (oref obj prototype) value value)
     (setf (alist-get (oref obj command) transient-values) value)
     (transient-save-values))
   (transient--history-push obj))
 
-;;;; Use
+;;;; Get
+
+(defun transient-args (prefix)
+  (and (eq current-transient-command prefix)
+       (delq nil (mapcar 'transient-infix-value current-transient-suffixes))))
+
+(defun transient-get-value ()
+  (delq nil (mapcar 'transient-infix-value current-transient-suffixes)))
 
 (cl-defgeneric transient-infix-value (obj)
   "Return the value of the suffix object OBJ.
@@ -2401,7 +2394,7 @@ that.  Otherwise return the value of the `command' slot."
   "Push the current value of OBJ to its entry in `transient-history'."
   (let ((key (transient--history-key obj)))
     (setf (alist-get key transient-history)
-          (let ((args (transient-args)))
+          (let ((args (transient-get-value)))
             (cons args (delete args (alist-get key transient-history)))))))
 
 (cl-defgeneric transient--history-init (obj)



reply via email to

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