aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorDavid Kastrup2006-09-15 07:19:15 +0000
committerDavid Kastrup2006-09-15 07:19:15 +0000
commitb74e16a384ddbded12eb7e8c7250253614554641 (patch)
tree287d09b973259b6101ae03baec0e0c91c848232a /lispref
parent6266eb4a51f75b4e31895cd8d8be1ddd5a18e076 (diff)
downloademacs-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/ChangeLog12
-rw-r--r--lispref/keymaps.texi55
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 @@
12006-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
12006-09-14 Richard Stallman <rms@gnu.org> 102006-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
132006-09-11 Richard Stallman <rms@gnu.org> 232006-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
48742001-10-31 Pavel Jan,Bm(Bk <Pavel@Janik.cz> 48842001-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
576input key sequence in all these keymaps. @xref{Searching Keymaps}, 576input key sequence in all these keymaps. @xref{Searching Keymaps},
577for more details of this procedure. 577for more details of this procedure.
578 578
579This process is somewhat modified for mouse events: the local modes and
580keymaps of the buffer corresponding to the mouse click position are
581searched instead, text properties are taken from the mouse click
582position in the buffer rather than point, and if the click happens on a
583string embedded with a @code{display}, @code{before-string}, or
584@code{after-string} text property (@pxref{Special Properties}) or
585overlay property (@pxref{Overlay Properties}), any non-@code{nil} maps
586specified with text properties of this string are searched instead of
587those 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
580regardless of the current buffer, such as @kbd{C-f}. The variable 590regardless 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
632non-@code{nil} then it pays attention to them. 642non-@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
636This function returns the binding for @var{key} according to the 646This function returns the binding for @var{key} according to the current
637current active keymaps. The result is @code{nil} if @var{key} is 647active keymaps. The result is @code{nil} if @var{key} is undefined in
638undefined in the keymaps. 648the keymaps. If @var{key} is a key sequence started with the mouse, the
649consulted maps will be changed accordingly.
639 650
640@c Emacs 19 feature 651@c Emacs 19 feature
641The argument @var{accept-defaults} controls checking for default 652The argument @var{accept-defaults} controls checking for default
642bindings, as in @code{lookup-key} (above). 653bindings, as in @code{lookup-key} (above).
643 654
644When @var{key} is a vector containing an input event, such as a mouse
645click, @code{key-binding} first looks for the binding in the keymaps
646that would be active at the position where the click was done.
647
648When commands are remapped (@pxref{Remapping Commands}), 655When 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
650returns the remapped command that will actually be executed. However, 657returns the remapped command that will actually be executed. However,
651if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores 658if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores
652remappings and returns the binding directly specified for @var{key}. 659remappings and returns the binding directly specified for @var{key}.
653 660
661If @var{position} is non-@code{nil}, it specifies either a buffer
662position or a position like those returned from @code{event-start}. In
663this case, @var{position} instead of @var{key} determines the
664click-specific maps.
665
654An error is signaled if @var{key} is not a string or a vector. 666An 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
688The @var{find-in} and @var{find-in-any} are pseudo functions that 700The @var{find-in} and @var{find-in-any} are pseudo functions that search
689search in one keymap and in an alist of keymaps, respectively. 701in one keymap and in an alist of keymaps, respectively. (Searching a
690(Searching a single keymap for a binding is called @dfn{key lookup}; 702single keymap for a binding is called @dfn{key lookup}; see @ref{Key
691see @ref{Key Lookup}.) 703Lookup}.) Mouse events on strings will use text properties from the
704string if non-@code{nil} instead of the buffer. Also, point and current
705buffer for mouse-based events are switched to correspond to the position
706of 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
1450if an ordinary binding specifies @code{my-kill-line}, this keymap will 1465if an ordinary binding specifies @code{my-kill-line}, this keymap will
1451remap it to @code{my-other-kill-line}. 1466remap it to @code{my-other-kill-line}.
1452 1467
1453@defun command-remapping command 1468@defun command-remapping command &optional position
1454This function returns the remapping for @var{command} (a symbol), 1469This function returns the remapping for @var{command} (a symbol), given
1455given the current active keymaps. If @var{command} is not remapped 1470the current active keymaps. If @var{command} is not remapped (which is
1456(which is the usual situation), or not a symbol, the function returns 1471the 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
1473like those returned from @code{event-start}: in that case, the active
1474maps 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