The key sequences to which individual commands are bound can be changed, and key bindings can be set up for commands which are not, by default, bound to any key sequences. Interactive means of modifying key bindings are described in Key bindings.
This section describes the editor function
, which is used to establish bindings programmatically. If you want to alter your personal key bindings, put the modifying code in your
The default Emacs key bindings can be found in the file
in the LispWorks library directory. See Key bindings for details of the key binds files used in other editor emulations.
editor:bind-key name key &optional kind where
Binds the command name to the key sequence or combination key .
can take the value
The default for
. which makes the binding apply in all buffers and all modes, unless overridden by a mode-specific or buffer-specific binding.
is not supplied, the binding is for the current emulation. Otherwise
should be either
, meaning that the binding is for Emacs emulation or KDE/Gnome emulation respectively.
Note: before the editor starts, the current emulation is
forms which do not specify
and which are evaluated before the editor starts (for example, in your initialization file) will apply to Emacs emulation only. Thus for example
(bind-key "Command" "Control-Right")
when evaluated in your initialization file will establish an Emacs emulation binding. The same form when evaluated after editor startup will establish a binding in the current emulation: Emacs or KDE/Gnome emulation.
It is best to specify the intended emulation:
(editor:bind-key "Command" "Control-Right" :global :pc)
the binding applies only to a buffer which should be specified by the value of
the binding applies only to a mode which should be specified by
If this function is called interactively via the command Bind Key, you will be prompted as necessary for the kind of binding, the buffer or the mode. The binding is for the current emulation.
completion may be used at any stage.
The following examples, which are used to implement some existing key bindings, illustrate how key sequences can be specified using
(editor:bind-key "Forward Character" #\control-\f)
(editor:bind-key "Forward Word" #\meta-\f)
(editor:bind-key "Save File" '#(#\control-\x #\control-\s))
(editor:bind-key "Regexp Forward Search" #\meta-control-\s)
(editor:bind-key "Complete Field" #\space :mode "Echo Area")
(editor:bind-key "Backward Character" "left")
(editor:bind-key "Forward Word" #("control-right"))
key &optional kind where
Binds the text string
to the keyboard shortcut
without the need to create a command explicitly. Using
in the current buffer. The
arguments are as for
editor:set-interrupt-keys keys &optional input-style
The key that aborts the current editor command is handled specially by the editor. If you wish to change the default (from
for Emacs) then you must use this function rather than
. See the file
for an example.