[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."
- [elpa] externals/transient updated (35bbc35929 -> 645f1b2cd4), Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient c9a62d5a16 10/25: Improve doc-strings of functions dealing with values, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient deb1569c9c 07/25: transient-prefix-value: New generic function,
Jonas Bernoulli <=
- [elpa] externals/transient c93c35f567 13/25: transient--show: Fix window height for more setups, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient aaefee0d01 03/25: Remove comments mentioning a legacy Emacs bug, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 3b28a2f8d6 12/25: transient-hide-during-minibuffer-read: Change default to t, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 3539231b98 20/25: fixup(e3e2e111): Improve options for showing menu during minibuffer use, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 645f1b2cd4 25/25: transient--stack-push: Preserve the value, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient d64b73efbc 17/25: transient-scope: Return nil if all prefixes are nil, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient ecdee415fb 16/25: transient-scope: Fully revert behavior with no argument, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient b3f3aa034a 09/25: transient-init-value: Define noop method for transient-suffix, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 4130f62966 11/25: transient--show: Run transient-setup-buffer-hook later, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 24a1be509b 02/25: docs: Fix word order, Jonas Bernoulli, 2024/12/03