diff --git a/ha-config.org b/ha-config.org index cd76b4c..50f1e47 100644 --- a/ha-config.org +++ b/ha-config.org @@ -98,6 +98,39 @@ And some Mac-specific settings: (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) (add-to-list 'default-frame-alist '(ns-appearance . dark))) #+end_src + +** Make C-g a little more useful + +Protesilaos has a simple fix for [[https://protesilaos.com/codelog/2024-11-28-basic-emacs-configuration/#h:1e468b2a-9bee-4571-8454-e3f5462d9321][closing minibuffer with C-g]]. His explanation: + +#+begin_quote +Do-What-I-Mean behaviour for a general 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. 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. + - When the Completions buffer is selected, close it. + - In every other case use the regular keyboard-quit. +#+end_quote + +And my copy of his code: + +#+begin_src emacs-lisp + (defun keyboard-quit-dwim () + "Cancel everything, even in the mini-buffer." + (interactive) + (cond + ((region-active-p) + (keyboard-quit)) + ((derived-mode-p 'completion-list-mode) + (delete-completion-window)) + ((> (minibuffer-depth) 0) + (abort-recursive-edit)) + (t + (keyboard-quit)))) + + (define-key global-map (kbd "C-g") #'keyboard-quit-dwim) +#+end_src + ** Emacs Everywhere After reading [[https://irreal.org/blog/?p=12139][Jon Sander’s essay]] as well as [[https://mbork.pl/2024-04-27_Emacs_everywhere][Marcin Borkowski's essay]], I decided to try out Tecosaur’s [[https://github.com/tecosaur/emacs-everywhere][Emacs Everywhere]] approach: