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 bind-key
, which is used to establish bindings programmatically. If you want to alter your personal key bindings, put the modifying code in your .lispworks
file.
The default key bindings can be found in the file config/key-binds.lisp
in the LispWorks library directory.
editor:bind-key name key &optional kind
Binds the command name to the key sequence or combination key . kind can take the value :global
, :mode
, or :buffer
. The default is :global,
as most key bindings are required to work throughout the editor. :buffer
applies the binding only to a specified buffer. :mode
applies the binding only to buffers in a specified major mode.
If this function is called interactively, you will be prompted as necessary for the kind of binding, the buffer or the major mode. Tab completion may be used at any stage.
Note that the function editor:bind-key
is a programmatic version the editor command Bind Key
.
The following examples, which are used to implement some existing key bindings, illustrate how key sequences can be specified using bind-key
.
(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"))
editor:bind-string-to-key string
key &optional kind
Binds the text string string to the keyboard shortcut key without the need to create a command explicitly. Using key inserts string in the current buffer. The kind option is as for editor:bind-key
.
editor:set-interrupt-keys keys
The key that aborts the current editor command is handled specially by the editor. If you wish to change the default (from Ctrl+G
) then you must use this function rather than editor:bind-key
. See the file config/msw-key-binds.lisp
for an example.