There are two issues at play here, both of which have to do with the terminal environment (tty):
Your terminal emulator (usually*) gets first dibs over any key combos that you enter, which can be a problem for any chords that happen to match a shortcut. For example, in terminator, C-M-w
renames a window even in emacs tty mode. (In my version of doom emacs gui, this appends from the kill ring.)
In this case, you won't have much choice except to find which shortcut could be interferring. I do not believe that is the main issue for the specific problem you listed though because 2) is more likely in play.
Terminal emulators sends characters not keystrokes. See this excellent discussion in the Unix SE for an overview. Also see further here that talks about making a terminal emulator to handle all key combos. But in summary: While it is possible to press a chord in emacs gui to enact some functionality and a different key for a different set of functionality, when we step into emacs tty, emacs could end up seeing the same characters on both keypresses. This is especially noticeable for chords involving any of the control keys**. In other words, the information that you pressed C
is lost.
There are not any easy fixes to number 2 because there aren't standard escape code messages for all terminals and key combos as far as I can tell. You could approach the problem in a few ways:
In ~/.Xresources
to define behaviours with C
, S
, and M
:
Term.VT100.translations: #override \n\
Ctrl ~Shift ~Meta <key>Return: string("\033[73;5~") \n\
Ctrl Shift ~Meta <key>percent: string("\033[37;6~")
Then in emacs, translate into mapping (the above uses number
representation to send in ESC [ n1 ; n2 ~
where n2 is the number we
get if we treat shift as 2, meta as 3, control as 5, control + meta as
7, or add 1 to the other number wherever we added shift to the combo.
(define-key local-function-key-map "\033[37;6~" [(control ?L)])
(define-key local-function-key-map "\033[37;6~" [(control ?L)])
*Not always though. Observe that you can enter C-d
in emacs tty mode and not close your session. If you exit emacs and do the same on the terminal, you close the session. This also holds for other common chords like C-c
and C-x
.
**But you may find control keys and chords which are not affected. Note how C-M-q
works in emacs tty for instance if you assign a chord to it.