annotate man/lispref/keymaps.texi @ 5378:4f0a1f4cc111

Improve support for min-colors req in `defface'. lisp/faces.el (face-spec-set-match-display): Protect against `display-color-cells' returning nil. Delete unreferenced let-binding of `min-colors'. man/lispref/customize.texi (Face Definitions): New node. (Customization): Add entry to menu. (Variable Definitions): Add cross-ref for `defface'. (Customization Types): Fixup Previous link. man/lispref/faces.texi (Faces): Clarify that built-in properties of faces are computed at runtime.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 19 Mar 2011 22:13:14 +0900
parents a25c824ed558
children a81a739181dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 @c Copyright (C) 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 @c See the file lispref.texi for copying conditions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 @setfilename ../../info/keymaps.info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 @node Keymaps, Menus, Command Loop, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 @chapter Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 @cindex keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 @c This section is largely different from the one in FSF Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 The bindings between input events and commands are recorded in data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 structures called @dfn{keymaps}. Each binding in a keymap associates
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 (or @dfn{binds}) an individual event type either with another keymap or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 with a command. When an event is bound to a keymap, that keymap is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 used to look up the next input event; this continues until a command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 is found. The whole process is called @dfn{key lookup}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 * Keymap Terminology:: Definitions of terms pertaining to keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * Format of Keymaps:: What a keymap looks like as a Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 * Creating Keymaps:: Functions to create and copy keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Inheritance and Keymaps:: How one keymap can inherit the bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 of another keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Key Sequences:: How to specify key sequences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * Prefix Keys:: Defining a key with a keymap as its definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * Active Keymaps:: Each buffer has a local keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 to override the standard (global) bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 A minor mode can also override them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * Key Lookup:: How extracting elements from keymaps works.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 * Functions for Key Lookup:: How to request key lookup.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * Changing Key Bindings:: Redefining a key in a keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 * Key Binding Commands:: Interactive interfaces for redefining keys.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 * Scanning Keymaps:: Looking through all keymaps, for printing help.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 * Other Keymap Functions:: Miscellaneous keymap functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 @node Keymap Terminology
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 @section Keymap Terminology
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 @cindex key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 @cindex keystroke
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 @cindex key binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 @cindex binding of a key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 @cindex complete key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 @cindex undefined key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 A @dfn{keymap} is a table mapping event types to definitions (which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 can be any Lisp objects, though only certain types are meaningful for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 execution by the command loop). Given an event (or an event type) and a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 keymap, XEmacs can get the event's definition. Events mapped in keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 include keypresses, button presses, and button releases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (@pxref{Events}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 A sequence of input events that form a unit is called a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 @dfn{key sequence}, or @dfn{key} for short. A sequence of one event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 is always a key sequence, and so are some multi-event sequences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 A keymap determines a binding or definition for any key sequence. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 the key sequence is a single event, its binding is the definition of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 event in the keymap. The binding of a key sequence of more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 event is found by an iterative process: the binding of the first event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 is found, and must be a keymap; then the second event's binding is found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 in that keymap, and so on until all the events in the key sequence are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 used up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 If the binding of a key sequence is a keymap, we call the key sequence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 a @dfn{prefix key}. Otherwise, we call it a @dfn{complete key} (because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 no more events can be added to it). If the binding is @code{nil},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 we call the key @dfn{undefined}. Examples of prefix keys are @kbd{C-c},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 @kbd{C-x}, and @kbd{C-x 4}. Examples of defined complete keys are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 @kbd{X}, @key{RET}, and @kbd{C-x 4 C-f}. Examples of undefined complete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 keys are @kbd{C-x C-g}, and @kbd{C-c 3}. @xref{Prefix Keys}, for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 The rule for finding the binding of a key sequence assumes that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 intermediate bindings (found for the events before the last) are all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 keymaps; if this is not so, the sequence of events does not form a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 unit---it is not really a key sequence. In other words, removing one or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 more events from the end of any valid key must always yield a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 key. For example, @kbd{C-f C-n} is not a key; @kbd{C-f} is not a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 key, so a longer sequence starting with @kbd{C-f} cannot be a key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 Note that the set of possible multi-event key sequences depends on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 bindings for prefix keys; therefore, it can be different for different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 keymaps, and can change when bindings are changed. However, a one-event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 sequence is always a key sequence, because it does not depend on any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 prefix keys for its well-formedness.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 At any time, several primary keymaps are @dfn{active}---that is, in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 use for finding key bindings. These are the @dfn{global map}, which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 shared by all buffers; the @dfn{local keymap}, which is usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 associated with a specific major mode; and zero or more @dfn{minor mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 keymaps}, which belong to currently enabled minor modes. (Not all minor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 modes have keymaps.) The local keymap bindings shadow (i.e., take
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 precedence over) the corresponding global bindings. The minor mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 keymaps shadow both local and global keymaps. @xref{Active Keymaps},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 for details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 @node Format of Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 @section Format of Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 @cindex format of keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 @cindex keymap format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 A keymap is a primitive type that associates events with their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 bindings. Note that this is different from Emacs 18 and FSF Emacs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 where keymaps are lists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 @defun keymapp object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 This function returns @code{t} if @var{object} is a keymap, @code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 otherwise.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 @node Creating Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 @section Creating Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 @cindex creating keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 Here we describe the functions for creating keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 @defun make-keymap &optional name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 This function constructs and returns a new keymap object. All entries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 in it are @code{nil}, meaning ``command undefined''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 Optional argument @var{name} specifies a name to assign to the keymap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 as in @code{set-keymap-name}. This name is only a debugging
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 convenience; it is not used except when printing the keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 @defun make-sparse-keymap &optional name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 This function constructs and returns a new keymap object. All entries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 in it are @code{nil}, meaning ``command undefined''. The only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 difference between this function and @code{make-keymap} is that this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 function returns a ``smaller'' keymap (one that is expected to contain
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
134 fewer entries). As keymaps dynamically resize, this distinction is not
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 great.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 Optional argument @var{name} specifies a name to assign to the keymap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 as in @code{set-keymap-name}. This name is only a debugging
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 convenience; it is not used except when printing the keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 @defun set-keymap-name keymap new-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 This function assigns a ``name'' to a keymap. The name is only a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 debugging convenience; it is not used except when printing the keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 @defun keymap-name keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 This function returns the ``name'' of a keymap, as assigned using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 @code{set-keymap-name}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 @defun copy-keymap keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 This function returns a copy of @var{keymap}. Any keymaps that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 appear directly as bindings in @var{keymap} are also copied recursively,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 and so on to any number of levels. However, recursive copying does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 take place when the definition of a character is a symbol whose function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 definition is a keymap; the same symbol appears in the new copy.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (setq map (copy-keymap (current-local-map)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 @result{} #<keymap 3 entries 0x21f80>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (eq map (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 @ignore @c Doesn't work!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (equal map (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 @result{} t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 @end ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 @node Inheritance and Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 @section Inheritance and Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 @cindex keymap inheritance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 @cindex inheriting a keymap's bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 @cindex keymap parent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 @cindex parent of a keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 A keymap can inherit the bindings of other keymaps. The other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 keymaps are called the keymap's @dfn{parents}, and are set with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 @code{set-keymap-parents}. When searching for a binding for a key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 sequence in a particular keymap, that keymap itself will first be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 searched; then, if no binding was found in the map and it has parents,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 the first parent keymap will be searched; then that keymap's parent will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 be searched, and so on, until either a binding for the key sequence is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 found, or a keymap without a parent is encountered. At this point,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 the search will continue with the next parent of the most recently
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 encountered keymap that has another parent, etc. Essentially, a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 depth-first search of all the ancestors of the keymap is conducted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 @code{(current-global-map)} is the default parent of all keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 @defun set-keymap-parents keymap parents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 This function sets the parent keymaps of @var{keymap} to the list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 @var{parents}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 If you change the bindings in one of the keymaps in @var{parents} using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 @code{define-key} or other key-binding functions, these changes are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 visible in @var{keymap} unless shadowed by bindings in that map or in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 earlier-searched ancestors. The converse is not true: if you use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 @code{define-key} to change @var{keymap}, that affects the bindings in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 that map, but has no effect on any of the keymaps in @var{parents}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 @defun keymap-parents keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 This function returns the list of parent keymaps of @var{keymap}, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 @code{nil} if @var{keymap} has no parents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 As an alternative to specifying a parent, you can also specify a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 @dfn{default binding} that is used whenever a key is not otherwise bound
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 in the keymap. This is useful for terminal emulators, for example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 which may want to trap all keystrokes and pass them on in some modified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 format. Note that if you specify a default binding for a keymap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 neither the keymap's parents nor the current global map are searched for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 key bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 @defun set-keymap-default-binding keymap command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 This function sets the default binding of @var{keymap} to @var{command},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 or @code{nil} if no default is desired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 @defun keymap-default-binding keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 This function returns the default binding of @var{keymap}, or @code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 if it has none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 @node Key Sequences
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 @section Key Sequences
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 @cindex key sequences
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 Contrary to popular belief, the world is not @sc{ascii}. When running
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 under a window manager, XEmacs can tell the difference between, for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 example, the keystrokes @kbd{control-h}, @kbd{control-shift-h}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 @kbd{backspace}. You can, in fact, bind different commands to each of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 these.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 A @dfn{key sequence} is a set of keystrokes. A @dfn{keystroke} is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 keysym and some set of modifiers (such as @key{CONTROL} and @key{META}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 A @dfn{keysym} is what is printed on the keys on your keyboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
2828
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
248 A keysym may be represented by a symbol, by a character, or by a
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
249 character's Mule code. The @kbd{A} key may be represented by the symbol
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
250 @code{A}, the character @code{?A}, or by the number 65. The @kbd{break}
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
251 key may be represented only by the symbol @code{break}, and non-ASCII
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
252 X11 keys in general are limited to the symbol form with XEmacs.
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
253 @footnote{A quirk of our X11 implementation means that non-ASCII keysyms
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
254 have different internal representations in the X11 (with GTK) and other
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
255 worlds (like the TTY, or Microsoft Windows), so, for example, binding
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
256 @kbd{EuroSign} to a command will normally work, but will not invoke that
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
257 command if someone presses the Euro sign in a TTY console; conversely,
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
258 binding @code{(make-char 'latin-iso8859-15 #xa4)} or @code{(char-to-int
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
259 (make-char 'latin-iso8859-15 #xa4))} to a command will call that command
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
260 on a TTY console, but not in an X11 window of the same process.}
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
261 @footnote{See the documentation for `set-input-mode' and
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
262 `set-console-tty-coding-system' if you're having trouble inputting
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 446
diff changeset
263 non-ASCII characters in the TTY.}
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 A keystroke may be represented by a list: the last element of the list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 is the key (a symbol, character, or number, as above) and the preceding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 elements are the symbolic names of modifier keys (@key{CONTROL},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 @key{META}, @key{SUPER}, @key{HYPER}, @key{ALT}, and @key{SHIFT}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 Thus, the sequence @kbd{control-b} is represented by the forms
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 @code{(control b)}, @code{(control ?b)}, and @code{(control 98)}. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 keystroke may also be represented by an event object, as returned by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 @code{next-command-event} and @code{read-key-sequence} functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 Note that in this context, the keystroke @kbd{control-b} is @emph{not}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 represented by the number 2 (the @sc{ascii} code for @samp{^B}) or the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 character @code{?\^B}. See below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 The @key{SHIFT} modifier is somewhat of a special case. You should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 not (and cannot) use @code{(meta shift a)} to mean @code{(meta A)},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 since for characters that have @sc{ascii} equivalents, the state of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 shift key is implicit in the keysym (@samp{a} vs. @samp{A}). You also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 cannot say @code{(shift =)} to mean @code{+}, as that sort of thing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 varies from keyboard to keyboard. The @key{SHIFT} modifier is for use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 only with characters that do not have a second keysym on the same key,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 such as @code{backspace} and @code{tab}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 A key sequence is a vector of keystrokes. As a degenerate case,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 elements of this vector may also be keysyms if they have no modifiers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 That is, the @kbd{A} keystroke is represented by all of these forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
292 A ?A 65 (A) (?A) (65)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
293 [A] [?A] [65] [(A)] [(?A)] [(65)]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 @end example
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
295
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 the @kbd{control-a} keystroke is represented by these forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
299 (control A) (control ?A) (control 65)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
300 [(control A)] [(control ?A)] [(control 65)]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 the key sequence @kbd{control-c control-a} is represented by these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
307 [(control c) (control a)] [(control ?c) (control ?a)]
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
308 [(control 99) (control 65)] etc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 Mouse button clicks work just like keypresses: @code{(control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 button1)} means pressing the left mouse button while holding down the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 control key. @code{[(control c) (shift button3)]} means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 @kbd{control-c}, hold @key{SHIFT}, click right.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 Commands may be bound to the mouse-button up-stroke rather than the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 down-stroke as well. @code{button1} means the down-stroke, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 @code{button1up} means the up-stroke. Different commands may be bound
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 to the up and down strokes, though that is probably not what you want,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 so be careful.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 For backward compatibility, a key sequence may also be represented by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 a string. In this case, it represents the key sequence(s) that would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 produce that sequence of @sc{ascii} characters in a purely @sc{ascii}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 world. For example, a string containing the @sc{ascii} backspace
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 character, @code{"\^H"}, would represent two key sequences:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 @code{(control h)} and @code{backspace}. Binding a command to this will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 actually bind both of those key sequences. Likewise for the following
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 pairs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
332 control h backspace
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
333 control i tab
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
334 control m return
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
335 control j linefeed
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
336 control [ escape
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
337 control @@ control space
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 After binding a command to two key sequences with a form like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
343 (define-key global-map "\^X\^I" 'command-1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 it is possible to redefine only one of those sequences like so:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 @example
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
350 (define-key global-map [(control x) (control i)] 'command-2)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
351 (define-key global-map [(control x) tab] 'command-3)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 Of course, all of this applies only when running under a window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 system. If you're talking to XEmacs through a @sc{tty} connection, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 don't get any of these features.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 @defun event-matches-key-specifier-p event key-specifier
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 This function returns non-@code{nil} if @var{event} matches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 @var{key-specifier}, which can be any valid form representing a key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 sequence. This can be useful, e.g., to determine if the user pressed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 @code{help-char} or @code{quit-char}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 @node Prefix Keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 @section Prefix Keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 @cindex prefix key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 A @dfn{prefix key} has an associated keymap that defines what to do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 with key sequences that start with the prefix key. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 @kbd{C-x} is a prefix key, and it uses a keymap that is also stored in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 the variable @code{ctl-x-map}. Here is a list of the standard prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 keys of XEmacs and their keymaps:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 @cindex @kbd{C-h}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 @code{help-map} is used for events that follow @kbd{C-h}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 @cindex @kbd{C-c}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 @vindex mode-specific-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 @code{mode-specific-map} is for events that follow @kbd{C-c}. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 map is not actually mode specific; its name was chosen to be informative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 for the user in @kbd{C-h b} (@code{display-bindings}), where it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 describes the main use of the @kbd{C-c} prefix key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 @cindex @kbd{C-x}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 @vindex ctl-x-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 @findex Control-X-prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 @code{ctl-x-map} is the map used for events that follow @kbd{C-x}. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 map is also the function definition of @code{Control-X-prefix}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 @cindex @kbd{C-x 4}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 @vindex ctl-x-4-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 @code{ctl-x-4-map} is used for events that follow @kbd{C-x 4}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 @cindex @kbd{C-x 5}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 @vindex ctl-x-5-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 @code{ctl-x-5-map} is used for events that follow @kbd{C-x 5}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 @cindex @kbd{C-x n}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 @cindex @kbd{C-x r}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 @cindex @kbd{C-x a}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 The prefix keys @kbd{C-x n}, @kbd{C-x r} and @kbd{C-x a} use keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 that have no special name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 @vindex esc-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 @findex ESC-prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 @code{esc-map} is an evil hack that is present for compatibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 purposes with Emacs 18. Defining a key in @code{esc-map} is equivalent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 to defining the same key in @code{global-map} but with the @key{META}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 prefix added. You should @emph{not} use this in your code. (This map is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 also the function definition of @code{ESC-prefix}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 The binding of a prefix key is the keymap to use for looking up the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 events that follow the prefix key. (It may instead be a symbol whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 function definition is a keymap. The effect is the same, but the symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 serves as a name for the prefix key.) Thus, the binding of @kbd{C-x} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 the symbol @code{Control-X-prefix}, whose function definition is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 keymap for @kbd{C-x} commands. (The same keymap is also the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 @code{ctl-x-map}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 Prefix key definitions can appear in any active keymap. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 definitions of @kbd{C-c}, @kbd{C-x}, @kbd{C-h} and @key{ESC} as prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 keys appear in the global map, so these prefix keys are always
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 available. Major and minor modes can redefine a key as a prefix by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 putting a prefix key definition for it in the local map or the minor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 mode's map. @xref{Active Keymaps}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 If a key is defined as a prefix in more than one active map, then its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 various definitions are in effect merged: the commands defined in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 minor mode keymaps come first, followed by those in the local map's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 prefix definition, and then by those from the global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 In the following example, we make @kbd{C-p} a prefix key in the local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 keymap, in such a way that @kbd{C-p} is identical to @kbd{C-x}. Then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 the binding for @kbd{C-p C-f} is the function @code{find-file}, just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 like @kbd{C-x C-f}. The key sequence @kbd{C-p 6} is not found in any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 active keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (use-local-map (make-sparse-keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (local-set-key "\C-p" ctl-x-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (key-binding "\C-p\C-f")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 @result{} find-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (key-binding "\C-p6")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 @defun define-prefix-command symbol &optional mapvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 @cindex prefix command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 This function defines @var{symbol} as a prefix command: it creates a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 keymap and stores it as @var{symbol}'s function definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 Storing the symbol as the binding of a key makes the key a prefix key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 that has a name. If optional argument @var{mapvar} is not specified,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 it also sets @var{symbol} as a variable, to have the keymap as its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 value. (If @var{mapvar} is given and is not @code{t}, its value is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 stored as the value of @var{symbol}.) The function returns @var{symbol}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 In Emacs version 18, only the function definition of @var{symbol} was
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 set, not the value as a variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 @node Active Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 @section Active Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 @cindex active keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 @cindex global keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 @cindex local keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 XEmacs normally contains many keymaps; at any given time, just a few of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 them are @dfn{active} in that they participate in the interpretation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 of user input. These are the global keymap, the current buffer's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 local keymap, and the keymaps of any enabled minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 The @dfn{global keymap} holds the bindings of keys that are defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 regardless of the current buffer, such as @kbd{C-f}. The variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 @code{global-map} holds this keymap, which is always active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 Each buffer may have another keymap, its @dfn{local keymap}, which may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 contain new or overriding definitions for keys. The current buffer's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 local keymap is always active except when @code{overriding-local-map} or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 @code{overriding-terminal-local-map} overrides it. Extents and text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 properties can specify an alternative local map for certain parts of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 buffer; see @ref{Extents and Events}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Each minor mode may have a keymap; if it does, the keymap is active
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 when the minor mode is enabled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 The variable @code{overriding-local-map} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 @code{overriding-terminal-local-map}, if non-@code{nil}, specify other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 local keymaps that override the buffer's local map and all the minor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 mode keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 All the active keymaps are used together to determine what command to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 execute when a key is entered. XEmacs searches these maps one by one, in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 order of decreasing precedence, until it finds a binding in one of the maps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 More specifically:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 For key-presses, the order of keymaps searched is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 the @code{keymap} property of any extent(s) or text properties at point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 any applicable minor-mode maps;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 the current local map of the current buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 the current global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 For mouse-clicks, the order of keymaps searched is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 the current local map of the @code{mouse-grabbed-buffer} if any;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 the @code{keymap} property of any extent(s) at the position of the click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (this includes modeline extents);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 the @code{modeline-map} of the buffer corresponding to the modeline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 under the mouse (if the click happened over a modeline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 the value of @code{toolbar-map} in the current buffer (if the click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 happened over a toolbar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 the current local map of the buffer under the mouse (does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 apply to toolbar clicks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 any applicable minor-mode maps;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 the current global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 Note that if @code{overriding-local-map} or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 @code{overriding-terminal-local-map} is non-@code{nil}, @emph{only}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 those two maps and the current global map are searched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 The procedure for searching a single keymap is called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 @dfn{key lookup}; see @ref{Key Lookup}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 @cindex major mode keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 Since every buffer that uses the same major mode normally uses the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 same local keymap, you can think of the keymap as local to the mode. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 change to the local keymap of a buffer (using @code{local-set-key}, for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 example) is seen also in the other buffers that share that keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 The local keymaps that are used for Lisp mode, C mode, and several
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 other major modes exist even if they have not yet been used. These
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 local maps are the values of the variables @code{lisp-mode-map},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 @code{c-mode-map}, and so on. For most other modes, which are less
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 frequently used, the local keymap is constructed only when the mode is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 used for the first time in a session.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 The minibuffer has local keymaps, too; they contain various completion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 and exit commands. @xref{Intro to Minibuffers}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 @xref{Standard Keymaps}, for a list of standard keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 @defun current-keymaps &optional event-or-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 This function returns a list of the current keymaps that will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 searched for bindings. This lists keymaps such as the current local map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 and the minor-mode maps, but does not list the parents of those keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 @var{event-or-keys} controls which keymaps will be listed. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 @var{event-or-keys} is a mouse event (or a vector whose last element is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 a mouse event), the keymaps for that mouse event will be listed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 Otherwise, the keymaps for key presses will be listed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 @defvar global-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 This variable contains the default global keymap that maps XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 keyboard input to commands. The global keymap is normally this keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 The default global keymap is a full keymap that binds
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 @code{self-insert-command} to all of the printing characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 It is normal practice to change the bindings in the global map, but you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 should not assign this variable any value other than the keymap it starts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 out with.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 @defun current-global-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 This function returns the current global keymap. This is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 same as the value of @code{global-map} unless you change one or the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 other.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 (current-global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 @result{} #<keymap global-map 639 entries 0x221>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
615 @defun current-local-map &optional buffer
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
616 This function returns @var{buffer}'s local keymap, or @code{nil}
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
617 if it has none. @var{buffer} defaults to the current buffer.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
618
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
619 In the following example, the keymap for the @samp{*scratch*} buffer
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
620 (using Lisp Interaction mode) has a number of entries, including one
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
621 prefix key, @kbd{C-x}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 (current-local-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 (describe-bindings-internal (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 @result{} ; @r{Inserted into the buffer:}
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
629 backspace backward-delete-char-untabify
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
630 linefeed eval-print-last-sexp
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
631 delete delete-char
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
632 C-j eval-print-last-sexp
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
633 C-x << Prefix Command >>
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
634 M-tab lisp-complete-symbol
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
635 M-; lisp-indent-for-comment
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
636 M-C-i lisp-complete-symbol
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
637 M-C-q indent-sexp
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
638 M-C-x eval-defun
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
639 Alt-backspace backward-kill-sexp
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
640 Alt-delete kill-sexp
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 @group
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
644 C-x x edebug-defun
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 @defun current-minor-mode-maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 This function returns a list of the keymaps of currently enabled minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 @defun use-global-map keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 This function makes @var{keymap} the new current global keymap. It
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 returns @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 It is very unusual to change the global keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 @defun use-local-map keymap &optional buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 This function makes @var{keymap} the new local keymap of @var{buffer}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 @var{buffer} defaults to the current buffer. If @var{keymap} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 @code{nil}, then the buffer has no local keymap. @code{use-local-map}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 returns @code{nil}. Most major mode commands use this function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 @defvar minor-mode-map-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 This variable is an alist describing keymaps that may or may not be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 active according to the values of certain variables. Its elements look
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (@var{variable} . @var{keymap})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 The keymap @var{keymap} is active whenever @var{variable} has a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 non-@code{nil} value. Typically @var{variable} is the variable that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 enables or disables a minor mode. @xref{Keymaps and Minor Modes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 Note that elements of @code{minor-mode-map-alist} do not have the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 structure as elements of @code{minor-mode-alist}. The map must be the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 @sc{cdr} of the element; a list with the map as the second element will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 not do.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 What's more, the keymap itself must appear in the @sc{cdr}. It does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 work to store a variable in the @sc{cdr} and make the map the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 that variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 When more than one minor mode keymap is active, their order of priority
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 is the order of @code{minor-mode-map-alist}. But you should design
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 minor modes so that they don't interfere with each other. If you do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 this properly, the order will not matter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 See also @code{minor-mode-key-binding}, above. See @ref{Keymaps and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 Minor Modes}, for more information about minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 @defvar modeline-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 This variable holds the keymap consulted for mouse-clicks on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 modeline of a window. This variable may be buffer-local; its value will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 be looked up in the buffer of the window whose modeline was clicked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 upon.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 @defvar toolbar-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 This variable holds the keymap consulted for mouse-clicks over a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 toolbar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 @defvar mouse-grabbed-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 If non-@code{nil}, a buffer which should be consulted first for all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 mouse activity. When a mouse-click is processed, it will first be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 looked up in the local-map of this buffer, and then through the normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 mechanism if there is no binding for that click. This buffer's value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 @code{mode-motion-hook} will be consulted instead of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 @code{mode-motion-hook} of the buffer of the window under the mouse.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 You should @emph{bind} this, not set it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 @defvar overriding-local-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 If non-@code{nil}, this variable holds a keymap to use instead of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 buffer's local keymap and instead of all the minor mode keymaps. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 keymap, if any, overrides all other maps that would have been active,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 except for the current global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 @defvar overriding-terminal-local-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 If non-@code{nil}, this variable holds a keymap to use instead of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 buffer's local keymap and instead of all the minor mode keymaps, but for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 the selected console only. (In other words, this variable is always
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 console-local; putting a keymap here only applies to keystrokes coming
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 from the selected console. @xref{Consoles and Devices}.) This keymap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 if any, overrides all other maps that would have been active, except for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 the current global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 @node Key Lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 @section Key Lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 @cindex key lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 @cindex keymap entry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 @dfn{Key lookup} is the process of finding the binding of a key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 sequence from a given keymap. Actual execution of the binding is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 part of key lookup.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 Key lookup uses just the event type of each event in the key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 sequence; the rest of the event is ignored. In fact, a key sequence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 used for key lookup may designate mouse events with just their types
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 (symbols) instead of with entire mouse events (lists). @xref{Events}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 Such a pseudo-key-sequence is insufficient for @code{command-execute},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 but it is sufficient for looking up or rebinding a key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 When the key sequence consists of multiple events, key lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 processes the events sequentially: the binding of the first event is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 found, and must be a keymap; then the second event's binding is found in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 that keymap, and so on until all the events in the key sequence are used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 up. (The binding thus found for the last event may or may not be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 keymap.) Thus, the process of key lookup is defined in terms of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 simpler process for looking up a single event in a keymap. How that is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 done depends on the type of object associated with the event in that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 Let's use the term @dfn{keymap entry} to describe the value found by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 looking up an event type in a keymap. (This doesn't include the item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 string and other extra elements in menu key bindings because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 @code{lookup-key} and other key lookup functions don't include them in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 the returned value.) While any Lisp object may be stored in a keymap as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 a keymap entry, not all make sense for key lookup. Here is a list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 the meaningful kinds of keymap entries:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 @table @asis
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 @item @code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 @cindex @code{nil} in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 @code{nil} means that the events used so far in the lookup form an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 undefined key. When a keymap fails to mention an event type at all, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 has no default binding, that is equivalent to a binding of @code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 for that event type.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 @item @var{keymap}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 @cindex keymap in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 The events used so far in the lookup form a prefix key. The next
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 event of the key sequence is looked up in @var{keymap}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 @item @var{command}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 @cindex command in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 The events used so far in the lookup form a complete key,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 and @var{command} is its binding. @xref{What Is a Function}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 @item @var{array}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 @cindex string in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 The array (either a string or a vector) is a keyboard macro. The events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 used so far in the lookup form a complete key, and the array is its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 binding. See @ref{Keyboard Macros}, for more information. (Note that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 you cannot use a shortened form of a key sequence here, such as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 @code{(control y)}; you must use the full form @code{[(control y)]}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 @xref{Key Sequences}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 @item @var{list}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 @cindex list in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 The meaning of a list depends on the types of the elements of the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 @cindex @code{lambda} in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 If the @sc{car} of @var{list} is @code{lambda}, then the list is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 lambda expression. This is presumed to be a command, and is treated as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 such (see above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 If the @sc{car} of @var{list} is a keymap and the @sc{cdr} is an event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 type, then this is an @dfn{indirect entry}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (@var{othermap} . @var{othertype})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 When key lookup encounters an indirect entry, it looks up instead the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 binding of @var{othertype} in @var{othermap} and uses that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 This feature permits you to define one key as an alias for another key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 For example, an entry whose @sc{car} is the keymap called @code{esc-map}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 and whose @sc{cdr} is 32 (the code for @key{SPC}) means, ``Use the global
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 binding of @kbd{Meta-@key{SPC}}, whatever that may be.''
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 @item @var{symbol}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 @cindex symbol in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 The function definition of @var{symbol} is used in place of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 @var{symbol}. If that too is a symbol, then this process is repeated,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 any number of times. Ultimately this should lead to an object that is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 a keymap, a command or a keyboard macro. A list is allowed if it is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 keymap or a command, but indirect entries are not understood when found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 via symbols.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 Note that keymaps and keyboard macros (strings and vectors) are not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 valid functions, so a symbol with a keymap, string, or vector as its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 function definition is invalid as a function. It is, however, valid as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 a key binding. If the definition is a keyboard macro, then the symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 is also valid as an argument to @code{command-execute}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 (@pxref{Interactive Call}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 @cindex @code{undefined} in keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 The symbol @code{undefined} is worth special mention: it means to treat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 the key as undefined. Strictly speaking, the key is defined, and its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 binding is the command @code{undefined}; but that command does the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 thing that is done automatically for an undefined key: it rings the bell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (by calling @code{ding}) but does not signal an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 @cindex preventing prefix key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 @code{undefined} is used in local keymaps to override a global key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 binding and make the key ``undefined'' locally. A local binding of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 @code{nil} would fail to do this because it would not override the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 global binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 @item @var{anything else}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 If any other type of object is found, the events used so far in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 lookup form a complete key, and the object is its binding, but the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 binding is not executable as a command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 In short, a keymap entry may be a keymap, a command, a keyboard macro,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 a symbol that leads to one of them, or an indirection or @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 @node Functions for Key Lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 @section Functions for Key Lookup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 Here are the functions and variables pertaining to key lookup.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 @defun lookup-key keymap key &optional accept-defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 This function returns the definition of @var{key} in @var{keymap}. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 the string or vector @var{key} is not a valid key sequence according to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 the prefix keys specified in @var{keymap} (which means it is ``too
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 long'' and has extra events at the end), then the value is a number, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 number of events at the front of @var{key} that compose a complete key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 If @var{accept-defaults} is non-@code{nil}, then @code{lookup-key}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 considers default bindings as well as bindings for the specific events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 in @var{key}. Otherwise, @code{lookup-key} reports only bindings for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 the specific sequence @var{key}, ignoring default bindings except when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 you explicitly ask about them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 All the other functions described in this chapter that look up keys use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 @code{lookup-key}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 (lookup-key (current-global-map) "\C-x\C-f")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 @result{} find-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 (lookup-key (current-global-map) "\C-x\C-f12345")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 @result{} 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 If @var{key} begins with the character whose value is contained in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 @code{meta-prefix-char}, that character is implicitly removed and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 @key{META} modifier added to the key. Thus, the first example below is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 handled by conversion into the second example.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 (lookup-key (current-global-map) "\ef")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 @result{} forward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (lookup-key (current-global-map) "\M-f")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 @result{} forward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 Unlike @code{read-key-sequence}, this function does not modify the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 specified events in ways that discard information (@pxref{Key Sequence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 Input}). In particular, it does not convert letters to lower case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 @deffn Command undefined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 Used in keymaps to undefine keys. If a key sequence is defined to this,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 invoking this key sequence causes a ``key undefined'' error, just as if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 the key sequence had no binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 @defun key-binding key &optional accept-defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 This function returns the binding for @var{key} in the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 keymaps, trying all the active keymaps. The result is @code{nil} if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 @var{key} is undefined in the keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 The argument @var{accept-defaults} controls checking for default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 bindings, as in @code{lookup-key} (above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 (key-binding "\C-x\C-f")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 @result{} find-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 (key-binding '(control home))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 @result{} beginning-of-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 (key-binding [escape escape escape])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 @result{} keyboard-escape-quit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
946 @defun local-key-binding keys &optional accept-defaults
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
947 This function returns the binding for @var{keys} in the current
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 local keymap, or @code{nil} if it is undefined there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 The argument @var{accept-defaults} controls checking for default bindings,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 as in @code{lookup-key} (above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
955 @defun global-key-binding keys &optional accept-defaults
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
956 This function returns the binding for command @var{keys} in the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 current global keymap, or @code{nil} if it is undefined there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 The argument @var{accept-defaults} controls checking for default bindings,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 as in @code{lookup-key} (above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 @defun minor-mode-key-binding key &optional accept-defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 This function returns a list of all the active minor mode bindings of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 @var{key}. More precisely, it returns an alist of pairs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 @code{(@var{modename} . @var{binding})}, where @var{modename} is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 variable that enables the minor mode, and @var{binding} is @var{key}'s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 binding in that mode. If @var{key} has no minor-mode bindings, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 value is @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 If the first binding is not a prefix command, all subsequent bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 from other minor modes are omitted, since they would be completely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 shadowed. Similarly, the list omits non-prefix bindings that follow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 prefix bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 The argument @var{accept-defaults} controls checking for default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 bindings, as in @code{lookup-key} (above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 @defvar meta-prefix-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 @cindex @key{ESC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 This variable is the meta-prefix character code. It is used when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 translating a two-character sequence to a meta character so it can be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 looked up in a keymap. For useful results, the value should be a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 event (@pxref{Prefix Keys}). The default value is @code{?\^[} (integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 27), which is the @sc{ascii} character usually produced by the @key{ESC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 As long as the value of @code{meta-prefix-char} remains @code{?\^[},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 key lookup translates @kbd{@key{ESC} b} into @kbd{M-b}, which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 normally defined as the @code{backward-word} command. However, if you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 set @code{meta-prefix-char} to @code{?\^X} (i.e. the keystroke
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 @kbd{C-x}) or its equivalent @sc{ascii} code @code{24}, then XEmacs will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 translate @kbd{C-x b} (whose standard binding is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 @code{switch-to-buffer} command) into @kbd{M-b}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 meta-prefix-char ; @r{The default value.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 @result{} ?\^[ ; @r{Under XEmacs 20.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 @result{} 27 ; @r{Under XEmacs 19.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 (key-binding "\eb")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 @result{} backward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 ?\C-x ; @r{The print representation}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 ; @r{of a character.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 @result{} ?\^X ; @r{Under XEmacs 20.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 @result{} 24 ; @r{Under XEmacs 19.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 (setq meta-prefix-char 24)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1017 @result{} 24
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 (key-binding "\C-xb")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 @result{} backward-word ; @r{Now, typing @kbd{C-x b} is}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 ; @r{like typing @kbd{M-b}.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 (setq meta-prefix-char ?\e) ; @r{Avoid confusion!}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 ; @r{Restore the default value!}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 @result{} ?\^[ ; @r{Under XEmacs 20.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 @result{} 27 ; @r{Under XEmacs 19.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 @end defvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 @node Changing Key Bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 @section Changing Key Bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 @cindex changing key bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 @cindex rebinding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 The way to rebind a key is to change its entry in a keymap. If you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 change a binding in the global keymap, the change is effective in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 buffers (though it has no direct effect in buffers that shadow the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 global binding with a local one). If you change the current buffer's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 local map, that usually affects all buffers using the same major mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 The @code{global-set-key} and @code{local-set-key} functions are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 convenient interfaces for these operations (@pxref{Key Binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 Commands}). You can also use @code{define-key}, a more general
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 function; then you must specify explicitly the map to change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 The way to specify the key sequence that you want to rebind is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 described above (@pxref{Key Sequences}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 For the functions below, an error is signaled if @var{keymap} is not a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 keymap or if @var{key} is not a string or vector representing a key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 sequence. You can use event types (symbols) as shorthand for events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 that are lists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 @defun define-key keymap key binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 This function sets the binding for @var{key} in @var{keymap}. (If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 @var{key} is more than one event long, the change is actually made
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 in another keymap reached from @var{keymap}.) The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 @var{binding} can be any Lisp object, but only certain types are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 meaningful. (For a list of meaningful types, see @ref{Key Lookup}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 The value returned by @code{define-key} is @var{binding}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 @cindex invalid prefix key error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 @cindex key sequence error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 Every prefix of @var{key} must be a prefix key (i.e., bound to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 keymap) or undefined; otherwise an error is signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 If some prefix of @var{key} is undefined, then @code{define-key} defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 it as a prefix key so that the rest of @var{key} may be defined as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 Here is an example that creates a sparse keymap and makes a number of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 bindings in it:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 (setq map (make-sparse-keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 @result{} #<keymap 0 entries 0xbee>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 (define-key map "\C-f" 'forward-char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 @result{} forward-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 @result{} #<keymap 1 entry 0xbee>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 (describe-bindings-internal map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 @result{} ; @r{(Inserted in buffer)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 C-f forward-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 ;; @r{Build sparse submap for @kbd{C-x} and bind @kbd{f} in that.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 (define-key map "\C-xf" 'forward-word)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 @result{} forward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 @result{} #<keymap 2 entries 0xbee>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 (describe-bindings-internal map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 @result{} ; @r{(Inserted in buffer)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 C-f forward-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 C-x << Prefix Command >>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 C-x f forward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 ;; @r{Bind @kbd{C-p} to the @code{ctl-x-map}.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 (define-key map "\C-p" ctl-x-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 ;; @code{ctl-x-map}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 @result{} #<keymap Control-X-prefix 77 entries 0x3bf>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 ;; @r{Bind @kbd{C-f} to @code{foo} in the @code{ctl-x-map}.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 (define-key map "\C-p\C-f" 'foo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 @result{} foo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 @result{} #<keymap 3 entries 0xbee>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 (describe-bindings-internal map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 @result{} ; @r{(Inserted in buffer)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 C-f forward-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 C-p << Prefix command Control-X-prefix >>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 C-x << Prefix Command >>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 C-p tab indent-rigidly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 C-p $ set-selective-display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 C-p ' expand-abbrev
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 C-p ( start-kbd-macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 C-p ) end-kbd-macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 C-p C-x exchange-point-and-mark
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 C-p C-z suspend-or-iconify-emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 C-p M-escape repeat-complex-command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 C-p M-C-[ repeat-complex-command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 C-x f forward-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 C-p 4 . find-tag-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 C-p 4 C-o display-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 C-p 5 0 delete-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 C-p 5 C-f find-file-other-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 C-p a i g inverse-add-global-abbrev
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 C-p a i l inverse-add-mode-abbrev
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 Note that storing a new binding for @kbd{C-p C-f} actually works by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 changing an entry in @code{ctl-x-map}, and this has the effect of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 changing the bindings of both @kbd{C-p C-f} and @kbd{C-x C-f} in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 default global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1164 @defun substitute-key-definition olddef newdef keymap &optional oldmap prefix
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 @cindex replace bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 This function replaces @var{olddef} with @var{newdef} for any keys in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 @var{keymap} that were bound to @var{olddef}. In other words,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1168 @var{olddef} is replaced with @var{newdef} wherever it appears. Prefix
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1169 keymaps are checked recursively.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1170
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1171 The function returns @code{nil}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 For example, this redefines @kbd{C-x C-f}, if you do it in an XEmacs with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 standard bindings:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 @group
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1178 (substitute-key-definition
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 'find-file 'find-file-read-only (current-global-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 @c Emacs 19 feature
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 If @var{oldmap} is non-@code{nil}, then its bindings determine which
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1185 keys to rebind. The rebindings still happen in @var{keymap}, not in
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 @var{oldmap}. Thus, you can change one map under the control of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 bindings in another. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 (substitute-key-definition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 'delete-backward-char 'my-funny-delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 my-map global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 puts the special deletion command in @code{my-map} for whichever keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 are globally bound to the standard deletion command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1199 If argument @var{prefix} is non-@code{nil}, then only those occurrences
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1200 of @var{olddef} found in keymaps accessible through the keymap bound to
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1201 @var{prefix} in @var{keymap} are redefined. See also
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1202 @code{accessible-keymaps}.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1203
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 @ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 @c Emacs 18 only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 Prefix keymaps that appear within @var{keymap} are not checked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 recursively for keys bound to @var{olddef}; they are not changed at all.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 Perhaps it would be better to check nested keymaps recursively.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 @end ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 @ignore @c #### fix this up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 Here is an example showing a keymap before and after substitution:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 @group
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1216 (setq map '(keymap
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1217 (?1 . olddef-1)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1218 (?2 . olddef-2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 (?3 . olddef-1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 @result{} (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 (substitute-key-definition 'olddef-1 'newdef map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 @result{} (keymap (49 . newdef) (50 . olddef-2) (51 . newdef))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 @end ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 @defun suppress-keymap keymap &optional nodigits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 @cindex @code{self-insert-command} override
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 This function changes the contents of the full keymap @var{keymap} by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 making all the printing characters undefined. More precisely, it binds
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 them to the command @code{undefined}. This makes ordinary insertion of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 text impossible. @code{suppress-keymap} returns @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 If @var{nodigits} is @code{nil}, then @code{suppress-keymap} defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 digits to run @code{digit-argument}, and @kbd{-} to run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 @code{negative-argument}. Otherwise it makes them undefined like the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 rest of the printing characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1247 @cindex yank suppression
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1248 @cindex @code{quoted-insert} suppression
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 The @code{suppress-keymap} function does not make it impossible to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 modify a buffer, as it does not suppress commands such as @code{yank}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 and @code{quoted-insert}. To prevent any modification of a buffer, make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 it read-only (@pxref{Read Only Buffers}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 Since this function modifies @var{keymap}, you would normally use it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 on a newly created keymap. Operating on an existing keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 that is used for some other purpose is likely to cause trouble; for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 example, suppressing @code{global-map} would make it impossible to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 most of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 Most often, @code{suppress-keymap} is used to initialize local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 keymaps of modes such as Rmail and Dired where insertion of text is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 desirable and the buffer is read-only. Here is an example taken from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 the file @file{emacs/lisp/dired.el}, showing how the local keymap for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 Dired mode is set up:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 (setq dired-mode-map (make-keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 (suppress-keymap dired-mode-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 (define-key dired-mode-map "r" 'dired-rename-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 (define-key dired-mode-map "\C-d" 'dired-flag-file-deleted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 (define-key dired-mode-map "d" 'dired-flag-file-deleted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 (define-key dired-mode-map "v" 'dired-view-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 (define-key dired-mode-map "e" 'dired-find-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 (define-key dired-mode-map "f" 'dired-find-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 @node Key Binding Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 @section Commands for Binding Keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 This section describes some convenient interactive interfaces for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 changing key bindings. They work by calling @code{define-key}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 People often use @code{global-set-key} in their @file{.emacs} file for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 simple customization. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 (global-set-key "\C-x\C-\\" 'next-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 (global-set-key [(control ?x) (control ?\\)] 'next-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 (global-set-key [?\C-x ?\C-\\] 'next-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 redefines @kbd{C-x C-\} to move down a line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 (global-set-key [(meta button1)] 'mouse-set-point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 redefines the first (leftmost) mouse button, typed with the Meta key, to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 set point where you click.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 @deffn Command global-set-key key definition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 This function sets the binding of @var{key} in the current global map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 to @var{definition}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 (global-set-key @var{key} @var{definition})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 @equiv{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 (define-key (current-global-map) @var{key} @var{definition})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 @deffn Command global-unset-key key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 @cindex unbinding keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 This function removes the binding of @var{key} from the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 global map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 One use of this function is in preparation for defining a longer key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 that uses @var{key} as a prefix---which would not be allowed if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 @var{key} has a non-prefix binding. For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 (global-unset-key "\C-l")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 (global-set-key "\C-l\C-l" 'redraw-display)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 @result{} nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 This function is implemented simply using @code{define-key}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 (global-unset-key @var{key})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 @equiv{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 (define-key (current-global-map) @var{key} nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 @deffn Command local-set-key key definition
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 This function sets the binding of @var{key} in the current local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 keymap to @var{definition}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 (local-set-key @var{key} @var{definition})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 @equiv{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 (define-key (current-local-map) @var{key} @var{definition})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 @deffn Command local-unset-key key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 This function removes the binding of @var{key} from the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 local map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 (local-unset-key @var{key})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 @equiv{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 (define-key (current-local-map) @var{key} nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 @node Scanning Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 @section Scanning Keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 This section describes functions used to scan all the current keymaps,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 or all keys within a keymap, for the sake of printing help information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 @defun accessible-keymaps keymap &optional prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 This function returns a list of all the keymaps that can be accessed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 (via prefix keys) from @var{keymap}. The value is an association list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 with elements of the form @code{(@var{key} .@: @var{map})}, where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 @var{key} is a prefix key whose definition in @var{keymap} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 @var{map}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 The elements of the alist are ordered so that the @var{key} increases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 in length. The first element is always @code{([] .@: @var{keymap})},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 because the specified keymap is accessible from itself with a prefix of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 no events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 If @var{prefix} is given, it should be a prefix key sequence; then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 @code{accessible-keymaps} includes only the submaps whose prefixes start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 with @var{prefix}. These elements look just as they do in the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 @code{(accessible-keymaps)}; the only difference is that some elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 are omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 In the example below, the returned alist indicates that the key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 @kbd{C-x}, which is displayed as @samp{[(control x)]}, is a prefix key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 whose definition is the keymap @code{#<keymap ((control x) #<keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 emacs-lisp-mode-map 8 entries 0x546>) 1 entry 0x8a2>}. (The strange
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 notation for the keymap's name indicates that this is an internal submap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 of @code{emacs-lisp-mode-map}. This is because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 @code{lisp-interaction-mode-map} has set up @code{emacs-lisp-mode-map}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 as its parent, and @code{lisp-interaction-mode-map} defines no key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 sequences beginning with @kbd{C-x}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 @group
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1426 (current-local-map)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 (accessible-keymaps (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 @result{}(([] . #<keymap lisp-interaction-mode-map 5 entries 0x558>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 ([(control x)] .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 #<keymap ((control x) #<keymap emacs-lisp-mode-map 8 entries 0x546>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 1 entry 0x8a2>))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 The following example shows the results of calling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 @code{accessible-keymaps} on a large, complex keymap. Notice how
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 some keymaps were given explicit names using @code{set-keymap-name};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 those submaps without explicit names are given descriptive names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 indicating their relationship to their enclosing keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 (accessible-keymaps (current-global-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 @result{} (([] . #<keymap global-map 639 entries 0x221>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 ([(control c)] . #<keymap mode-specific-command-prefix 1 entry 0x3cb>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 ([(control h)] . #<keymap help-map 33 entries 0x4ec>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 ([(control x)] . #<keymap Control-X-prefix 77 entries 0x3bf>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 ([(meta escape)] .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 #<keymap ((meta escape) #<keymap global-map 639 entries 0x221>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 3 entries 0x3e0>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 ([(meta control \[)] .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 #<keymap ((meta escape) #<keymap global-map 639 entries 0x221>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 3 entries 0x3e0>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 ([f1] . #<keymap help-map 33 entries 0x4ec>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 ([(control x) \4] . #<keymap ctl-x-4-prefix 9 entries 0x3c5>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 ([(control x) \5] . #<keymap ctl-x-5-prefix 8 entries 0x3c8>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 ([(control x) \6] . #<keymap 13 entries 0x4d2>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 ([(control x) a] .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 #<keymap (a #<keymap Control-X-prefix 77 entries 0x3bf>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 8 entries 0x3ef>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 ([(control x) n] . #<keymap narrowing-prefix 3 entries 0x3dd>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 ([(control x) r] . #<keymap rectangle-prefix 18 entries 0x3e9>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 ([(control x) v] . #<keymap vc-prefix-map 13 entries 0x60e>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 ([(control x) a i] .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 #<keymap (i #<keymap (a #<keymap Control-X-prefix 77 entries 0x3bf>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 8 entries 0x3ef>)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 2 entries 0x3f5>))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 @defun map-keymap function keymap &optional sort-first
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1474 This function applies @var{function} to each element of @var{keymap}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 @var{function} will be called with two arguments: a key-description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 list, and the binding. The order in which the elements of the keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 are passed to the function is unspecified. If the function inserts new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 elements into the keymap, it may or may not be called with them later.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 No element of the keymap will ever be passed to the function more than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 once.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 The function will not be called on elements of this keymap's parents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 (@pxref{Inheritance and Keymaps}) or upon keymaps which are contained
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 within this keymap (multi-character definitions). It will be called on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 @key{META} characters since they are not really two-character sequences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 If the optional third argument @var{sort-first} is non-@code{nil}, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 the elements of the keymap will be passed to the mapper function in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 canonical order. Otherwise, they will be passed in hash (that is,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 random) order, which is faster.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 @defun keymap-fullness keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 This function returns the number of bindings in the keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 @defun where-is-internal definition &optional keymaps firstonly noindirect event-or-keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 This function returns a list of key sequences (of any length) that are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 bound to @var{definition} in a set of keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 The argument @var{definition} can be any object; it is compared with all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 keymap entries using @code{eq}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1504 @var{keymaps} can be either a keymap (meaning search in that keymap and the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 current global keymap) or a list of keymaps (meaning search in exactly
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1506 those keymaps and no others). If @var{keymaps} is nil, search in the currently
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1507 applicable maps for @var{event-or-keys}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1509 If @var{keymaps} is a keymap, then the maps searched are @var{keymaps} and
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1510 the global keymap. If @var{keymaps} is a list of keymaps, then the maps
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1511 searched are exactly those keymaps, and no others. If @var{keymaps} is
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 @code{nil}, then the maps used are the current active keymaps for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 @var{event-or-keys} (this is equivalent to specifying
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 @code{(current-keymaps @var{event-or-keys})} as the argument to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 @var{keymaps}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 If @var{firstonly} is non-@code{nil}, then the value is a single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 vector representing the first key sequence found, rather than a list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 all possible key sequences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 @ignore @c #### Should fix where-is to be more like FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 If @var{firstonly} is @code{non-ascii}, then the value is a single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 string representing the first key sequence found, rather than a list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 all possible key sequences. If @var{firstonly} is @code{t}, then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 value is the first key sequence, except that key sequences consisting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 entirely of @sc{ascii} characters (or meta variants of @sc{ascii}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 characters) are preferred to all other key sequences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 @end ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 If @var{noindirect} is non-@code{nil}, @code{where-is-internal} doesn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 follow indirect keymap bindings. This makes it possible to search for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 an indirect definition itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1533 This function is used by @code{where-is} (@pxref{Help, , Help, xemacs,
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1534 The XEmacs Lisp Reference Manual}).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 (where-is-internal 'describe-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 @result{} ([(control h) d] [(control h) f] [f1 d] [f1 f])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 @defun describe-bindings-internal map &optional all shadow prefix mouse-only-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 This function inserts (into the current buffer) a list of all defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 keys and their definitions in @var{map}. Optional second argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 @var{all} says whether to include even ``uninteresting'' definitions,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 i.e. symbols with a non-@code{nil} @code{suppress-keymap} property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 Third argument @var{shadow} is a list of keymaps whose bindings shadow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 those of map; if a binding is present in any shadowing map, it is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 printed. Fourth argument @var{prefix}, if non-@code{nil}, should be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 key sequence; only bindings which start with that key sequence will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 printed. Fifth argument @var{mouse-only-p} says to only print bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 for mouse clicks.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 @code{describe-bindings-internal} is used to implement the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 help command @code{describe-bindings}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1560 @deffn Command describe-bindings &optional prefix mouse-only-p
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 This function creates a listing of all defined keys and their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 definitions. It writes the listing in a buffer named @samp{*Help*} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 displays it in a window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1565 If optional argument @var{prefix} is non-@code{nil}, it should be a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1566 prefix key; then the listing includes only keys that start with
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1567 @var{prefix}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 When several characters with consecutive @sc{ascii} codes have the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 same definition, they are shown together, as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 @samp{@var{firstchar}..@var{lastchar}}. In this instance, you need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 know the @sc{ascii} codes to understand which characters this means.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 For example, in the default global map, the characters @samp{@key{SPC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 ..@: ~} are described by a single line. @key{SPC} is @sc{ascii} 32,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 @kbd{~} is @sc{ascii} 126, and the characters between them include all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 the normal printing characters, (e.g., letters, digits, punctuation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 etc.@:); all these characters are bound to @code{self-insert-command}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1579 If the second optional argument @var{mouse-only-p} (prefix arg,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1580 interactively) is non-@code{nil} then only the mouse bindings are
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
1581 displayed.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 @end deffn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 @node Other Keymap Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 @section Other Keymap Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 @defun set-keymap-prompt keymap new-prompt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 This function sets the ``prompt'' of @var{keymap} to string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 @var{new-prompt}, or @code{nil} if no prompt is desired. The prompt is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 shown in the echo-area when reading a key-sequence to be looked-up in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 this keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 @end defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 @defun keymap-prompt keymap &optional use-inherited
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 This function returns the ``prompt'' of the given keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 If @var{use-inherited} is non-@code{nil}, any parent keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 will also be searched for a prompt.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 @end defun