Bozhidar Batsov is back with a quick tip that many of you will probably find useful. It’s an improvement to keyboard-quit
or, as we all know and love it, Ctrl+g.
One of Batsov’s pet peeves is that keyboard-quit
doesn’t function as expected when the minibuffer is active. Happily that and a few other infelicities are easily fixed as he shows in his post. The code that Batsov presents in his post is short. It’s more comment than code yet it does fix the problems that were annoying Batsov.
Here, from the code comments, is what his improved code does:
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'."
You don’t have to edit Emacs source code. You simply include his function in your init.el
and remap Ctrl+g to it. It’s easy to try out his code and if you don’t like it, simply drop back to the default behavior by undoing the key sequence remapping.