1

I've just set

(define-key input-decode-map "\C-i" [\C-i])
(define-key input-decode-map "\C-m" [\C-m])
(define-key input-decode-map "\C-[" [\C-\[])

in my config, but I noticed that C-i is now remapped to <C-i>.

Where is the difference? It's possible to obtain only C-i?

I'm interested in getting a C-i not a \t or a <C-i>

6
  • Perhaps you meant [?\C-i], aka (control ?i)? – Drew Nov 20 '18 at 14:47
  • I also don't know the difference between "\C-i" and "?\C-i" – Francesco Cadei Nov 20 '18 at 15:06
  • 2
    Spontaneously, I don't understand the purpose of the lines. They seem to map some keys to themselves, why do you need them? – Lindydancer Nov 20 '18 at 16:35
  • Because in ASCII C-i is a \t, C-m a \r and C-[ an ESC – Francesco Cadei Nov 20 '18 at 16:44
  • @Fólkvangr so my original settings was correct? – Francesco Cadei Nov 20 '18 at 19:58
4

I'm interested in getting a C-i not a \t

C-i and \t are the same thing (ASCII character 9; aka TAB).

If you want the TAB key to be different to C-i you can achieve that in a GUI environment (but not in a terminal, where they are, again, the same thing).

In GUI environments, the event <tab> is sent to Emacs when the TAB key is used.

function-key-map maps <tab> to TAB (aka C-i, aka 9) so that in a GUI environment the TAB key will have the same effect in Emacs that it has in a terminal.

(lookup-key function-key-map (kbd "<tab>"))
[9]

This translation takes place only if no binding for the <tab> event itself was found; so if you do bind something to <tab> it will take precedence over any TAB bindings. Normally1 there are no bindings for <tab>, though, and so the translation tends to take place.

If you want to prevent the translation entirely, you'll need to disable that function-key-map binding:

(define-key function-key-map (kbd "<tab>") nil)

This would completely separate <tab> from C-i in a GUI environment.

1 Note that most commands with a tab binding will be using the terminal-friendly value, so expect some things to stop working in a GUI environment if you remove that translation. You would need to either use C-i to invoke those commands, or else add custom bindings for <tab> to replicate them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.