branch: externals/transient commit e88005d27634eb2bf6b57009c68820f67e90745c Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Replace transient--do-return when there is no outer prefix A suffix may explicitly be configured to return to the outer prefix even if there is no outer prefix. This may happen, for example, if a prefix is invoked directly, even though it usually is invoked via an outer prefix. `transient--do-return' itself already takes care to fall back to `transient--do-exit' behavior in this situation, but that does not affect to color used for the binding. By detecting this situation in `transient--make-predicate-map', we can also correct the color. --- lisp/transient.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lisp/transient.el b/lisp/transient.el index 846890b7a2..a7834724e4 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -2119,7 +2119,7 @@ of the corresponding object." ((slot-boundp obj 'transient) (pcase (list kind (transient--resolve-pre-command - (oref obj transient)) + (oref obj transient) nil t) return) (`(prefix t ,_) #'transient--do-recurse) (`(prefix nil ,_) #'transient--do-stack) @@ -2939,14 +2939,19 @@ exit." (oref transient--prefix transient-non-suffix) t)))) -(defun transient--resolve-pre-command (pre &optional resolve-boolean) - (cond ((booleanp pre) - (if resolve-boolean - (if pre #'transient--do-stay #'transient--do-warn) - pre)) - ((string-match-p "--do-" (symbol-name pre)) pre) - ((let ((sym (intern (format "transient--do-%s" pre)))) - (if (functionp sym) sym pre))))) +(defun transient--resolve-pre-command (pre &optional resolve-boolean correct) + (setq pre (cond ((booleanp pre) + (if resolve-boolean + (if pre #'transient--do-stay #'transient--do-warn) + pre)) + ((string-match-p "--do-" (symbol-name pre)) pre) + ((let ((sym (intern (format "transient--do-%s" pre)))) + (if (functionp sym) sym pre))))) + (cond ((not correct) pre) + ((and (eq pre 'transient--do-return) + (not transient--stack)) + 'transient--do-exit) + (pre))) (defun transient--do-stay () "Call the command without exporting variables and stay transient."