In emacs23 how to bind C- <return> with C- <return> instead of CJ

I'm trying to use org-mode, and whenever I press Crtl + return emacs instead of CJ. I know this because when I use ch k and then press crtl + return, emacs shows "This is Cj related." Is there anyway I can register ctrl + return so that I can insert headers?

I am using emacs23 via terminal on ubuntu 12.04 x64. When I do this on my Windows machine, it inserts a new title.

0


source to share


3 answers


Maybe. As @phils says, this is C-Enterusually not a valid sequence for the vast majority of terminal emulators. This is because when you press a key or key combination, the terminal sends a sequence of characters to the appropriate application. A hit is asending a

, while a Enterhit CR

is a carriage return (otherwise known as ^M

, \r

or \015

).

What sequences are actually implemented in modern terminals is basically just hovering from the earlier physical terminals they emulate (in particular the VT-100). These machines were not allowed to be used Ctrlin conjunction with each key, such as function keys, so C-F1no escape sequence was possible or defined. Likewise, there is no control sequence for C-Enter, so when you press it, the terminal ignores Ctrland just sees Enter.



However, you can define your own escape sequences in your terminal, which you can then bind to the correct key combinations in emacs. See here for example. I was able to use this method to be able to use C-Enter. Unfortunately, this is still a bit painful as it requires a lot of configuration and you still might not use some sequences ( C-M-%doesn't work in konsole for me). As with @phils, I decided to use a GUI, but I would like to better integrate with my terminal.

+2


source


This is not a valid sequence for most terminals, I'm afraid, so they just can't send it to Emacs.

If you start GUI Emacs the key bindings will work.

Thomas Dickey xterm is the only terminal software I know of that can (I think) support all the normal Emacs bindings. If you agree with compiling this, you can try it with the following .Xdefaults-(hostname)

(or .Xresources

if you re-merge after editing) to get basic support:



XTerm*metaSendsEscape: true
XTerm*modifier: meta
XTerm*modifyOtherKeys: 1

      

You really need XTerm*modifyOtherKeys: 2

to fully expand the sequences (otherwise you still can't type such as C-M-%

), but by default this setting breaks most of the key sequences, and right now I couldn't tell you how to properly tweak the settings for this setting (the only one the example I saw - xterm-extras.el as stated on the wiki and available in the easymacs download - didn't work for me).

I mostly use GUI Emacs, but I would like this to work properly, so if anyone has any success with xterm-extras.el or similar, please do speak.

+2


source


If you want to install the Emacs package and customize your terminal, I wrote an Emacs package that can teach Emacs and terminals to correctly recognize all PC keyboard keys and modifier key combinations:

https://github.com/CyberShadow/term-keys

The default configuration allows you to encode a combination Ctrl Returnthat allows Emacs to distinguish it from Ctrl J.

0


source







All Articles