Configuring Terminal to accept [<Control>-<Return>] - macos

I'm using org-mode in emacs on MacOS X Lion (10.7). One of the commands to use is (i.e. the control key, chorded with the return key). When I press this nothing happens. Doing some further investigation, I found that emacs is just receiving the return NOT the ctrl modifier key along with it. I know this because I did a C-q (i.e. control-letter 'q') and then tried to do a C-RETURN, with just the RETURN showing up.
I used the keyboard viewer to confirm that I am really pressing C-RETURN. Is there a way to configure Terminal.app (or my system) to send/accept C-Return?

Terminal's keyboard map preference won't let you map the Return key. However, you can map one of the supported keys to send the input sequence that you expect Control-Return to send.
You want to send the sequence:
ESC [ 2 7 ; 5 ; 1 3 ~
(In Terminal preferences, when you type ESC it is displayed numerically as "\003".)
That's what emacs displays for <C-return> if you enter M-x describe-bindings.
Note that in Emacs 22.1.1 (the version installed with 10.8.3) org-mode has a mapping for Meta-Return, but not Control-Return. Are you sure you didn't mean Meta?

Related

Clear prompt on Esc in OS X Terminal

Clearing prompt in OS X Terminal is really annoying. We have ctrl+u to clear before cursor and ctrl+k to clear after cursor. Is there any way to clear whole prompt with esc key, like in Windows?
The built in options are either Ctrl + AK to go to the beginning of the line and clear it or Ctrl + C to cancel the current command.
If you go into your Terminal settings and look under Profiles > Keyboard you'll see the interface for creating custom keyboard shortcuts. Just create a new shortcut and set it to Send Text '\001\013' (or hit whatever command keys you want to use) and bind it to whatever key/combo you want.

<tab> v. TAB in emacs

I'm using emacs 24.3 in the OS X terminal, and have run into something strange.
In markdown-mode.el, the tab key is bound to a specific function in the keymap via (define-key map (kbd "<tab>") 'markdown-cycle), but for some reason this wasn't registering for me (though other parts of the keymap were working fine).
What fixed this was changing <tab> to TAB in the above. Is this something wonky in the OS X terminal? Is there a way to fix this; I feel like this shouldn't occur.
I believe markdown-mode should be using TAB, not <tab>.
As far as I can tell, <tab> is the Tab key on the keyboard, and TAB is control-I, or ascii character 9 (written \t or \x09). The Tab key doesn't have an ascii value.
In GUI Emacs, Emacs sees that you pressed the Tab key (<tab>) and converts it to C-i (TAB) by default. Emacs can distinguish Tab and C-i, but converts Tab to C-i unless you specifically bind <tab> to something else (which markdown-mode does).
In the terminal, the terminal converts the Tab key to C-i (ascii 9), and Emacs sees only C-i. Emacs can't distinguish the two because they both show up as C-i.
The same thing happens with <return> vs RET (C-m, ascii 13).
Using TAB with define-key should automatically bind whatever event your keyboard sends for the key labeled "Tab", whether it is the ASCII TAB character, also known as C-i (Control + i) or something else -- including what Emacs writes as the pseudo-function key <tab>.
This might not work automatically in all cases. If it does not work for your particular keyboard then use C-h k and hit your Tab key, to find out what it is bound to. Whatever Emacs tells you is the key sequence, try binding that. For example, if it tells you that the key sequence is <foobar> then use (kbd "<foobar>").
But in most cases, all you need to do is use (kbd "TAB") (or "\C-i" or [control ?i]).

emacs DELETE/C-h confusion on OS X

Going through the tutorial on emacs, I got stuck on the deleting part, because by default DELETE key sends me to help. I've tried adding a few popular commands to the .emacs file such as (normal-erase-is-backspace-mode 1). So with that in my .emacs file, I hit C-h and get the screen that says This buffer is for notes you don't want to save..., then hit t and it just enters the letter into this "buffer". DELETE does what it's supposed to do now, though. When running emacs -q instead, I end up at the same "buffer" screen, except when I hit t it actually takes me to the tutorial, but the problem is of course that DELETE does not delete. Any solutions to this? I'm on a MacBook with OS X 10.9.4, using the Terminal.
The answer is in the Emacs manual, node DEL Does Not Delete. Just customize option normal-erase-is-backspace. Or use M-x normal-erase-is-backspace-mode to toggle the value.
Hmm, but I see now that you have added that you tried this. I do not understand what you mean by "notepad", so I do not understand that part.
Try this also, at a command prompt (assuming you are on GNU/Linux or similar):
stty erase ^H
And see various writeups on the web about stty erase. (IOW, google stty erase.)
When you say DELETE, I'm guessing (hoping) that you mean the key labeled Backspace and not the key labeled Delete. What does C-h k tell you when you use it and then hit each of these keys?
the key labeled Backspace
C-h, that is, press and hold Control then hit h
the key labeled Delete
(And just which keys are you using to get the behavior that does not work?)

Key-combination on Emacs + nRepl + ClojureMode [duplicate]

I use the shortcut C-, with the window version of emacs.
(global-set-key (kbd "C-,") 'dabbrev-expand)
My problem is that this shortcut does not work in the console version of emacs.
I've tried many things (.inputrc, set bind-tty-special-chars off, bind command in .bashrc) but nothing seems to work; I never manage to receive something with this combination of keys.
I've managed to bind other non standards shortcuts like Ctrl-<left-arrow>.
Control-Comma does not map to a control character in the system keyboard map. Therefore, it is sent to applications as just a comma. Terminal then sends this comma to the tty, where Emacs receives it. If you want Control-Comma to map to a control character or other sequence that Emacs can distinguish from a normal comma, you'll have to alter the system keyboard map. Doing so is left as an exercise for the reader.

Control + , in Terminal.app

I use the shortcut C-, with the window version of emacs.
(global-set-key (kbd "C-,") 'dabbrev-expand)
My problem is that this shortcut does not work in the console version of emacs.
I've tried many things (.inputrc, set bind-tty-special-chars off, bind command in .bashrc) but nothing seems to work; I never manage to receive something with this combination of keys.
I've managed to bind other non standards shortcuts like Ctrl-<left-arrow>.
Control-Comma does not map to a control character in the system keyboard map. Therefore, it is sent to applications as just a comma. Terminal then sends this comma to the tty, where Emacs receives it. If you want Control-Comma to map to a control character or other sequence that Emacs can distinguish from a normal comma, you'll have to alter the system keyboard map. Doing so is left as an exercise for the reader.

Resources