branch: externals/transient commit 45fbefdc5b112f0a15cd936570b00629a9a2fda0 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Inhibit quitting while a menu is active Like the somewhat similar but much less complex `read-key-sequence', for example, Transient menus should inhibit quitting, otherwise C-g might, for example, kill some subprocess, when the user intended to exit the menu. Due to how Transient is implemented, there is nothing around which we could let-bind `inhibit-quit', like that is usually done. Instead we have to set the global value and make sure we reset that when exiting the menu. The resetting has to happen on `post-command-hook' but at that time a let-binding for `inhibit-quit' is in effect, so we have to use `set-default-toplevel-value', instead of `setq'. Closes #388. --- lisp/transient.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/transient.el b/lisp/transient.el index 40f8a60ac6..c3761973de 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -2649,6 +2649,7 @@ value. Otherwise return CHILDREN as is.") (add-hook 'pre-command-hook #'transient--pre-command 99) (add-hook 'post-command-hook #'transient--post-command) (advice-add 'recursive-edit :around #'transient--recursive-edit) + (set-default-toplevel-value 'inhibit-quit t) (when transient--exitp ;; This prefix command was invoked as the suffix of another. ;; Prevent `transient--post-command' from removing the hooks @@ -2988,6 +2989,8 @@ value. Otherwise return CHILDREN as is.") (setq transient--editp nil) (setq transient--all-levels-p nil) (setq transient--minibuffer-depth 0) + (setq quit-flag nil) + (set-default-toplevel-value 'inhibit-quit nil) (run-hooks 'transient-exit-hook) (when command (setq transient-current-prefix nil)