Next: Reserved Keys, Previous: Representing Keys in Code, Up: Mastering Key Bindings in Emacs [Index]
remap
—ReplaceYou can tell Emacs that you want to replace all keys pointing to a certain
command with one of your own choosing by using the remap
event; this should
be done instead of passing a key to the key bind function you are using. This
is arguably the best way of replacing existing commands with your own as Emacs
will automagically handle the key reassignment in the background.
(define-key (current-global-map) [remap kill-line] 'my-homemade-kill-line)
Here I globally remap all key binds that point to kill-line
to
my-homemade-kill-line
.
For some more hands-on examples read my article Fixing the Mark Commands in Transient Mark Mode.