Usually, in Conkeror, when you want to bind a keystroke to a command or function
in a key map, you would use the define_key function (see more at
Conkeror Key Bindings). However, when you
have too many key bindings, it will lead to the problem of repetition in your
config code. For example
This is extremely annoying since I have to rebind too many keys in Conkeror (the
us dynamically define the number of arguments that passed to the function. By
using that, you can define your own function for binding the keys to avoid
repetition in your init code.
Defining keys function
The idea is to create a function that receive a key map followed by pairs of
keystroke and the command/function that bound to it. The function looks like
Now, if you want to batch define keys, just pass the keymap as the first
argument, and the rest will be the pairs of keystroke and the command. The
following example demonstrates how to batch define keys for default_global_keymap.
You can pass as many key bindings as you want. The argument that follow right
after the keystroke is the string representing the interactive command name
(which can be activated via M-x) or the name of the interactive function
that you want to bind.
This function is very helpful. It eliminates the repetition in my code and makes
my code a lot easier to read.
Undefining keys function
Similarly, the function for undefining keys receives the key map as the first
argument and followed by a series of keystroke that you wish to unbind from that
key map. This is how the function looks like
Function for defining key aliases
This function behaves much in the same way with the defining keys function.
In the following example, C-o is aliased to escape, A-v is aliased to
C-y and so on.