emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/transient 48238bf580 236/366: Allow invoking arbitrary


From: Jonas Bernoulli
Subject: [elpa] externals/transient 48238bf580 236/366: Allow invoking arbitrary prefixes as non-suffixes
Date: Tue, 25 Jan 2022 18:54:44 -0500 (EST)

branch: externals/transient
commit 48238bf580c0a3e8ea05ffc5ee86eb104404ea3b
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Allow invoking arbitrary prefixes as non-suffixes
    
    When a prefix is explicitly added as a suffix of another "outer"
    prefix, then the `transient--do-replace' pre-command function is
    added to the predicate map by `transient--make-predicate-map',
    which is aware that this is a sub-prefix.
    
    When the "outer" prefix allows arbitrary non-suffix commands to
    be invoked while it is active, by setting `transient-non-suffix'
    to `transient--do-stay' or `transient--do-call', then there is no
    opportunity to configure another predicate for commands that happen
    to be prefixes.
    
    This results in a pre-command being called that is not appropriate
    for a sub-prefix command because it fails to clean up after the
    "outer" prefix command.  In particular it fails to remove the active
    transient keymaps before adding new keymaps of the new prefix.
    
    That causes them to stick around forever.  The redisplay keymap ends
    up consume certain key events, such as "C-x", without unreading them
    again so that the real bindings can be looked up.
    
    We deal with this by teaching the code that sets up a prefix to check
    whether a transient keymap (`transient--transient-map') is still in
    effect and if so to take this as a sign that the above is what has
    happened and to clean up accordingly.
---
 lisp/transient.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/transient.el b/lisp/transient.el
index 592ae654a4..51106e7e30 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1633,6 +1633,12 @@ EDIT may be non-nil."
       (transient--pop-keymap 'transient--redisplay-map)
       (setq name (oref transient--prefix command))
       (setq params (list :scope (oref transient--prefix scope))))
+     (transient--transient-map
+      ;; Invoked as a ":transient-non-suffix 'transient--do-{stay,call}"
+      ;; of an outer prefix.  Unlike the usual `transient--do-replace',
+      ;; these predicates fail to clean up after the outer prefix.
+      (transient--pop-keymap 'transient--transient-map)
+      (transient--pop-keymap 'transient--redisplay-map))
      ((not (or layout                      ; resuming parent/suspended prefix
                transient-current-command)) ; entering child prefix
       (transient--stack-zap))              ; replace suspended prefix, if any



reply via email to

[Prev in Thread] Current Thread [Next in Thread]