Take the 2-minute tour ×

I want to bind "C-[" like so:

(define-key py-mode-map "\C-["  'py-shift-region-left)

The problem is, Emacs sees "C-[" as ESC. Am I missing something?

share|improve this question
The function describe-key confirms this: (describe-key [?\C-\[]). I've been searching around, looking for an answer, and so far can't find an answer. –  seh Dec 27 '09 at 15:17
add comment

1 Answer

Well, as it happens, "\C-[" and ESC are the same character. They are also being reported as the same by xkbwatch, which leads me to believe that X is reporting those keypresses to applications in the same way, so there's nothing to be done on the Emacs side of things. As for somehow making "\C-[" not act like ESC at a lower level, unfortunately I've no idea, I always considered it a pinky-saving feature.

share|improve this answer
Note that I see the same effect using GNU Emacs on Windows, not involving X in any way. Remapping at the X level may offer a way around this problem, but it seems that Emacs has some assumptions built in that must be overcome as well. –  seh Dec 27 '09 at 15:56
And the same effect on Linux console, too. –  Wei Hu Dec 30 '09 at 6:31
add comment

Your Answer


