comparison lispref/keymaps.texi @ 72905:310304c34121

(Remapping Commands, Searching Keymaps) (Active Keymaps): Clean up previous change.
author Richard M. Stallman <rms@gnu.org>
date Fri, 15 Sep 2006 18:29:01 +0000
parents 25c755416160
children 7ee455606dfd
comparison
equal deleted inserted replaced
72904:425ede302504 72905:310304c34121
574 the keymaps of any enabled minor modes, the current buffer's local 574 the keymaps of any enabled minor modes, the current buffer's local
575 keymap, and the global keymap, in that order. Emacs searches for each 575 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 579 When the key sequence starts with a mouse event (optionally preceded
580 keymaps of the buffer corresponding to the mouse click position are 580 by a symbolic prefix), the active keymaps are determined based on the
581 searched instead, text properties are taken from the mouse click 581 position in that event. If the event happened on a string embedded
582 position in the buffer rather than point, and if the click happens on a 582 with a @code{display}, @code{before-string}, or @code{after-string}
583 string embedded with a @code{display}, @code{before-string}, or 583 property (@pxref{Special Properties}), the non-@code{nil} map
584 @code{after-string} text property (@pxref{Special Properties}) or 584 properties of the string override those of the buffer.
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 585
589 The @dfn{global keymap} holds the bindings of keys that are defined 586 The @dfn{global keymap} holds the bindings of keys that are defined
590 regardless of the current buffer, such as @kbd{C-f}. The variable 587 regardless of the current buffer, such as @kbd{C-f}. The variable
591 @code{global-map} holds this keymap, which is always active. 588 @code{global-map} holds this keymap, which is always active.
592 589
641 @code{overriding-terminal-local-map}, but if @var{olp} is 638 @code{overriding-terminal-local-map}, but if @var{olp} is
642 non-@code{nil} then it pays attention to them. 639 non-@code{nil} then it pays attention to them.
643 @end defun 640 @end defun
644 641
645 @defun key-binding key &optional accept-defaults no-remap position 642 @defun key-binding key &optional accept-defaults no-remap position
646 This function returns the binding for @var{key} according to the current 643 This function returns the binding for @var{key} according to the
647 active keymaps. The result is @code{nil} if @var{key} is undefined in 644 current active keymaps. The result is @code{nil} if @var{key} is
648 the keymaps. If @var{key} is a key sequence started with the mouse, the 645 undefined in the keymaps.
649 consulted maps will be changed accordingly. 646
650
651 @c Emacs 19 feature
652 The argument @var{accept-defaults} controls checking for default 647 The argument @var{accept-defaults} controls checking for default
653 bindings, as in @code{lookup-key} (above). 648 bindings, as in @code{lookup-key} (above).
654 649
655 When commands are remapped (@pxref{Remapping Commands}), 650 When commands are remapped (@pxref{Remapping Commands}),
656 @code{key-binding} normally processes command remappings so as to 651 @code{key-binding} normally processes command remappings so as to
657 returns the remapped command that will actually be executed. However, 652 returns the remapped command that will actually be executed. However,
658 if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores 653 if @var{no-remap} is non-@code{nil}, @code{key-binding} ignores
659 remappings and returns the binding directly specified for @var{key}. 654 remappings and returns the binding directly specified for @var{key}.
660 655
661 If @var{position} is non-@code{nil}, it specifies either a buffer 656 If @var{key} starts with a mouse event (perhaps following a prefix
662 position or a position like those returned from @code{event-start}. In 657 event), the maps to be consulted are determined based on the event's
663 this case, @var{position} instead of @var{key} determines the 658 position. Otherwise, they are determined based on the value of point.
664 click-specific maps. 659 However, you can override either of them by specifying @var{position}.
660 If @var{position} is non-@code{nil}, it should be either a buffer
661 position or an event position like the value of @code{event-start}.
662 Then the maps consulted are determined based on @var{position}.
665 663
666 An error is signaled if @var{key} is not a string or a vector. 664 An error is signaled if @var{key} is not a string or a vector.
667 665
668 @example 666 @example
669 @group 667 @group
695 (@var{find-in} (current-local-map)))))) 693 (@var{find-in} (current-local-map))))))
696 (@var{find-in} (current-global-map))) 694 (@var{find-in} (current-global-map)))
697 @end lisp 695 @end lisp
698 696
699 @noindent 697 @noindent
700 The @var{find-in} and @var{find-in-any} are pseudo functions that search 698 The @var{find-in} and @var{find-in-any} are pseudo functions that
701 in one keymap and in an alist of keymaps, respectively. (Searching a 699 search in one keymap and in an alist of keymaps, respectively.
702 single keymap for a binding is called @dfn{key lookup}; see @ref{Key 700 (Searching a single keymap for a binding is called @dfn{key lookup};
703 Lookup}.) Mouse events on strings will use text properties from the 701 see @ref{Key Lookup}.) If the key sequence starts with a mouse event,
704 string if non-@code{nil} instead of the buffer. Also, point and current 702 or a symbolic prefix event followed by a mouse event, that event's
705 buffer for mouse-based events are switched to correspond to the position 703 position is used instead of point and the current buffer. Mouse
706 of the event start while performing the lookup. 704 events on an embedded string use text properties from that string
705 instead of the buffer.
707 706
708 @enumerate 707 @enumerate
709 @item 708 @item
710 The function finally found may be remapped 709 The function finally found may be remapped
711 (@pxref{Remapping Commands}). 710 (@pxref{Remapping Commands}).
1464 @code{kill-line}, this keymap will remap it to @code{my-kill-line}; 1463 @code{kill-line}, this keymap will remap it to @code{my-kill-line};
1465 if an ordinary binding specifies @code{my-kill-line}, this keymap will 1464 if an ordinary binding specifies @code{my-kill-line}, this keymap will
1466 remap it to @code{my-other-kill-line}. 1465 remap it to @code{my-other-kill-line}.
1467 1466
1468 @defun command-remapping command &optional position 1467 @defun command-remapping command &optional position
1469 This function returns the remapping for @var{command} (a symbol), given 1468 This function returns the remapping for @var{command} (a symbol),
1470 the current active keymaps. If @var{command} is not remapped (which is 1469 given the current active keymaps. If @var{command} is not remapped
1471 the usual situation), or not a symbol, the function returns @code{nil}. 1470 (which is the usual situation), or not a symbol, the function returns
1472 @code{position} can optionally specify a buffer position or a position 1471 @code{nil}. @code{position} can optionally specify a buffer position
1473 like those returned from @code{event-start}: in that case, the active 1472 or an event position to determine the keymaps to use, as in
1474 maps are changed like they are in @code{key-binding}. 1473 @code{key-binding}.
1475 @end defun 1474 @end defun
1476 1475
1477 @node Translation Keymaps 1476 @node Translation Keymaps
1478 @section Keymaps for Translating Sequences of Events 1477 @section Keymaps for Translating Sequences of Events
1479 1478