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

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

[elpa] externals/transient deb1569c9c 07/25: transient-prefix-value: New


From: Jonas Bernoulli
Subject: [elpa] externals/transient deb1569c9c 07/25: transient-prefix-value: New generic function
Date: Tue, 3 Dec 2024 14:35:01 -0500 (EST)

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

    transient-prefix-value: New generic function
---
 CHANGELOG         |  3 +++
 lisp/transient.el | 20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 575580edc0..a301438cb1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,9 @@
 - ~transient-args~ and ~transient-scope~ now both take a prefix command or
   a list of prefix commands as argument.
 
+- Added new generic function ~transient-prefix-value~, giving finer
+  control over how the value returned by ~transient-args~ is determined.
+
 Bug fixes:
 
 - Fixes some menu navigation edge-cases.
diff --git a/lisp/transient.el b/lisp/transient.el
index 4d6a841df9..fa965060e2 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -3548,10 +3548,26 @@ was not invoked from PREFIX, then return the set, saved 
or default value
 for PREFIX.
 
 PREFIX may also be a list of prefixes.  If no prefix is active, the
-fallback value of the first of these prefixes is used."
+fallback value of the first of these prefixes is used.
+
+The generic function `transient-prefix-value' is used to determine the
+returned value."
   (when (listp prefix)
     (setq prefix (car (or (memq transient-current-command prefix) prefix))))
-  (mapcan #'transient--get-wrapped-value (transient-suffixes prefix)))
+  (if-let ((obj (get prefix 'transient--prefix)))
+      (transient-prefix-value obj)
+    (error "Not a transient prefix: %s" prefix)))
+
+(cl-defgeneric transient-prefix-value (obj)
+  "Return the value of the prefix object OBJ.
+This function is used by `transient-args'.")
+
+(cl-defmethod transient-prefix-value ((obj transient-prefix))
+  "Return a list of the values of the suffixes the prefix object OBJ.
+Use `transient-infix-value' to collect the values of individual suffix
+objects."
+  (mapcan #'transient--get-wrapped-value
+          (transient-suffixes (oref obj command))))
 
 (defun transient-suffixes (prefix)
   "Return the suffix objects of the transient prefix command PREFIX."



reply via email to

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