tags:

views:

542

answers:

4

Normally keyboard-escape-quit is bound to EscEscEsc. Is it possible to rebind it to a single Esc? I never use Escape as a prefix key.

I'm running Emacs 23.0.60.1 on Windows XP.

+1  A: 

You can do it, but at the expense of killing the Esc prefix key map The code to do this is (global-set-key "" 'keyboard-escape-quit) where the funny char is is escape (use ^Q esc to type it in) it will map esc for you but the rest of the keymap is gone after that

jottos
You can avoid typing the funny character by doing (global-set-key (kbd "ESC") 'keyboard-escape-quit), but it is not as simple as that: at least on my Emacs (22.3.1 on a Mac, Carbon version 1.6.0) ESC doesn't work as the quit key, but all meta keystrokes (even using Cmd) stop working.
Jouni K. Seppänen
ya, that's the behavior on Win32 Emacs 22.0.99
jottos
A: 

You can do it, but at the expense of killing the Esc prefix key map The code to do this is (global-set-key "" 'keyboard-escape-quit) where the funny char is is escape (use ^Q esc to type it in) it will map esc for you but the rest of the keymap is gone after that

jottos
OK, I think I've found a bug, this seems to have posted twice
jottos
+2  A: 

Not to say this is right for you, but when I had this problem I taught myself to press Ctrl-g instead, which is also bound to keyboard-escape-quit by default. For me, this has the advantage of keeping my left hand pretty close to the home position, as well as leaving my Esc prefix intact.

Edit: After reading through the linked page, it's not bound to exactly the same function, and on Windows Ctrl-g can't forcibly interrupt a running command, but Ctrl-g covers 99% of what I would use Esc Esc Esc for --- aborting a command that I screwed up entering.

Chris Connett
I never use `keyboard-escape-quit`, I use C-g. Can't say I reach for C-[, which would be the other part of the functionality to mimic ESC ESC ESC.
ashawley
I'll try to use C-g to not to leave the home position but Esc is already burned into my brain as "get me back to where I was" so I need it. Otherwise I press Esc -> nothing happens -> I feel unhappy.
Pavel Chuchuva
+5  A: 

Rehashing other's answer, I have

(global-set-key (kbd "<escape>")      'keyboard-escape-quit)

in my .emacs file, and it works on my emacs 22 on WinXP. I also hate typing 3 ESC in a row; and from years of (windows) habits my finger goes so naturally to the escape key for getting out of anything unpleasant.

polyglot