summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2024-11-22 22:45:14 +0100
committerJonas Bernoulli <jonas@bernoul.li>2024-11-22 22:45:14 +0100
commitdeb1569c9c1dcb2e15e0654ba2d5fe1e4018ad0a (patch)
tree3ec59bf9a455db0930bb17dd2208e9ecccededb8 /lisp
parentd0cba152dc708b1cf9028539ac5204469057027b (diff)
transient-prefix-value: New generic function
Diffstat (limited to 'lisp')
-rw-r--r--lisp/transient.el20
1 files changed, 18 insertions, 2 deletions
diff --git a/lisp/transient.el b/lisp/transient.el
index 4d6a841..fa96506 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."