LispWorks Editor User Guide > 6 Advanced Features

NextPrevUpTopContentsIndex

6.1 Customizing default key bindings

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 Emacs key bindings can be found in the file config/key-binds.lisp in the LispWorks library directory. See Key bindings for details of the key binds files used in other editor emulations.

editor:bind-key

Function

editor:bind-key name key &optional kind where

Binds the command name to the key sequence or combination key .

kind can take the value :global , :mode , or :buffer .

The default for kind is :global . which makes the binding apply in all buffers and all modes, unless overridden by a mode-specific or buffer-specific binding.

If where is not supplied, the binding is for the current emulation. Otherwise where should be either :emacs or :pc , meaning that the binding is for Emacs emulation or KDE/Gnome emulation respectively.

Note: before the editor starts, the current emulation is :emacs . Therefore bind-key forms which do not specify where 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)

If kind is :buffer the binding applies only to a buffer which should be specified by the value of where .

If kind is :mode the binding applies only to a mode which should be specified by where .

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. Tab 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 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

Function

editor:bind-string-to-key string key &optional kind where

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 and where arguments are as for editor:bind-key .

editor:set-interrupt-keys

Function

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 Ctrl+G for Emacs) then you must use this function rather than editor:bind-key . See the file config/msw-key-binds.lisp for an example.


LispWorks Editor User Guide (Unix version) - 22 Dec 2009

NextPrevUpTopContentsIndex