[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient cb5e1e5594 18/25: transient-scope: Redesign
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient cb5e1e5594 18/25: transient-scope: Redesign |
Date: |
Tue, 3 Dec 2024 14:35:02 -0500 (EST) |
branch: externals/transient
commit cb5e1e5594926333327705b1130f58a25d0ca4c8
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient-scope: Redesign
---
lisp/transient.el | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 911a34d0c7..c582b455da 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -3727,26 +3727,39 @@ a default implementation, which is a noop.")
;;;; Get
-(defun transient-scope (&optional prefix)
+(defun transient-scope (&optional prefixes)
"Return the scope of the active or current transient prefix command.
-If optional PREFIX is nil, return the scope of the active prefix; the
-prefix whose menu is active or being setup. In suffix commands it is
-rarely, if ever, appropriate to call this function like this.
-
-If PREFIX is a prefix command or a list of such commands, then return
-its scope, if, and only if, either the active prefix or the prefix from
-which the current suffix command was invoked, is one of these prefixes.
-Otherwise return nil.
-
-Return the value of the corresponding object's `scope' slot."
- (if prefix
- ;; Prefer the current over the active prefix. If the opposite is
- ;; appropriate, one should call this function without an argument.
- (and-let* ((obj (or transient-current-prefix transient--prefix)))
- (and (memq (oref obj command)
- (ensure-list prefix))
- (oref obj scope)))
+If optional PREFIXES is nil, return the scope of the prefix currently
+being setup, making this variant useful, e.g., in `:if*' predicates.
+If no prefix is being setup, but the current command was invoked from
+some prefix, then return the scope of that.
+
+When this function is called from the body or `interactive' form of a
+suffix command, PREFIXES should be non-nil.
+
+If PREFIXES is non-nil, it must be a prefix command or a list of such
+commands. In this case try the following in order:
+
+- If the current suffix command was invoked from a prefix, which
+ appears in PREFIXES, then return the scope of that prefix.
+
+- If a prefix is being setup and it appears in PREFIXES, then return
+ its scope.
+
+- Finally try to return the default scope of the first prefix in
+ PREFIXES. This only works if that slot is set in the respective
+ class definition or using its `transient-init-scope' method.
+
+If no prefix matches, return nil."
+ (if prefixes
+ (let ((prefixes (ensure-list prefixes)))
+ (if-let* ((obj (or (and-let* ((obj transient-current-prefix))
+ (and (memq (oref obj command) prefixes) obj))
+ (and-let* ((obj transient--prefix))
+ (and (memq (oref obj command) prefixes) obj)))))
+ (oref obj scope)
+ (oref (transient--init-prefix (car prefixes)) scope)))
(and-let* ((obj (transient-prefix-object)))
(oref obj scope))))
- [elpa] externals/transient b3f3aa034a 09/25: transient-init-value: Define noop method for transient-suffix, (continued)
- [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
- [elpa] externals/transient d0cba152dc 06/25: transient-scope: Add PREFIX argument, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 75f0aef8d7 04/25: Add new "Scope" top-level section, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 9259f77e14 05/25: transient-args: Allow PREFIX to be a list of prefixes, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 6b83a02151 08/25: transient-init-scope: Add stub method for prefixes, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 37be15575a 23/25: fixup(e3e2e111): Improve options for showing menu during minibuffer use, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 4de5812992 15/25: transient-scope: Fix recent regression, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 51f25c21b8 24/25: Fix typos in documentation, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient cb5e1e5594 18/25: transient-scope: Redesign,
Jonas Bernoulli <=
- [elpa] externals/transient 23cb5b109d 22/25: transient-prefix: Add mode-line-format slot, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient e3e2e1112f 19/25: Improve options for showing menu during minibuffer use, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 7e50a8fa8e 14/25: Check validity of transient-display-buffer-action, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 590181262b 21/25: transient-prefix: Add display-action slot, Jonas Bernoulli, 2024/12/03
- [elpa] externals/transient 32e8150226 01/25: Use mapcan instead of cl-mapcan, Jonas Bernoulli, 2024/12/03