[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient e90f7a165e 335/366: Add support for returning
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient e90f7a165e 335/366: Add support for returning from a sub-prefix to the parent prefix |
Date: |
Tue, 25 Jan 2022 18:54:52 -0500 (EST) |
branch: externals/transient
commit e90f7a165e05b80846781823d23e8b078d4bb142
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Add support for returning from a sub-prefix to the parent prefix
---
docs/transient.org | 35 +++++++++++++++++++++++++++++++++--
lisp/transient.el | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/docs/transient.org b/docs/transient.org
index 798c27dd46..7cf0c6a95d 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -1193,16 +1193,47 @@ The default for suffixes is ~transient--do-exit~.
Call the command after exporting variables and exit the transient.
+- Function: transient--do-return ::
+
+ Call the command after exporting variables and return to parent
+ prefix. If there is no parent prefix, then call ~transient--do-exit~.
+
- Function: transient--do-call ::
Call the command after exporting variables and stay transient.
+The following pre-commands are suitable for sub-prefixes. Only the
+first should ever explicitly be set as the value of the ~transient~
+slot.
+
+- Function: transient--do-recurse ::
+
+ Call the transient prefix command, preparing for return to active
+ transient.
+
+ Whether we actually return to the parent transient is ultimately
+ under the control of each invoked suffix. The difference between
+ this pre-command and ~transient--do-replace~ is that it changes the
+ value of the ~transient-suffix~ slot to ~transient--do-return~.
+
+ If there is no parent transient, then only call this command and
+ skip the second step.
+
- Function: transient--do-replace ::
Call the transient prefix command, replacing the active transient.
- This is used for suffixes that are prefixes themselves, i.e. for
- sub-prefixes.
+ Unless ~transient--do-recurse~ is explicitly used, this pre-command
+ is automatically used for suffixes that are prefixes themselves,
+ i.e. for sub-prefixes.
+
+- Function: transient--do-suspend ::
+
+ Suspend the active transient, saving the transient stack.
+
+ This is used by the command ~transient-suspend~ and optionally also by
+ "external events" such as ~handle-switch-frame~. Such bindings should
+ be added to ~transient-predicate-map~.
*** Pre-commands for Non-Suffixes
:PROPERTIES:
diff --git a/lisp/transient.el b/lisp/transient.el
index 9addbafa4c..1b1e53400a 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -524,6 +524,15 @@ These faces are only used if `transient-semantic-coloring'
"Face used for teal prefixes."
:group 'transient-color-faces)
+(defface transient-purple
+ '((t :inherit transient-key :foreground "#a020f0"))
+ "Face used for purple prefixes.
+
+This is an addition to the colors supported by Hydra. It is
+used by suffixes that quit the current prefix but return to
+the previous prefix."
+ :group 'transient-color-faces)
+
;;; Persistence
(defun transient--read-file-contents (file)
@@ -1760,6 +1769,7 @@ value. Otherwise return CHILDREN as is."
:level (or (alist-get t (alist-get name
transient-levels))
transient-default-level)
params))))
+ (transient--setup-recursion obj)
(transient-init-value obj)
obj))
@@ -2235,12 +2245,34 @@ nil) then do nothing."
(transient--export)
transient--stay)
+(defun transient--do-return ()
+ "Call the command after exporting variables and return to parent prefix.
+If there is no parent prefix, then behave like `transient--do-exit'."
+ (if (not transient--stack)
+ (transient--do-exit)
+ (transient--export)
+ transient--exit))
+
(defun transient--do-exit ()
"Call the command after exporting variables and exit the transient."
(transient--export)
(transient--stack-zap)
transient--exit)
+(defun transient--do-recurse ()
+ "Call the transient prefix command, preparing for return to active transient.
+If there is no parent prefix, then just call the command."
+ (transient--do-replace))
+
+(defun transient--setup-recursion (prefix-obj)
+ (when transient--stack
+ (let ((command (oref prefix-obj command)))
+ (when-let ((suffix-obj (transient-suffix-object command)))
+ (when (and (slot-boundp suffix-obj 'transient)
+ (eq (oref suffix-obj transient)
+ 'transient--do-recurse))
+ (oset prefix-obj transient-suffix 'transient--do-return))))))
+
(defun transient--do-replace ()
"Call the transient prefix command, replacing the active transient."
(transient--export)
@@ -2283,7 +2315,9 @@ to `transient--do-warn'."
(put 'transient--do-warn 'transient-color 'transient-red)
(put 'transient--do-warn-inapt 'transient-color 'transient-red)
(put 'transient--do-call 'transient-color 'transient-red)
+(put 'transient--do-return 'transient-color 'transient-purple)
(put 'transient--do-exit 'transient-color 'transient-blue)
+(put 'transient--do-recurse 'transient-color 'transient-red)
(put 'transient--do-replace 'transient-color 'transient-blue)
(put 'transient--do-suspend 'transient-color 'transient-blue)
(put 'transient--do-quit-one 'transient-color 'transient-blue)
@@ -3703,6 +3737,7 @@ search instead."
'transient-red
'transient-blue))))
(pcase (list suffix nonsuf)
+ (`(transient-purple ,_) 'transient-purple)
(`(transient-red disallow) 'transient-amaranth)
(`(transient-blue disallow) 'transient-teal)
(`(transient-red transient-red) 'transient-pink)
- [elpa] externals/transient d85eb790e8 235/366: transient-read-directory: Pass read value through file-local-name, (continued)
- [elpa] externals/transient d85eb790e8 235/366: transient-read-directory: Pass read value through file-local-name, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 48238bf580 236/366: Allow invoking arbitrary prefixes as non-suffixes, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a3b442243b 241/366: transient-read-{, existing-}file: New functions, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient c4bf4af655 020/366: transient--show-manpage: Fix jumping to argument, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient e4ffb97a68 018/366: transient--layout-member: Match indirect key bindings, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2d8ceff408 185/366: transient-setup: Add emergency exit, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 601ebf5547 262/366: Quote value of slots' :initform when defining classes, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b526b9c735 281/366: transient-infix-set: Consider all incompatibility rules, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 459e28e28a 311/366: Add lisp-imenu-generic-expression entry, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 1a1ae03600 324/366: Remove transient--pre-command later, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient e90f7a165e 335/366: Add support for returning from a sub-prefix to the parent prefix,
Jonas Bernoulli <=
- [elpa] externals/transient 8b1f8dcc51 354/366: transient--minibuffer-depth: Must always be a number, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 5762bd9a06 341/366: transient-hide-during-minibuffer-read: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient de5a325616 349/366: Re-align debug declarations, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6103f168aa 347/366: transient--describe-function: Deal with anonymous infix arguments, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4477555b17 366/366: transient--post-exit: Deal with unbound transient slot properly, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient ad7f255308 116/366: For popups set tab-line-format to nil, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 0ad64ddc5d 010/366: transient-remove-suffix: Fix removal of last child of a group, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient f2ef69cfcc 176/366: transient--get-predicate-for: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient f2252d53b6 188/366: Support delaying setup of suffixes until prefix invocation, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a3e536333e 189/366: Support anonymous non-infix suffixes, Jonas Bernoulli, 2022/01/25