Since every reader can conceivably use a different buffer and/or
major-mode to reply in, supercite can't know ahead of time what the
state of the buffer is. So supercite needs to leach onto whatever buffer
the reply is being made in, modifying the keymap and the documentation
string for that buffer. A mechanism was developed to provide a
per-interface keymap, which installs itself into the reply
buffer's current-local-map
based on the major-mode of the
buffer.
The variable sc-local-keymaps
contains an association list of the
form:
((MAJOR-MODE [FUNCTION | MAJOR-MODE])+)
When it is time to modify the keymap of the current buffer, supercite
looks up that buffer's major-mode in this association list. If it
matches an entry, supercite looks at the value associated with the key.
If the value is a list, it is assumed that this list is a function which
will set the current local keymap as intended. If however, the value is
another major-mode symbol name, then this returned major mode is looked
up in sc-local-keymaps
, and the resulting keymap-setting function
is evaluated. Only one level of indirection is allowed, but this does
let you save space when defining key bindings. If you have many modes
which have the same bindings, you only need define the keymap setting
function once, and then let all other modes refer to this mode's keymap.
Here is the default value for sc-local-keymaps
:
'((mail-mode (lambda () (local-set-key "\C-c\C-r" 'sc-insert-reference) (local-set-key "\C-c\C-t" 'sc-cite) (local-set-key "\C-c\C-a" 'sc-recite) (local-set-key "\C-c\C-u" 'sc-uncite) (local-set-key "\C-c\C-i" 'sc-insert-citation) (local-set-key "\C-c\C-o" 'sc-open-line) (local-set-key "\C-c\C-q" 'sc-fill-paragraph-manually) (local-set-key "\C-cq" 'sc-fill-paragraph-manually) (local-set-key "\C-c\C-m" 'sc-modify-information) (local-set-key "\C-cf" 'sc-view-field) (local-set-key "\C-cg" 'sc-glom-headers) (local-set-key "\C-c\C-v" 'sc-version) (local-set-key "\C-c?" 'sc-describe) )) (mh-letter-mode (lambda () (local-set-key "\C-c\C-r" 'sc-insert-reference) (local-set-key "\C-c\C-t" 'sc-cite) (local-set-key "\C-c\C-a" 'sc-recite) (local-set-key "\C-c\C-u" 'sc-uncite) (local-set-key "\C-ci" 'sc-insert-citation) (local-set-key "\C-c\C-o" 'sc-open-line) (local-set-key "\C-cq" 'sc-fill-paragraph-manually) (local-set-key "\C-c\C-m" 'sc-modify-information) (local-set-key "\C-cf" 'sc-view-field) (local-set-key "\C-cg" 'sc-glom-headers) (local-set-key "\C-c\C-v" 'sc-version) (local-set-key "\C-c?" 'sc-describe) )) (news-reply-mode mail-mode) (vm-mail-mode mail-mode) (e-reply-mode mail-mode) (n-reply-mode mail-mode) )
If the major-mode of the buffer is not found in the association list,
then the function in sc-default-keymap
is evaluated. The default
value for sc-default-keymap
is:
'(lambda () (local-set-key "\C-c\C-r" 'sc-insert-reference) (local-set-key "\C-c\C-t" 'sc-cite) (local-set-key "\C-c\C-a" 'sc-recite) (local-set-key "\C-c\C-u" 'sc-uncite) (local-set-key "\C-c\C-i" 'sc-insert-citation) (local-set-key "\C-c\C-o" 'sc-open-line) (local-set-key "\C-c\C-q" 'sc-fill-paragraph-manually) (local-set-key "\C-cq" 'sc-fill-paragraph-manually) (local-set-key "\C-c\C-m" 'sc-modify-information) (local-set-key "\C-cf" 'sc-view-field) (local-set-key "\C-cg" 'sc-glom-headers) (local-set-key "\C-c\C-v" 'sc-version) (local-set-key "\C-c?" 'sc-describe) )
The keymap for electric reference mode can also be user defined, but
since there is no need for a per-interface map, there is only a single
variable, sc-electric-mode-map
which contains the keymap. If you
set this variable, you can override the default key bindings for
electric reference mode. See section Electric References for a description
of the default key bindings for this mode.