1

I came across this snippet which stops emacs from converting C-i and C-m into <tab> and <ret> respectively:

(dolist (k '("C-i" "C-m"))
    (define-key input-decode-map (kbd k) (kbd (concat "<" k ">"))))

Given that I always use emacs in a graphical environment where this remapping works, and I don't want to use C-i and C-m for <tab> and <ret>, is there any reason not to do this and reclaim two keys? E.g. would C-i or C-m ever be specifically bound? Or would this translation affect key combinations? Or anything else? Thanks.

5
  • 3
    Does this answer your question? How to bind C-i as different from TAB? Commented Apr 10 at 8:40
  • TAB (not the same thing as tab) is how Ctrl+I is displayed, and it's what modes bind. Same with RET vs return. It's possible but a bit more complicated, see the answer to the duplicate question. Commented Apr 10 at 8:42
  • @Gilles'SO-stopbeingevil' my question was more asking about the potential downsides of binding C-i as different from TAB, rather than asking how to do it. Commented Apr 10 at 8:55
  • And my point is that C-i cannot be different from TAB, but it can be different from tab. The only downside of binding them differently is that you have to understand how to work with that subtlety. Commented Apr 10 at 9:33
  • @Gilles'SO-stopbeingevil' Oh I see, sorry for misunderstanding. Thank you, I'll look into it more. Commented Apr 10 at 22:12

1 Answer 1

1

You should be careful, because function-key-map maps, for example, <tab> to C-i.
So any changes you apply to C-i will also affect <tab>.


(keymap-local-set "C-i"
  (lambda ()
    (interactive)
    (insert "233")))

The above expression makes Emacs insert "233" when you type tab.


The good news is that function-key-map is, of course, mutable.

1
  • Thanks for the reply. I'm a bit confused though. What is the correct way to achieve what I want then? For example, I have this in my config: (define-key input-decode-map "\C-m" [H-m]) and (setq shell-pop-universal-key "<H-m>") when using the shell-pop package. Now enter seems to continue to work as enter, and C-m now executes shell pop like desired. Is there anything wrong with this? Commented Apr 10 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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