mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-19 01:10:57 -08:00
Added command remapping.
This commit is contained in:
parent
9c874d82af
commit
93607efd67
3 changed files with 112 additions and 0 deletions
81
etc/NEWS
81
etc/NEWS
|
|
@ -136,6 +136,27 @@ C-h C-e displays the PROBLEMS file.
|
|||
The info-search bindings on C-h C-f, C-h C-k and C-h C-i
|
||||
have been moved to C-h F, C-h K and C-h S.
|
||||
|
||||
C-h c, C-h k, C-h w, and C-h f now handle remapped interactive commands.
|
||||
|
||||
- C-h c and C-h k report the actual command (after possible remapping)
|
||||
run by the key sequence.
|
||||
|
||||
- C-h w and C-h f on a command which has been remapped now report the
|
||||
command it is remapped to, and the keys which can be used to run
|
||||
that command.
|
||||
|
||||
For example, if C-k is bound to kill-line, and kill-line is remapped
|
||||
to new-kill-line, these commands now report:
|
||||
|
||||
- C-h c and C-h k C-k reports:
|
||||
C-k runs the command new-kill-line
|
||||
|
||||
- C-h w and C-h f kill-line reports:
|
||||
kill-line is remapped to new-kill-line which is on C-k, <deleteline>
|
||||
|
||||
- C-h w and C-h f new-kill-line reports:
|
||||
new-kill-line is on C-k
|
||||
|
||||
** C-w in incremental search now grabs either a character or a word,
|
||||
making the decision in a heuristic way. This new job is done by the
|
||||
command `isearch-yank-word-or-char'. To restore the old behavior,
|
||||
|
|
@ -416,6 +437,66 @@ SQL buffer.
|
|||
|
||||
* Lisp Changes in Emacs 21.3
|
||||
|
||||
** Interactive commands can be remapped through keymaps.
|
||||
|
||||
This is an alternative to using defadvice or substitute-key-definition
|
||||
to modify the behaviour of a key binding using the normal keymap
|
||||
binding and lookup functionality.
|
||||
|
||||
When a key sequence is bound to a command, and that command is
|
||||
remapped to another command, that command is run instead of the
|
||||
original command.
|
||||
|
||||
Example:
|
||||
Suppose that minor mode my-mode has defined the commands
|
||||
my-kill-line and my-kill-word, and it wants C-k (and any other key
|
||||
bound to kill-line) to run the command my-kill-line instead of
|
||||
kill-line, and likewise it wants to run my-kill-word instead of
|
||||
kill-word.
|
||||
|
||||
Instead of rebinding C-k and the other keys in the minor mode map,
|
||||
command remapping allows you to directly map kill-line into
|
||||
my-kill-line and kill-word into my-kill-word through the minor mode
|
||||
map using define-key:
|
||||
|
||||
(define-key my-mode-map 'kill-line 'my-kill-line)
|
||||
(define-key my-mode-map 'kill-word 'my-kill-word)
|
||||
|
||||
Now, when my-mode is enabled, and the user enters C-k or M-d,
|
||||
the commands my-kill-line and my-kill-word are run.
|
||||
|
||||
Notice that only one level of remapping is supported. In the above
|
||||
example, this means that if my-kill-line is remapped to other-kill,
|
||||
then C-k still runs my-kill-line.
|
||||
|
||||
The following changes have been made to provide command remapping:
|
||||
|
||||
- define-key now accepts a command name as the KEY argument.
|
||||
This identifies the command to be remapped in the specified keymap.
|
||||
This is equivalent to specifying the command name as the only
|
||||
element of a vector, e.g [kill-line], except that when KEY is a
|
||||
symbol, the DEF argument must also be a symbol.
|
||||
|
||||
- In calls from Lisp, global-set-key, global-unset-key, local-set-key,
|
||||
and local-unset-key also accept a command name as the KEY argument.
|
||||
|
||||
- key-binding now remaps interactive commands unless the optional
|
||||
third argument NO-REMAP is non-nil. It also accepts a command name
|
||||
as the KEY argument.
|
||||
|
||||
- lookup-key now accepts a command name as the KEY argument.
|
||||
|
||||
- where-is-internal now returns nil for a remapped command (e.g.
|
||||
kill-line if my-mode is enabled), and the actual key binding for
|
||||
the command it is remapped to (e.g. C-k for my-kill-line).
|
||||
It also has a new optional fifth argument, NO-REMAP, which inhibits
|
||||
remapping if non-nil (e.g. it returns C-k for kill-line and
|
||||
<kill-line> for my-kill-line).
|
||||
|
||||
- The new variable `this-original-command' contains the original
|
||||
command before remapping. It is equal to `this-command' when the
|
||||
command was not remapped.
|
||||
|
||||
** Atomic change groups.
|
||||
|
||||
To perform some changes in the current buffer "atomically" so that
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
2002-02-06 Kim F. Storm <storm@cua.dk>
|
||||
|
||||
* help.el (where-is): Report remapped commands.
|
||||
|
||||
* help-fns.el (describe-function-1): Ditto.
|
||||
|
||||
* subr.el (global-set-key, local-set-key): Accept a symbol for the
|
||||
KEY argument (like define-key).
|
||||
|
||||
2002-02-06 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
|
||||
|
||||
* textmodes/flyspell.el (flyspell-insert-function): Doc fix.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
2002-02-06 Kim F. Storm <storm@cua.dk>
|
||||
|
||||
* keymap.c (Fdefine_key): Allow symbol as KEY argument for
|
||||
defining command remapping. Doc updated.
|
||||
(Flookup_key): Remap command through keymap if KEY is a symbol.
|
||||
(is_command_symbol): New function.
|
||||
(Fkey_binding): Use it. New optional argument NO-REMAP. Doc
|
||||
updated. Callers changed. Perform command remapping via
|
||||
recursive call unless that arg is non-nil.
|
||||
(where_is_internal): New argument no_remap. Callers changed.
|
||||
Call recursively to find original key bindings for a remapped
|
||||
comand unless that arg is non-nil.
|
||||
(Fwhere_is_internal): New optional argument NO-REMAP. Doc
|
||||
updated. Callers changed. Pass arg to where_is_internal.
|
||||
|
||||
* keymap.h (Fkey_binding, Fwhere_is_internal): Update prototype.
|
||||
(is_command_symbol): Added prototype.
|
||||
|
||||
* keyboard.c (Vthis_original_command): New variable.
|
||||
(syms_of_keyboard): DEFVAR_LISP it.
|
||||
(command_loop_1): Set it, and perform command remapping.
|
||||
|
||||
2002-02-06 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
|
||||
|
||||
* keyboard.c (recursive_edit_1): Call cancel_hourglass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue