If command command is bound to 2 keys kb1 and kb2, and if I remap like this (define-key somemap [remap command] #'some-other-command), which of kb1 and kb2 is now bound to some-other-command in somemap?

1 Answer 1


The first command (command) is remapped to all of the keys bound to the second command (some-other-command).

See the Elisp manual, node Remapping Commands.

Update, to try to answer your question in your comment:

Whether some-other-command (which is typically just a symbol here) is already a command bound to some keys, or is even already defined as a command, is irrelevant.

What the [remap...] does is create a key binding for command, so that IF some-other-command does become defined and bound to some key(s) THEN it will have its key(s) remapped so they invoke command instead.

The binding that is created for command is special. It just holds the information that "any keys bound to some-other-command are to be rerouted to invoke command instead."

You can think of this binding as being a "Detour" sign on the road that would normally lead to some-other-command. When you hit the key Emacs follows the detour sign and ends up at command instead of some-other-command.

"Remap" means to use some-other-command as a pointer (indirection), so that key lookup goes past/through some-other-command to finally end up invoking command.

Let me know if this is still not clear, and I'll try to explain better.

  • Thanks. I read this document several times before asking the question. I don't understand your answer. You say "all of the keys bound to the second command some-other-command", but this command is not bound to any key before the evaluation of define-key. I'm lost. Also, could you please tell me what you exactly mean by remap? Apr 9, 2016 at 9:39

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.