Go to the first, previous, next, last section, table of contents.


Prefix Keys

As briefly noted in the previous section it is possible to create multi-event key bindings. The next-keymap-path variable is used to link key presses (known as prefix keys since they prefix the actual, command-invoking, binding) to a new keymap environment which will be used to resolve the next key press. This method allows key sequences of an arbitrary length to be used.

The best way to explain this is probably with an example. Consider the following,

(setq entry-keymap (make-keylist))
(bind-keys entry-keymap
 "Ctrl-x" '(setq next-keymap-path '(second-keymap)))

(setq second-keymap (make-keylist))
(bind-keys second-keymap
 "Ctrl-j" 'some-command)

Two keymaps are created, the first of which, entry-keymap, would be placed in the keymap-path list. When Ctrl-x is typed the associated command would be invoked, installing the next piece of the chain, the second-keymap into the next-keymap-path variable.

So, after Ctrl-x is typed the keymap environment will be the list of keymaps (second-keymap), subsequently typing Ctrl-j would then invoke the command some-command.


Go to the first, previous, next, last section, table of contents.