1

I tried to use a following

(global-set-key (kbd "C-[") nil)

but it also disables M-x. How can I properly disable it?

Jānis Erdmanis
  • 393
  • 3
  • 11
  • You can't: The Esc key is tied to 【Ctrl+[】 and Meta. Except if you have an azerty keyboard: `(global-set-key (kbd "C-M-(") nil)` – djangoliv Oct 28 '15 at 12:49

1 Answers1

1

See this answer, which should solve your problem.


A second possibility is to selectively remap this key combination for Emacs but outside Emacs. The options available for this will depend on your operating system. On Windows, you could do this with AutoHotkey pretty easily. If you're on Linux, you might take a look at this answer.


(This is the previous content of my answer, moved here because it is less helpful than the above but may still be of interest.)

If you don't care about the Esc key per se, you may be able to sever the link between this pair of keys and Meta by setting meta-prefix-char, but a little bit of fiddling around has convinced me that this isn't as straightforward as simply setting the variable.

Specifically, I tried setting meta-prefix-char to nil. Following advice in @lawlist's comment on this question, I did so as early as possible in initialization to make sure all the keymaps got the hint, but some keybindings (most notably C-M-x in lisp-interaction-mode) were unexpectedly unbound, and I was getting many unexpected errors. It may be possible to sort all this out, but it's probably not worth the effort. Binding meta-prefix-char to an alternative key will probably work better, but your options are limited to single ASCII characters, none of which seem more appealing to me than C-[.

Aaron Harris
  • 2,664
  • 17
  • 22