<tab> v. TAB in emacs

I am using emacs 24.3 in OS X terminal and am running into something weird.

In markdown-mode.el, the tab key is tied to a specific function in the keymap via (define-key map (kbd "<tab>") 'markdown-cycle)

, but for some reason this didn't register for me (although other parts of the keyboard layout worked fine).

What fixed it changed <tab>

to TAB

in the above. Is this something awkward about the OS X terminal? Is there a way to fix this; I feel like this shouldn't happen.

+3


source to share


2 answers


I believe markdown mode should be used TAB

instead <tab>

.

As far as I can tell, <tab>

this is the Tab key on the keyboard and TAB

is the control-I or ascii 9 character (written \t

or \x09

). The Tab key is not ascii significant.

In the Emacs GUI, Emacs sees that you pressed the Tab ( <tab>

) key and converts it TAB

to the default Ci ( ). Emacs can distinguish between Tab and Ci, but converts Tab to Ci unless you specifically bind <tab>

to something else (which is what markdown mode does).



In a terminal, the terminal converts the Tab key to Ci (ascii 9), and Emacs only sees Ci. Emacs cannot tell the difference between the two because they both display as Ci.

The same thing happens with <return>

vs RET

(Cm, ascii 13).

+3


source


Use TAB

with define-key

should automatically bind any event your keyboard sends for a key labeled "Tab", be it the ASCII character TAB

, also known as C-i

(Control + i), or anything else - including what Emacs writes as a pseudo-function key <tab>

.

This may not work automatically in all cases. If that doesn't work for your particular keyboard, use C-h k

and press the Tab key to see what it binds to. Whatever Emacs tells you is a key sequence, try linking that. For example, if it tells you what the key sequence is <foobar>

, then use (kbd "<foobar>")

.



But in most cases, all you have to do is use (kbd "TAB")

(or "\C-i"

or [control ?i]

).

+3


source







All Articles