1
votes

Some emacs keyboard bindings that work in GUI mode won't work in terminal mode because the terminal only knows how to send ASCII control codes. Is there a way to get emacs to complain when I bind a key to a non-ASCII control code so I'll stop doing it by accident? I only run emacs in a terminal occasionally, and usually only remotely, and usually only because something is broken, which means I end up discovering this suckiness at the worst time.

I've also had experiences when remoting in, especially from one OS to another (e.g. Solaris -> Linux) where even modifier keys get remapped (esc <-> ctrl get swapped, or right alt works but left alt doesn't). Is there any way to detect when this is happening and swap my keyboard bindings appropriately?

Basically: it sucks that everytime I use emacs remotely in the terminal I get an inconsistent experience with the GUI, how can I change my emacs usage to prevent that.

1

1 Answers

1
votes

I don't know of a good way to do that: for one, it is not true that terminals can only send ASCII control codes, because they can encode pretty much anything via escape sequences (e.g. xterm sends a special escape sequences for, say, C-M-up, which Emacs then recognizes). So depending the set of events that the terminal is able to send to Emacs (and which Emacs is then able to recognize) depends on the terminal.

If you want to be really safe, you can limit yourself to bindings where the key sequence is described as a string (not a vector, and not something built via kbd), which basically means only ASCII chars (including control sequences) combined with Meta.