mirror of
https://github.com/protesilaos/dotfiles.git
synced 2026-09-10 07:16:20 -04:00
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:
parent
4dc4412c6e
commit
3cadbe03c8
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue