Normally, for historic reasons, emacs treats the TAB
keycode and the C-i
key as the same, cf. the emacs lisp documentation on function keys or abo-abo's answer on the question "What is the difference between TAB and ?".
NOTE: In this post, keycodes are
TAB
,<tab>
, andC-i
; tab and Ctrl + i on the other hand are the physical keys on the keyboard.However, at the moment, emacs treats the
TAB
andC-i
as the same thing, i.e.(equal (kbd "TAB") (kbd "C-i"))
->t
.
However, since we are no longer living in the stoneage of computing I find this extremely annoying. There's a few suggestions out there what can be done to work around this, e.g.
"How do I bind a command to C-i without changing TAB?"
- Trey's Solution did not work for my, the variable
local-function-key-maps
is not changed. Modifying it to usedelete
rather thandelq
does result in a modified variable but it does not bring resolve ... tab and Ctrl+i are still the same. - Translating to the hyper map seems like a 1980s workaround ... I might want to use Hyper+i as well.
- Trey's Solution did not work for my, the variable
Using the
input-decode-map
to map Ctrl+i to some post-ASCII control code is almost what I'm looking for. Except that it does not work properly with thekbd
macro meaning that one must modify all bits of source code that will bind Ctrl + i. Arguably this is the best solution given that all source code is modified properly.Using
(kbd "<tab>")
for tab and(kbd "C-i")
(which translates to(kbd "TAB")
i.e. the\t
literal) for Ctrl+i does work but you'd have to modify all source files which use the wrong kind of tab [Read: the keycodeTAB
] which is annoying.
This has been suggested e.g. in a github issue and on emacs.sx as well.
None of these solutions seem real solutions, I'd rather consider them workarounds or hacks (of the existing bug).
Is there a way out there to force emacs to map tab to
(kbd "<tab>")
and(kbd "TAB")
while Ctrl+i is mapped to(kbd "C-i")
short of modyfing the emacs source code?This approach should be completely invisible to the user, meaning that the tab like keycodes
<tab>
andTAB
should map to one binding whilst the Ctrl+i like keycodeC-i
should map to another binding.
On a less serious note: Any emacs developers here who can comment whether this will be changed / fixed in the emacs source code at some point?
TAB
andC-i
(the codes, not the keys) are one and the same by definition ofTAB
.kbd
to translate TAB as [tab]. It just won't work for the preloaded parts of Emacs.