3

Looking for a new convenient keybinding for a frequently used command I stumbled upon Ctrl-M which is the same as Return/Enter.

What is the point of this binding? Can it cause some problem if I overwrite it?

Tom
  • 1,260
  • 8
  • 16
  • This recent related Q&A might also be helpful: https://emacs.stackexchange.com/a/52328/454 – phils Sep 05 '19 at 21:40

1 Answers1

3

ASCII control character Control M is a carriage-return character. It is return, and its ASCII name is RET. That's the reason why C-m in Emacs is RET.

In terminal mode (no graphic display) Emacs does not have a <return> (pseudo-)function key. There is only the RET key, also known as C-m.

In a graphic-display Emacs has both a <return> key and a RET (C-m) key. You can bind either of them to whatever command you like.

If <return> is not explicitly bound then when you use <return> the binding of RET takes effect.

This is for convenience - it's the same principle that lets key M act as key m if m is bound to a command and M is not explicitly bound to a command.


As @phils mentioned in a comment here, see also C-h i g (elisp)Function Keys.

Drew
  • 77,472
  • 10
  • 114
  • 243
  • So I if used Emacs in terminal (I don't) then I shouldn't rebind C-m, because then RET wouldn't work either? – Tom Sep 05 '19 at 17:36
  • If you rebind C-m then you've just rebound RET. They are the same thing. Whether rebinding it breaks something or not is another question. It likely won't "break" anything, but sometimes when you think RET (C-m) will do one thing it might do another instead. It depends on the keymap you rebind it in etc. – Drew Sep 05 '19 at 18:25
  • See also: C-h i g (elisp)Function Keys – phils Sep 05 '19 at 21:37
  • @phils: Thx; I added that to the answer. – Drew Sep 06 '19 at 00:18