Terminals transmit bytes, not keys. Keychords like Ctrl+' have to be encoded as sequences of bytes. Apart from printable characters with no modifier or with just Shift, most keychords have no corresponding characters, and are instead transmitted as escape sequences, beginning with the escape character (the character with the byte value 27, which you can write as \e
in Emacs strings). But many keychords don't have a traditional standard escape sequence, and many terminals either don't transmit these keychords or strip information about modifiers (transmitting Ctrl+' as just the '
character).
Some terminals allow you to configure escape sequences for each keychord. In Terminal.app, you can do this from the keyboard preferences.
For Ctrl+', pick either \033[39;5~
or \033[27;5;39~
: these are two emerging standards, the libtermkey scheme and the xterm scheme. See Problems with keybindings when using terminal for more information.
Emacs translates escape sequences into its internal key representation through input-decode-map
or local-function-key-map
(or function-key-map
before Emacs 23). Put either of these in your init file:
(define-key input-decode-map "\033[39;5~" [(control ?\')])
(define-key input-decode-map "\033[27;5;39~" [(control ?\')])
'
is not one of them. As far as you know, can it be done in some.rc
file? – darksky Sep 14 '15 at 14:46