Show
Ignore:
Timestamp:
09/18/06 20:48:14 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lispref/keymaps.texi

    r4148 r4166  
    570570interpretation of user input.  All the active keymaps are used 
    571571together to determine what command to execute when a key is entered. 
    572 Emacs searches these keymaps one by one, in a standard order, until it 
    573 finds a binding in one of the keymaps. 
    574572 
    575573  Normally the active keymaps are the @code{keymap} property keymap, 
    576574the 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}.) 
     575keymap, and the global keymap, in that order.  Emacs searches for each 
     576input key sequence in all these keymaps.  @xref{Searching Keymaps}, 
     577for more details of this procedure. 
     578 
     579  When the key sequence starts with a mouse event (optionally preceded 
     580by a symbolic prefix), the active keymaps are determined based on the 
     581position in that event.  If the event happened on a string embedded 
     582with a @code{display}, @code{before-string}, or @code{after-string} 
     583property (@pxref{Special Properties}), the non-@code{nil} map 
     584properties of the string override those of the buffer. 
    601585 
    602586  The @dfn{global keymap} holds the bindings of keys that are defined 
     
    656640@end defun 
    657641 
    658 @defun key-binding key &optional accept-defaults no-remap 
     642@defun key-binding key &optional accept-defaults no-remap position 
    659643This function returns the binding for @var{key} according to the 
    660644current active keymaps.  The result is @code{nil} if @var{key} is 
    661645undefined in the keymaps. 
    662646 
    663 @c Emacs 19 feature 
    664647The argument @var{accept-defaults} controls checking for default 
    665648bindings, as in @code{lookup-key} (above). 
     
    671654remappings and returns the binding directly specified for @var{key}. 
    672655 
     656If @var{key} starts with a mouse event (perhaps following a prefix 
     657event), the maps to be consulted are determined based on the event's 
     658position.  Otherwise, they are determined based on the value of point. 
     659However, you can override either of them by specifying @var{position}. 
     660If @var{position} is non-@code{nil}, it should be either a buffer 
     661position or an event position like the value of @code{event-start}. 
     662Then the maps consulted are determined based on @var{position}. 
     663 
    673664An error is signaled if @var{key} is not a string or a vector. 
    674665 
     
    684675@section Searching the Active Keymaps 
    685676 
    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 
     678Keymaps}) Emacs looks for them in the active keymaps.  Here is a 
     679pseudo-Lisp description of the order and conditions for searching 
     680them: 
    689681 
    690682@lisp 
     
    693685      (if overriding-local-map 
    694686          (@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)) 
    696688            (@var{find-in-any} emulation-mode-map-alists) 
    697689            (@var{find-in-any} minor-mode-overriding-map-alist) 
    698690            (@var{find-in-any} minor-mode-map-alist) 
    699691            (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)) 
    701693              (@var{find-in} (current-local-map)))))) 
    702694    (@var{find-in} (current-global-map))) 
     
    706698The @var{find-in} and @var{find-in-any} are pseudo functions that 
    707699search in one keymap and in an alist of keymaps, respectively. 
     700(Searching a single keymap for a binding is called @dfn{key lookup}; 
     701see @ref{Key Lookup}.)  If the key sequence starts with a mouse event, 
     702or a symbolic prefix event followed by a mouse event, that event's 
     703position is used instead of point and the current buffer.  Mouse 
     704events on an embedded string use text properties from that string 
     705instead of the buffer. 
    708706 
    709707@enumerate 
     
    14671465remap it to @code{my-other-kill-line}. 
    14681466 
    1469 @defun command-remapping command 
     1467@defun command-remapping command &optional position 
    14701468This function returns the remapping for @var{command} (a symbol), 
    14711469given the current active keymaps.  If @var{command} is not remapped 
    14721470(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 
     1472or an event position to determine the keymaps to use, as in 
     1473@code{key-binding}. 
    14741474@end defun 
    14751475