C-Tab cannot be recognized in terminal? - emacs

I want to bind company-mode-map to C-tab, but it seems doesn't work. And I typed C-h k C-tab, it just said that I typed TAB but not C-Tab. It works in Xwindows, is there any way to fix the problem in terminal mode?

I found these directions, which are targeted at using GNU screen, but they work for me in regular terminal mode. After adding:
*vt100.translations: #override \n\
Ctrl ~Shift <Key>Tab: string(0x1b) string("[27;5;9~") \n \
Ctrl Shift <Key>Tab: string(0x1b) string("[27;6;9~") \n
to my .Xresources file, C-tab is recognized in my terminal, and the binding found by Emacs.

Related

emacs + konsole: key binding problems [duplicate]

In org-mode, pressing M-S-RET (meta-shift-return) will create a new TODO on a new line. This key sequence sends M-RET to emacs through my terminal. I've checked this with C-h c ESC-S-RET, which returns M-RET is undefined in the mini-buffer.
I'm using Snow Leopard with Emacs 23.2.1 running in Terminal.app. There is no option to define a RET sequence in the terminal keyboard preferences.
Any idea what's causing the missing SHIFT? Workarounds?
You can get Emacs to pretend that it got S-RET with C-x # S RET (note uppercase S).
This also works for adding control, meta, alt, hyper or super modifiers; type C-x # C-h for the list of bindings. The Modifier Keys section in the Emacs manual mentions this as well.
In general, lots of keystrokes are simply impossible to send via a terminal, since terminals emulate an old protocol that only allowed 256 separate keys (or maybe only 128).
Chances are, when you press S-RET, Terminal.app does exactly the same thing as if you'd pressed RET. Thus Emacs has no way to distinguish those two cases.
Cross-linking to other Q&As:
If you are using an xterm, then the modifyOtherKeys option may facilitate that binding. See the following for details:
Send "C-(" to Emacs in VT100/xterm terminal (Mac OS X's Terminal)?
I suspect Emacs recognises those codes by default, but if not then also see input-decode-map as described here: Binding M-<up> / M-<down> in Emacs 23.1.1
See explanation and alternative shortcuts for TTY here.
Some of these have worked for me in a terminal in Ubuntu Linux (both locally and over SSH), but not all of them seem to work. For example, the alternative provided for S-RET (which I expected to run org-table-copy-down) instead seems to run org-clone-subtree-with-time-shift for some reason. However, I have found the list of alternatives useful, particularly those with the M- prefix. For example ESC UP for M-UP to move text around in tables.

vi command line editing key bindings - previous command

I use the vi editor on the command line, and I really like it.
I use
set -o vi
to set the bindings.
The only thing is that I have to use the up and down arrows to cycle through the
previous executed commands.
In the emacs key bindings it was Ctrl+p to get to the previous command. It is the one emacs binding I miss.
I have been looking for something like it vi - but can't find it. My search gets diverted to the text editing vi binding for previous command which is held in " : " or hitting Ctrl+F to get a command window. I am using vi on the command line instead of emacs. There has to be something.
Is there something comparable in the vi command line ?
Using the Up / Down arrow keys is driving me nuts.
Actually I found the answer on this on this site:
Working Productively in Bash's Vi Command Line Editing Mode (with Cheat Sheet)
Make sure set -o vi is set to 'on'. Hit Ctrl+[ or escape to get to command mode. Then tap k go up the history and j to go down. It is so intuitive that I imagine most vi power-users discover it without trying, without help.
Thanks.

C-<SPC> is intercepted in emacs -nw (terminal intercept?)

I use urxvt (terminal) under awesome (window manager) and ubuntu (os).
In graphical mode, c- set the mark but in text mode it inserts a space.
The problem is solved when using gnome-terminal but some other key combinations still does not work. For instance, C-: insert a : in both terminals.
I do not know where to look at to correct this behaviour.
C-h k (help on key combination) followed by one of these combination shows only the key pressed along ctrl, for instance C- is interpreted as .
As stated in comments, the terminal is probably the cause. I believe that C- should not enter a space at the terminal prompt, which it does here.
I identified this question as being related. This one too.
In my case, Ctrl-Space was being used to change input methods. Running ibus-setup and unbinding it fixed my problem (it now produces Nul)
See also: https://askubuntu.com/questions/243639/ctrlspace-has-been-bound-to-invoke-some-input-method-and-does-not-work-in-ema

Use Alt key as Meta in emacs

Somehow the emacs I'm using doesn't treat Alt as Meta. It only uses ESC for it. If I press Alt+x it will tell me "A-X" undefined. I tried to figure out how to map it to meta but got no luck on the web because in most of results from my search people take Alt as Meta by default. I guess something like this should work:
global-set-key Alt(?) 'meta
but I'm not sure how to represent Alt in lisp.. any help? Thanks!
Most solutions will tell you to change keymap at the X11 level. The wiki suffers from the problem of too much information. If you just want a solution that works only at the emacs level (quite useful for VNC/remote desktop), then add the below line to your emacs init file
;; Map Alt key to Meta
(setq x-alt-keysym 'meta)
I had the same problem and by putting this in ~/.emacs helped me.
(set-keyboard-coding-system nil)
Refer to this, if you need more help
http://www.emacswiki.org/emacs/MetaKeyProblems#toc15
Entering this command in a shell (even M-x shell) works for me.
xmodmap -e "clear mod4"
This works when the problem is that the output of xmodmap includes a line showing that Meta_L is set to mod4:
mod4 Meta_L (0x73)
Emacs thinks your keyboard has a Meta key, so it's not interpreting Alt as Meta. The above command tells X that you don't have a Meta key, so Emacs will interpret Alt the way that we're used to.
I learned this from https://www.emacswiki.org/emacs/MetaKeyProblems.

M-RET and M-UP/DOWN not working in Emacs org-mode in console/terminal

I'm using emacs23 on Ubuntu 32-bit 10.04/10.10 with GNOME and Compiz.
Pressing M-RET in an org-mode plain list in Emacs (GUI) inserts a new item. Pressing M-Up moves the item up in the list.
These keys don't work as expected in emacs -nw under Terminator and gnome-terminal. The M-Up key does nothing, whereas the M-RET key simply moves the cursor down one line and indents the position. The keys also don't "work" in xterm, which inserts \215 instead. Pressing ESC-RET or ESC-Up instead produces the expected functionality. The same problems exist if I run emacs -nw on a headless server accessed via ssh under Terminator, gnome-terminal and xterm.
I've searched both generally and on the org-mode Gmane list for an answer to this, but have not found anything. Is this a known issue with org-mode or is it related to the terminal emulator and/or the Window Manager?
In addition to the keys in my question, S-TAB, S-Left, S-Right, S-Up and S-Down were not working over ssh and PuTTY. Using certain keys on a TTY connection (ssh, screen, PuTTY) is a known issue.
Alternative keys are included in org-mode as detailed in 'Using Org on a TTY' in the org-mode manual.
Alternative key combinations exist
for equivalent to M-RET
M C-m
"<return>" is the Return ↩ key while emacs runs in a graphical user interface.
"RET" is the Return ↩ key while emacs runs in a terminal.
"RET" is also equivalent to "C-m" (【Ctrl+m】). (http://ergoemacs.org/emacs/emacs_key_notation_return_vs_RET.html)
as equivalents for M-<up/down> you can use
ESC-<up>
ESC-<down>
The menubar of terminal emulator is not letting the M key that is meant for Emacs be passed down to Emacs. For Emacs to receive the M key as it is supposed to, you could either use the Esc or disable the menubar and use M key in Emacs as usual.
ADDED:
For the xterm, if you do CTRL+Mouse Button 1, you will see "Meta sends Escape". You need to make sure that option is checked/enabled to make M work as it should in Emacs.