1

Is there a way to configure C-g (or some other key?) to not be usable as normal input in any context, part of a key binding, etc, and instead have it quit in more contexts? e.g. I'd like C-x C-g to quit immediately (instead of saying C-x C-g is undefined, then quitting)

  • 4
    I'm not sure I understand what you're actually trying to do. Can you explain how this causes a problem? In what context does it make any difference whether or not this message is printed? – Tyler Mar 26 '18 at 16:58
1
(advice-add #'undefined :override #'keyboard-quit)

It is a hack.

0

C-g isn't treated specially. Any undefined key will prompt the message "key is undefined". For example, with emacs -Q, C-c C-g and C-c a both give you that message.

If you really need to change this behaviour, you can define C-g explicitly:

(global-set-key (kbd "C-x C-g") 'keyboard-quit)

For what you're asking, you'll need to do this for every prefix key, and new prefix keys can be created by you, or by add-on packages. Which means I don't think there's a straightforward way to impose this globally.

You might have better success if you can explain why this behaviour is a problem for you; then we might be able to find a more general solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.