Changeset 4166 for trunk/lispref/keymaps.texi
- Timestamp:
- 09/18/06 20:48:14 (2 years ago)
- Files:
-
- trunk/lispref/keymaps.texi (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lispref/keymaps.texi
r4148 r4166 570 570 interpretation of user input. All the active keymaps are used 571 571 together to determine what command to execute when a key is entered. 572 Emacs searches these keymaps one by one, in a standard order, until it573 finds a binding in one of the keymaps.574 572 575 573 Normally the active keymaps are the @code{keymap} property keymap, 576 574 the keymaps of any enabled minor modes, the current buffer's local 577 keymap, and the global keymap, in that order. Therefore, Emacs 578 searches for each input key sequence in all these keymaps. Here is a 579 pseudo-Lisp description of how this process works: 580 581 @lisp 582 (or (if overriding-terminal-local-map 583 (@var{find-in} overriding-terminal-local-map) 584 (if overriding-local-map 585 (@var{find-in} overriding-local-map) 586 (or (@var{find-in} (get-text-property (point) 'keymap)) 587 (@var{find-in-any} emulation-mode-map-alists) 588 (@var{find-in-any} minor-mode-overriding-map-alist) 589 (@var{find-in-any} minor-mode-map-alist) 590 (if (get-text-property (point) 'local-map) 591 (@var{find-in} (get-text-property (point) 'local-map)) 592 (@var{find-in} (current-local-map)))))) 593 (@var{find-in} (current-global-map))) 594 @end lisp 595 596 @noindent 597 Here, the pseudo-function @var{find-in} means to look up the key 598 sequence in a single map, and @var{find-in-any} means to search the 599 appropriate keymaps from an alist. (Searching a single keymap for a 600 binding is called @dfn{key lookup}; see @ref{Key Lookup}.) 575 keymap, and the global keymap, in that order. Emacs searches for each 576 input key sequence in all these keymaps. @xref{Searching Keymaps}, 577 for more details of this procedure. 578 579 When the key sequence starts with a mouse event (optionally preceded 580 by a symbolic prefix), the active keymaps are determined based on the 581 position in that event. If the event happened on a string embedded 582 with a @code{display}, @code{before-string}, or @code{after-string} 583 property (@pxref{Special Properties}), the non-@code{nil} map 584 properties of the string override those of the buffer. 601 585 602 586 The @dfn{global keymap} holds the bindings of keys that are defined … … 656 640 @end defun 657 641 658 @defun key-binding key &optional accept-defaults no-remap 642 @defun key-binding key &optional accept-defaults no-remap position 659 643 This function returns the binding for @var{key} according to the 660 644 current active keymaps. The result is @code{nil} if @var{key} is 661 645 undefined in the keymaps. 662 646 663 @c Emacs 19 feature664 647 The argument @var{accept-defaults} controls checking for default 665 648 bindings, as in @code{lookup-key} (above). … … 671 654 remappings and returns the binding directly specified for @var{key}. 672 655 656 If @var{key} starts with a mouse event (perhaps following a prefix 657 event), the maps to be consulted are determined based on the event's 658 position. Otherwise, they are determined based on the value of point. 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}. 663 673 664 An error is signaled if @var{key} is not a string or a vector. 674 665 … … 684 675 @section Searching the Active Keymaps 685 676 686 After translation of event subsequences (@pxref{Translation Keymaps}) 687 Emacs looks for them in the active keymaps. Here is a pseudo-Lisp 688 description of the order in which the active keymaps are searched: 677 After translation of event subsequences (@pxref{Translation 678 Keymaps}) Emacs looks for them in the active keymaps. Here is a 679 pseudo-Lisp description of the order and conditions for searching 680 them: 689 681 690 682 @lisp … … 693 685 (if overriding-local-map 694 686 (@var{find-in} overriding-local-map) 695 (or (@var{find-in} (get- text-property (point) 'keymap))687 (or (@var{find-in} (get-char-property (point) 'keymap)) 696 688 (@var{find-in-any} emulation-mode-map-alists) 697 689 (@var{find-in-any} minor-mode-overriding-map-alist) 698 690 (@var{find-in-any} minor-mode-map-alist) 699 691 (if (get-text-property (point) 'local-map) 700 (@var{find-in} (get- text-property (point) 'local-map))692 (@var{find-in} (get-char-property (point) 'local-map)) 701 693 (@var{find-in} (current-local-map)))))) 702 694 (@var{find-in} (current-global-map))) … … 706 698 The @var{find-in} and @var{find-in-any} are pseudo functions that 707 699 search in one keymap and in an alist of keymaps, respectively. 700 (Searching a single keymap for a binding is called @dfn{key lookup}; 701 see @ref{Key Lookup}.) If the key sequence starts with a mouse event, 702 or a symbolic prefix event followed by a mouse event, that event's 703 position is used instead of point and the current buffer. Mouse 704 events on an embedded string use text properties from that string 705 instead of the buffer. 708 706 709 707 @enumerate … … 1467 1465 remap it to @code{my-other-kill-line}. 1468 1466 1469 @defun command-remapping command 1467 @defun command-remapping command &optional position 1470 1468 This function returns the remapping for @var{command} (a symbol), 1471 1469 given the current active keymaps. If @var{command} is not remapped 1472 1470 (which is the usual situation), or not a symbol, the function returns 1473 @code{nil}. 1471 @code{nil}. @code{position} can optionally specify a buffer position 1472 or an event position to determine the keymaps to use, as in 1473 @code{key-binding}. 1474 1474 @end defun 1475 1475
