diff options
| author | David Kastrup | 2006-09-15 07:19:15 +0000 |
|---|---|---|
| committer | David Kastrup | 2006-09-15 07:19:15 +0000 |
| commit | b74e16a384ddbded12eb7e8c7250253614554641 (patch) | |
| tree | 287d09b973259b6101ae03baec0e0c91c848232a /lispref | |
| parent | 6266eb4a51f75b4e31895cd8d8be1ddd5a18e076 (diff) | |
| download | emacs-b74e16a384ddbded12eb7e8c7250253614554641.tar.gz emacs-b74e16a384ddbded12eb7e8c7250253614554641.zip | |
* NEWS: explain new behavior and arguments of `key-binding' and
`command-remapping'.
* keymaps.texi (Active Keymaps): Adapt description to use
`get-char-property' instead `get-text-property'. Explain how
mouse events change this. Explain the new optional argument of
`key-binding' and its mouse-dependent lookup.
(Searching Keymaps): Adapt description similarly. Explain the new
optional argument of `command-remapping'.
* Makefile.in (keymap.o): Add "keymap.h" and "window.h"
dependencies.
* keymap.c: include "window.h".
(Fcommand_remapping): New optional POSITION argument.
(Fkey_binding): New optional POSITION argument. Completely rework
handling of mouse clicks to get the same order of keymaps as
`read-key-sequence' and heed POSITION. Also temporarily switch
buffers to location of mouse click and back.
* keyboard.c (command_loop_1): Adjust call of `Fcommand_remapping'
for additional argument.
(parse_menu_item): Adjust call of `Fkey_binding' for additional
argument.
(read_key_sequence): If there are both `local-map' and `keymap'
text properties at some buffer position, heed both.
* keymap.h: Declare additional optional arguments of
`Fcommand_remapping' and `Fkey_binding'.
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/ChangeLog | 12 | ||||
| -rw-r--r-- | lispref/keymaps.texi | 55 |
2 files changed, 47 insertions, 20 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog index c6c968bdb34..7b32595083f 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2006-09-15 David Kastrup <dak@gnu.org> | ||
| 2 | |||
| 3 | * keymaps.texi (Active Keymaps): Adapt description to use | ||
| 4 | `get-char-property' instead `get-text-property'. Explain how | ||
| 5 | mouse events change this. Explain the new optional argument of | ||
| 6 | `key-binding' and its mouse-dependent lookup. | ||
| 7 | (Searching Keymaps): Adapt description similarly. Explain the new | ||
| 8 | optional argument of `command-remapping'. | ||
| 9 | |||
| 1 | 2006-09-14 Richard Stallman <rms@gnu.org> | 10 | 2006-09-14 Richard Stallman <rms@gnu.org> |
| 2 | 11 | ||
| 3 | * keymaps.texi (Searching Keymaps): Clarification. | 12 | * keymaps.texi (Searching Keymaps): Clarification. |
| @@ -10,6 +19,7 @@ | |||
| 10 | (Basic Char Syntax, General Escape Syntax) | 19 | (Basic Char Syntax, General Escape Syntax) |
| 11 | (Ctl-Char Syntax, Meta-Char Syntax): New subnodes. | 20 | (Ctl-Char Syntax, Meta-Char Syntax): New subnodes. |
| 12 | 21 | ||
| 22 | >>>>>>> 1.751 | ||
| 13 | 2006-09-11 Richard Stallman <rms@gnu.org> | 23 | 2006-09-11 Richard Stallman <rms@gnu.org> |
| 14 | 24 | ||
| 15 | * display.texi (Display Table Format): Wording clarification. | 25 | * display.texi (Display Table Format): Wording clarification. |
| @@ -4871,7 +4881,7 @@ | |||
| 4871 | (info): Add target. | 4881 | (info): Add target. |
| 4872 | (installall): Target removed. | 4882 | (installall): Target removed. |
| 4873 | 4883 | ||
| 4874 | 2001-10-31 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | 4884 | 2001-10-31 Pavel Jan,Am(Bk <Pavel@Janik.cz> |
| 4875 | 4885 | ||
| 4876 | * tips.texi (Coding Conventions): Fix typo. | 4886 | * tips.texi (Coding Conventions): Fix typo. |
| 4877 | 4887 | ||
diff --git a/lispref/keymaps.texi b/lispref/keymaps.texi index 2e38514c00d..309664c38dd 100644 --- a/lispref/keymaps.texi +++ b/lispref/keymaps.texi | |||
| @@ -576,6 +576,16 @@ keymap, and the global keymap, in that order. Emacs searches for each | |||
| 576 | input key sequence in all these keymaps. @xref{Searching Keymaps}, | 576 | input key sequence in all these keymaps. @xref{Searching Keymaps}, |
| 577 | for more details of this procedure. | 577 | for more details of this procedure. |
| 578 | 578 | ||
| 579 | This process is somewhat modified for mouse events: the local modes and | ||
| 580 | keymaps of the buffer corresponding to the mouse click position are | ||
| 581 | searched instead, text properties are taken from the mouse click | ||
| 582 | position in the buffer rather than point, and if the click happens on a | ||
| 583 | string embedded with a @code{display}, @code{before-string}, or | ||
| 584 | @code{after-string} text property (@pxref{Special Properties}) or | ||
| 585 | overlay property (@pxref{Overlay Properties}), any non-@code{nil} maps | ||
| 586 | specified with text properties of this string are searched instead of | ||
| 587 | those of the buffer. | ||
| 588 | |||
| 579 | The @dfn{global keymap} holds the bindings of keys that are defined | 589 | The @dfn{global keymap} holds the bindings of keys that are defined |
| 580 | regardless of the current buffer, such as @kbd{C-f}. The variable | 590 | regardless of the current buffer, such as @kbd{C-f}. The variable |
| 581 | @code{global-map} holds this keymap, which is always active. | 591 | @code{global-map} holds this keymap, which is always active. |
| @@ -632,25 +642,27 @@ Normally it ignores @code{overriding-local-map} and | |||
| 632 | non-@code{nil} then it pays attention to them. | 642 | non-@code{nil} then it pays attention to them. |
| 633 | @end defun | 643 | @end defun |
| 634 | 644 | ||
| 635 | @defun key-binding key &optional accept-defaults no-remap | 645 | @defun key-binding key &optional accept-defaults no-remap position |
| 636 | This function returns the binding for @var{key} according to the | 646 | This function returns the binding for @var{key} according to the current |
| 637 | current active keymaps. The result is @code{nil} if @var{key} is | 647 | active keymaps. The result is @code{nil} if @var{key} is undefined in |
| 638 | undefined in the keymaps. | 648 | the keymaps. If @var{key} is a key sequence started with the mouse, the |
| 649 | consulted maps will be changed accordingly. | ||
| 639 | 650 | ||
| 640 | @c Emacs 19 feature | 651 | @c Emacs 19 feature |
| 641 | The argument @var{accept-defaults} controls checking for default | 652 | The argument @var{accept-defaults} controls checking for default |
| 642 | bindings, as in @code{lookup-key} (above). | 653 | bindings, as in @code{lookup-key} (above). |
| 643 | 654 | ||
| 644 | When @var{key} is a vector containing an input event, such as a mouse | ||
| 645 | click, @code{key-binding} first looks for the binding in the keymaps | ||
| 646 | that would be active at the position where the click was done. | ||
| 647 | |||
| 648 | When commands are remapped (@pxref{Remapping Commands}), | 655 | When commands are remapped (@pxref{Remapping Commands}), |
| 649 | @code{key-binding} normally processes command remappings so as to | 656 | @code{key-binding} normally processes command remappings so as to |
| 650 | returns the remapped command that will actually be executed. However, | 657 | returns the remapped command that will actually be executed. However, |
| 651 | if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores | 658 | if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores |
| 652 | remappings and returns the binding directly specified for @var{key}. | 659 | remappings and returns the binding directly specified for @var{key}. |
| 653 | 660 | ||
| 661 | If @var{position} is non-@code{nil}, it specifies either a buffer | ||
| 662 | position or a position like those returned from @code{event-start}. In | ||
| 663 | this case, @var{position} instead of @var{key} determines the | ||
| 664 | click-specific maps. | ||
| 665 | |||
| 654 | An error is signaled if @var{key} is not a string or a vector. | 666 | An error is signaled if @var{key} is not a string or a vector. |
| 655 | 667 | ||
| 656 | @example | 668 | @example |
| @@ -674,21 +686,24 @@ them: | |||
| 674 | (@var{find-in} overriding-terminal-local-map) | 686 | (@var{find-in} overriding-terminal-local-map) |
| 675 | (if overriding-local-map | 687 | (if overriding-local-map |
| 676 | (@var{find-in} overriding-local-map) | 688 | (@var{find-in} overriding-local-map) |
| 677 | (or (@var{find-in} (get-text-property (point) 'keymap)) | 689 | (or (@var{find-in} (get-char-property (point) 'keymap)) |
| 678 | (@var{find-in-any} emulation-mode-map-alists) | 690 | (@var{find-in-any} emulation-mode-map-alists) |
| 679 | (@var{find-in-any} minor-mode-overriding-map-alist) | 691 | (@var{find-in-any} minor-mode-overriding-map-alist) |
| 680 | (@var{find-in-any} minor-mode-map-alist) | 692 | (@var{find-in-any} minor-mode-map-alist) |
| 681 | (if (get-text-property (point) 'local-map) | 693 | (if (get-text-property (point) 'local-map) |
| 682 | (@var{find-in} (get-text-property (point) 'local-map)) | 694 | (@var{find-in} (get-char-property (point) 'local-map)) |
| 683 | (@var{find-in} (current-local-map)))))) | 695 | (@var{find-in} (current-local-map)))))) |
| 684 | (@var{find-in} (current-global-map))) | 696 | (@var{find-in} (current-global-map))) |
| 685 | @end lisp | 697 | @end lisp |
| 686 | 698 | ||
| 687 | @noindent | 699 | @noindent |
| 688 | The @var{find-in} and @var{find-in-any} are pseudo functions that | 700 | The @var{find-in} and @var{find-in-any} are pseudo functions that search |
| 689 | search in one keymap and in an alist of keymaps, respectively. | 701 | in one keymap and in an alist of keymaps, respectively. (Searching a |
| 690 | (Searching a single keymap for a binding is called @dfn{key lookup}; | 702 | single keymap for a binding is called @dfn{key lookup}; see @ref{Key |
| 691 | see @ref{Key Lookup}.) | 703 | Lookup}.) Mouse events on strings will use text properties from the |
| 704 | string if non-@code{nil} instead of the buffer. Also, point and current | ||
| 705 | buffer for mouse-based events are switched to correspond to the position | ||
| 706 | of the event start while performing the lookup. | ||
| 692 | 707 | ||
| 693 | @enumerate | 708 | @enumerate |
| 694 | @item | 709 | @item |
| @@ -1450,11 +1465,13 @@ does not have the effect of remapping @code{kill-line} into | |||
| 1450 | if an ordinary binding specifies @code{my-kill-line}, this keymap will | 1465 | if an ordinary binding specifies @code{my-kill-line}, this keymap will |
| 1451 | remap it to @code{my-other-kill-line}. | 1466 | remap it to @code{my-other-kill-line}. |
| 1452 | 1467 | ||
| 1453 | @defun command-remapping command | 1468 | @defun command-remapping command &optional position |
| 1454 | This function returns the remapping for @var{command} (a symbol), | 1469 | This function returns the remapping for @var{command} (a symbol), given |
| 1455 | given the current active keymaps. If @var{command} is not remapped | 1470 | the current active keymaps. If @var{command} is not remapped (which is |
| 1456 | (which is the usual situation), or not a symbol, the function returns | 1471 | the usual situation), or not a symbol, the function returns @code{nil}. |
| 1457 | @code{nil}. | 1472 | @code{position} can optionally specify a buffer position or a position |
| 1473 | like those returned from @code{event-start}: in that case, the active | ||
| 1474 | maps are changed like they are in @code{key-binding}. | ||
| 1458 | @end defun | 1475 | @end defun |
| 1459 | 1476 | ||
| 1460 | @node Translation Keymaps | 1477 | @node Translation Keymaps |