From b17aaed7b214da62a6f3f21073cac25d7e71b4f5 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 20 Jun 2025 10:49:11 +0200 Subject: [PATCH] feat: Make keyboard-quit smarter --- init.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/init.el b/init.el index 1157f8e..4069dfa 100644 --- a/init.el +++ b/init.el @@ -1182,6 +1182,22 @@ :config (which-function-mode 1) + ;; Taken from https://emacsredux.com/blog/2025/06/01/let-s-make-keyboard-quit-smarter/ + (defun er-keyboard-quit () + "Smater version of the built-in `keyboard-quit'. + +The generic `keyboard-quit' does not do the expected thing when +the minibuffer is open. Whereas we want it to close the +minibuffer, even without explicitly focusing it." + (interactive) + (if (active-minibuffer-window) + (if (minibufferp) + (minibuffer-keyboard-quit) + (abort-recursive-edit)) + (keyboard-quit))) + + (global-set-key [remap keyboard-quit] #'er-keyboard-quit) + (defun my/which-func-try-to-enable () (unless (or (not which-function-mode) (local-variable-p 'which-func-mode)) -- 2.49.0