emacs: simplify prot-simple-keyboard-quit-dwim

This is how I used to have it. I am reverting to it because it is
easier for me to share it with people. Whereas the newer one can be
confusing.
This commit is contained in:
Protesilaos 2026-08-02 08:32:16 +03:00
parent 4dc4412c6e
commit 3cadbe03c8
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
2 changed files with 8 additions and 42 deletions

View file

@ -17860,32 +17860,15 @@ minibuffer, even without explicitly focusing it.
The DWIM behaviour of this command is as follows:
- When the region is active, disable it.
- When a minibuffer is open, but not focused, close the minibuffer. For
recursive minibuffers, make sure to only close one level of depth.
- When in a *Completions* or `special-mode' buffer (e.g. *Help* or
,*Messages*), close it.
- When the *Completions* or a `special-mode' buffer is on display but
not selected, close it. If there are more than one, close them all.
- When a minibuffer is open, but not focused, close the minibuffer.
- When the Completions buffer is selected, close it.
- In every other case use the regular `keyboard-quit'."
(interactive)
(cond
((region-active-p)
(keyboard-quit))
((and (derived-mode-p 'completion-list-mode 'special-mode)
(not (one-window-p)))
(quit-window))
((when-let* ((_ (not (one-window-p)))
(windows (seq-filter
(lambda (window)
(with-selected-window window
(derived-mode-p 'completion-list-mode 'special-mode)))
(window-list))))
(dolist (window windows)
(quit-window nil window))))
((derived-mode-p 'completion-list-mode)
(delete-completion-window))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(t

View file

@ -118,32 +118,15 @@ minibuffer, even without explicitly focusing it.
The DWIM behaviour of this command is as follows:
- When the region is active, disable it.
- When a minibuffer is open, but not focused, close the minibuffer. For
recursive minibuffers, make sure to only close one level of depth.
- When in a *Completions* or `special-mode' buffer (e.g. *Help* or
*Messages*), close it.
- When the *Completions* or a `special-mode' buffer is on display but
not selected, close it. If there are more than one, close them all.
- When a minibuffer is open, but not focused, close the minibuffer.
- When the Completions buffer is selected, close it.
- In every other case use the regular `keyboard-quit'."
(interactive)
(cond
((region-active-p)
(keyboard-quit))
((and (derived-mode-p 'completion-list-mode 'special-mode)
(not (one-window-p)))
(quit-window))
((when-let* ((_ (not (one-window-p)))
(windows (seq-filter
(lambda (window)
(with-selected-window window
(derived-mode-p 'completion-list-mode 'special-mode)))
(window-list))))
(dolist (window windows)
(quit-window nil window))))
((derived-mode-p 'completion-list-mode)
(delete-completion-window))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(t