Mercurial > hg > xemacs-beta
comparison man/lispref/keymaps.texi @ 5679:a81a739181dc
Add command remapping, a more robust alternative to #'substitute-key-definition
src/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* keymap.c:
Add command remapping, a more robust equivalent to
#'substitute-key-definition.
* keymap.c (CHECK_REMAPPING_POSITION): New.
* keymap.c (keymap_equal): Correct a comment here.
* keymap.c (Fdefine_key): Document the command remapping syntax.
* keymap.c (Fremap_command): New.
* keymap.c (command_remapping): New.
* keymap.c (Fcommand_remapping): New.
* keymap.c (commands_remapped_to_mapper): New.
* keymap.c (commands_remapped_to_traverser): New.
* keymap.c (Fcommands_remapped_to): New.
* keymap.c (get_relevant_keymaps): Take a new POSITION argument.
* keymap.c (Fcurrent_keymaps, event_binding):
Supply the new POSITION argument to get_relevant_keymaps.
* keymap.c (Fkey_binding):
Add new arguments, NO-REMAP and POSITION.
* keymap.c (map_keymap_mapper):
* keymap.c (Fwhere_is_internal):
* keymap.c (where_is_to_char):
* keymap.c (where_is_recursive_mapper):
Don't expose the key remapping in these functions. This conflicts
with GNU, but is more sane for our callers. Access to command
remapping is with the functions #'command-remapping,
#'commands-remapped-to, and #'remap-command, not with the general
keymap functions, apart from the compatibility hack in #'define-key.
* keymap.c (syms_of_keymap):
* keymap.c (vars_of_keymap):
* keymap.c (complex_vars_of_keymap):
* lisp.h: New CHECK_COMMAND macro.
man/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* lispref/keymaps.texi (Keymaps):
* lispref/keymaps.texi (Changing Key Bindings):
* lispref/keymaps.texi (Scanning Keymaps):
* lispref/keymaps.texi (Remapping commands):
* lispref/keymaps.texi (XEmacs): New.
* lispref/keymaps.texi (Other Keymap Functions):
Document the new command remapping functionality in this file.
lisp/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* help.el (describe-function-1):
Document any command remapping that has been done in this function.
tests/ChangeLog addition:
2012-09-02 Aidan Kehoe <kehoea@parhasard.net>
* automated/keymap-tests.el:
Test the new command remapping functionality.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 02 Sep 2012 14:31:40 +0100 |
parents | a25c824ed558 |
children | 9fae6227ede5 |
comparison
equal
deleted
inserted
replaced
5678:b0d40183ac79 | 5679:a81a739181dc |
---|---|
31 * Key Lookup:: How extracting elements from keymaps works. | 31 * Key Lookup:: How extracting elements from keymaps works. |
32 * Functions for Key Lookup:: How to request key lookup. | 32 * Functions for Key Lookup:: How to request key lookup. |
33 * Changing Key Bindings:: Redefining a key in a keymap. | 33 * Changing Key Bindings:: Redefining a key in a keymap. |
34 * Key Binding Commands:: Interactive interfaces for redefining keys. | 34 * Key Binding Commands:: Interactive interfaces for redefining keys. |
35 * Scanning Keymaps:: Looking through all keymaps, for printing help. | 35 * Scanning Keymaps:: Looking through all keymaps, for printing help. |
36 * Remapping commands:: Specifying that one command should override | |
37 another. | |
36 * Other Keymap Functions:: Miscellaneous keymap functions. | 38 * Other Keymap Functions:: Miscellaneous keymap functions. |
37 @end menu | 39 @end menu |
38 | 40 |
39 @node Keymap Terminology | 41 @node Keymap Terminology |
40 @section Keymap Terminology | 42 @section Keymap Terminology |
1166 This function replaces @var{olddef} with @var{newdef} for any keys in | 1168 This function replaces @var{olddef} with @var{newdef} for any keys in |
1167 @var{keymap} that were bound to @var{olddef}. In other words, | 1169 @var{keymap} that were bound to @var{olddef}. In other words, |
1168 @var{olddef} is replaced with @var{newdef} wherever it appears. Prefix | 1170 @var{olddef} is replaced with @var{newdef} wherever it appears. Prefix |
1169 keymaps are checked recursively. | 1171 keymaps are checked recursively. |
1170 | 1172 |
1171 The function returns @code{nil}. | 1173 The function returns @code{nil}. @pxref{Remapping commands} for a more |
1174 robust way of doing the same thing. | |
1172 | 1175 |
1173 For example, this redefines @kbd{C-x C-f}, if you do it in an XEmacs with | 1176 For example, this redefines @kbd{C-x C-f}, if you do it in an XEmacs with |
1174 standard bindings: | 1177 standard bindings: |
1175 | 1178 |
1176 @smallexample | 1179 @smallexample |
1579 If the second optional argument @var{mouse-only-p} (prefix arg, | 1582 If the second optional argument @var{mouse-only-p} (prefix arg, |
1580 interactively) is non-@code{nil} then only the mouse bindings are | 1583 interactively) is non-@code{nil} then only the mouse bindings are |
1581 displayed. | 1584 displayed. |
1582 @end deffn | 1585 @end deffn |
1583 | 1586 |
1587 @node Remapping commands | |
1588 @section Remapping commands | |
1589 | |
1590 This section describes some functionality to allow commands to be | |
1591 remapped, e.g. when providing workalike commands. | |
1592 | |
1593 @defun remap-command keymap old new | |
1594 This function ensures that in @var{keymap} any command lookups that | |
1595 would previously have given @var{old} now give @var{new}. This is | |
1596 equivalent to the following GNU-compatible code, which also works in | |
1597 XEmacs: | |
1598 | |
1599 @smallexample | |
1600 (define-key KEYMAP [remap OLD] NEW) | |
1601 @end smallexample | |
1602 @end defun | |
1603 | |
1604 @defun command-remapping command &optional position keymaps | |
1605 If @var{command} has a remapping in @var{keymaps}, this function returns | |
1606 that remapping. Otherwise it returns @var{nil}. @var{keymaps} defaults | |
1607 to the currently active keymaps. @var{position} specifies the relevant buffer | |
1608 position where keymaps should be searched for, and overrides | |
1609 @var{keymaps}. It can also be a marker or an event. | |
1610 @end defun | |
1611 | |
1612 @defun commands-remapped-to command &optional position keymaps | |
1613 This is the inverse operation of @code{command-remapping}; it returns a | |
1614 list of the commands that will never be executed in @var{keymaps} | |
1615 because @var{command} will be execute instead. | |
1616 @end defun | |
1617 | |
1584 @node Other Keymap Functions | 1618 @node Other Keymap Functions |
1585 @section Other Keymap Functions | 1619 @section Other Keymap Functions |
1586 | 1620 |
1587 @defun set-keymap-prompt keymap new-prompt | 1621 @defun set-keymap-prompt keymap new-prompt |
1588 This function sets the ``prompt'' of @var{keymap} to string | 1622 This function sets the ``prompt'' of @var{keymap} to string |