Next: Translation Keymaps, Previous: Changing Key Bindings, Up: Keymaps
A special kind of key binding, using a special “key sequence”
which includes a command name, has the effect of remapping that
command into another. Here's how it works. You make a key binding
for a key sequence that starts with the dummy event remap,
followed by the command name you want to remap. Specify the remapped
definition as the definition in this binding. The remapped definition
is usually a command name, but it can be any valid definition for
a key binding.
Here's an example. Suppose that My mode uses special commands
my-kill-line and my-kill-word, which should be invoked
instead of kill-line and kill-word. It can establish
this by making these two command-remapping bindings in its keymap:
(define-key my-mode-map [remap kill-line] 'my-kill-line)
(define-key my-mode-map [remap kill-word] 'my-kill-word)
Whenever my-mode-map is an active keymap, if the user types
C-k, Emacs will find the standard global binding of
kill-line (assuming nobody has changed it). But
my-mode-map remaps kill-line to my-kill-line,
so instead of running kill-line, Emacs runs
my-kill-line.
Remapping only works through a single level. In other words,
(define-key my-mode-map [remap kill-line] 'my-kill-line)
(define-key my-mode-map [remap my-kill-line] 'my-other-kill-line)
does not have the effect of remapping kill-line into
my-other-kill-line. If an ordinary key binding specifies
kill-line, this keymap will remap it to my-kill-line;
if an ordinary binding specifies my-kill-line, this keymap will
remap it to my-other-kill-line.
This function returns the remapping for command (a symbol), given the current active keymaps. If command is not remapped (which is the usual situation), or not a symbol, the function returns
nil.
