I suspect this is some sort of magic terminal definition thing but I've noticed some magic keys not working on terminals. When I type M-RET to create a new item in org mode I instead get a newline. M-x describe-key reports seeing C-M-j instead.

Sure I could rebind C-M-j to do what's expected but I'd really like to know why there is a disconnect between what I type and what the remote terminal sees.

Edit:

gnome-terminal on Ubuntu Hardy Heron ssh'ing to Debian Stable running emacs23

link|improve this question

71% accept rate
2  
What terminal emulation program, what OS, Emacs version ,etc. FWIW on Terminal.app, OSX Leopard, Emacs 23, I get M-RET. – Richard Hoskins Aug 5 '09 at 17:00
feedback

2 Answers

up vote 1 down vote accepted

Does your Ubuntu setup have a strange keyboard layout or does it remap keys?

Go to System, then Preferences, and then Keyboard, and choose the Layouts tab. I find that Generic 104-key keyboard works the best as it includes the Win keys (I have the standard multimedia keys too and they still work). This seems to make things work no matter what terminal application I am using or whether I am SSH'ing.

Also, make sure that the Alt key isn't mapped to something by checking the Layout Options.

link|improve this answer
It seems to be a gnome-terminal thing as if I use rxvt I can get M-RET to work fine. I've also been unable to reset gnome-terminals default character encoding to UTF-8 but I think that is unrelated to the keybinding issue. In terms of layout I have it set to Microsoft Natural and a remapped Caps-Lock->Control. – stsquad Oct 7 '09 at 11:21
feedback

There's not really a disconnect. Behind the scenes there's really no such thing as an "enter" or a "return". There are carriage-return characters and new-line characters.

Carriage return is Ctrl-M. New-line is Ctrl-J.

So, a Meta-RET being reported as a Meta-Ctrl-J makes perfect sense.

link|improve this answer
Depends on the hardware and OS. Some systems are capable of distinguishing between Ctrl-J and RET keystrokes, and can generate different code sequences for them. – Loadmaster Nov 12 '09 at 22:50
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.