diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-05-29 18:31:50 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-05-29 18:31:50 +0200 |
| commit | 45fbefdc5b112f0a15cd936570b00629a9a2fda0 (patch) | |
| tree | c5a9ad80c73367b2fbe5a8435f9b6c5cd94318fe | |
| parent | df5856bb960933c91ec391de79f75ecd2cb55e52 (diff) | |
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.
| -rw-r--r-- | lisp/transient.el | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/transient.el b/lisp/transient.el index 40f8a60..c376197 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) |
