aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2006-05-25 04:51:50 +0000
committerChong Yidong2006-05-25 04:51:50 +0000
commit08244b8144daa9b9fdd69fd8d74155b6dd1d9493 (patch)
tree68509bd5d98ddc1726f01503bfebf25a9e7076a1
parent60f7e8b6638bd63d6055add0e202e09f04208f5c (diff)
downloademacs-08244b8144daa9b9fdd69fd8d74155b6dd1d9493.tar.gz
emacs-08244b8144daa9b9fdd69fd8d74155b6dd1d9493.zip
* keymaps.texi (Key Sequences): Renamed from Keymap Terminology.
Explain string and vector representations of key sequences * keymaps.texi (Changing Key Bindings): * commands.texi (Interactive Codes, Interactive Codes): * help.texi (Describing Characters): Refer to it.
-rw-r--r--lispref/ChangeLog9
-rw-r--r--lispref/commands.texi2
-rw-r--r--lispref/help.texi2
-rw-r--r--lispref/keymaps.texi68
4 files changed, 55 insertions, 26 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index de08e3fb459..ec852df16fe 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,12 @@
12006-05-25 Chong Yidong <cyd@stupidchicken.com>
2
3 * keymaps.texi (Key Sequences): Renamed from Keymap Terminology.
4 Explain string and vector representations of key sequences
5
6 * keymaps.texi (Changing Key Bindings):
7 * commands.texi (Interactive Codes, Interactive Codes):
8 * help.texi (Describing Characters): Refer to it.
9
12006-05-23 Luc Teirlinck <teirllm@auburn.edu> 102006-05-23 Luc Teirlinck <teirllm@auburn.edu>
2 11
3 * frames.texi (Pointer Shape): @end table -> @end defvar. 12 * frames.texi (Pointer Shape): @end table -> @end defvar.
diff --git a/lispref/commands.texi b/lispref/commands.texi
index fa5d95f0408..0723c368bba 100644
--- a/lispref/commands.texi
+++ b/lispref/commands.texi
@@ -362,7 +362,7 @@ An irrelevant argument. This code always supplies @code{nil} as
362the argument's value. No I/O. 362the argument's value. No I/O.
363 363
364@item k 364@item k
365A key sequence (@pxref{Keymap Terminology}). This keeps reading events 365A key sequence (@pxref{Key Sequences}). This keeps reading events
366until a command (or undefined command) is found in the current key 366until a command (or undefined command) is found in the current key
367maps. The key sequence argument is represented as a string or vector. 367maps. The key sequence argument is represented as a string or vector.
368The cursor does not move into the echo area. Prompt. 368The cursor does not move into the echo area. Prompt.
diff --git a/lispref/help.texi b/lispref/help.texi
index 0fe996dfd7c..6173c746d1e 100644
--- a/lispref/help.texi
+++ b/lispref/help.texi
@@ -497,7 +497,7 @@ can also be used as a rough inverse for @code{key-description}. You
497call it with a string containing key descriptions, separated by spaces; 497call it with a string containing key descriptions, separated by spaces;
498it returns a string or vector containing the corresponding events. 498it returns a string or vector containing the corresponding events.
499(This may or may not be a single valid key sequence, depending on what 499(This may or may not be a single valid key sequence, depending on what
500events you use; @pxref{Keymap Terminology}.) If @var{need-vector} is 500events you use; @pxref{Key Sequences}.) If @var{need-vector} is
501non-@code{nil}, the return value is always a vector. 501non-@code{nil}, the return value is always a vector.
502@end defun 502@end defun
503 503
diff --git a/lispref/keymaps.texi b/lispref/keymaps.texi
index 39a57eddf13..808f3a617a6 100644
--- a/lispref/keymaps.texi
+++ b/lispref/keymaps.texi
@@ -16,7 +16,7 @@ to look up the next input event; this continues until a command is
16found. The whole process is called @dfn{key lookup}. 16found. The whole process is called @dfn{key lookup}.
17 17
18@menu 18@menu
19* Keymap Terminology:: Definitions of terms pertaining to keymaps. 19* Key Sequences:: What a key sequence looks like as a Lisp object.
20* Format of Keymaps:: What a keymap looks like as a Lisp object. 20* Format of Keymaps:: What a keymap looks like as a Lisp object.
21* Creating Keymaps:: Functions to create and copy keymaps. 21* Creating Keymaps:: Functions to create and copy keymaps.
22* Inheritance and Keymaps:: How one keymap can inherit the bindings 22* Inheritance and Keymaps:: How one keymap can inherit the bindings
@@ -37,32 +37,26 @@ found. The whole process is called @dfn{key lookup}.
37* Menu Keymaps:: Defining a menu as a keymap. 37* Menu Keymaps:: Defining a menu as a keymap.
38@end menu 38@end menu
39 39
40@node Keymap Terminology 40@node Key Sequences
41@section Keymap Terminology 41@section Key Sequences
42@cindex key 42@cindex key
43@cindex keystroke 43@cindex keystroke
44@cindex key binding 44@cindex key binding
45@cindex binding of a key 45@cindex binding of a key
46@cindex complete key 46@cindex complete key
47@cindex undefined key 47@cindex undefined key
48@cindex key sequence
48 49
49 A @dfn{keymap} is a table mapping event types to definitions (which 50 A keymap determines a binding or definition for a set of @dfn{key
50can be any Lisp objects, though only certain types are meaningful for 51sequences}, or @dfn{keys} for short. A key sequence is a sequence of
51execution by the command loop). Given an event (or an event type) and a 52one or more input events that form a unit.
52keymap, Emacs can get the event's definition. Events include
53characters, function keys, and mouse actions (@pxref{Input Events}).
54
55 A sequence of input events that form a unit is called a
56@dfn{key sequence}, or @dfn{key} for short. A sequence of one event
57is always a key sequence, and so are some multi-event sequences.
58 53
59 A keymap determines a binding or definition for any key sequence. If 54 If a keymap binds a key sequence consisting of a single event, its
60the key sequence is a single event, its binding is the definition of the 55binding is the definition of that event. The binding of a key
61event in the keymap. The binding of a key sequence of more than one 56sequence of more than one event is found by an iterative process: the
62event is found by an iterative process: the binding of the first event 57binding of the first event is found, and must be a keymap; then the
63is found, and must be a keymap; then the second event's binding is found 58second event's binding is found in that keymap, and so on until all
64in that keymap, and so on until all the events in the key sequence are 59the events in the key sequence are used up.
65used up.
66 60
67 If the binding of a key sequence is a keymap, we call the key sequence 61 If the binding of a key sequence is a keymap, we call the key sequence
68a @dfn{prefix key}. Otherwise, we call it a @dfn{complete key} (because 62a @dfn{prefix key}. Otherwise, we call it a @dfn{complete key} (because
@@ -99,8 +93,28 @@ keymaps shadow both local and global keymaps. @xref{Active Keymaps},
99for details. 93for details.
100 94
101 The Emacs Lisp representation for a key sequence is a string or vector. 95 The Emacs Lisp representation for a key sequence is a string or vector.
102You can enter key sequence constants using the ordinary string or vector 96
103representation; it is also convenient to use @code{kbd}: 97 In the string representation, alphanumeric characters ordinarily
98stand for themselves; for example, @code{"a"} represents @key{a} and
99and @code{"1"} represents @key{1}. Control character events are
100prefixed by the substring @code{"\C-"}, and meta characters by
101@code{"\M-"}; for example, @code{"\C-x"} represents the key @kbd{C-x}.
102In addition, the @kbd{<TAB>}, @kbd{<RET>}, @kbd{<ESC>}, and
103@kbd{<DEL>} events are represented by @code{"\t"}, @code{"\r"},
104@code{"\e"}, and @code{"\d"} respectively. The string representation
105of a complete key sequence is then obtained by concatenating the
106string representations of each constituent event; thus, @code{"\C-x"}
107represents the key sequence @kbd{C-x}.
108
109 Key sequences containing function keys, mouse button events, or
110non-ASCII characters such as @kbd{C-=} or @kbd{H-a} cannot be
111represented as strings; they have to be represented as vectors.
112
113 In the vector representation, each element of the vector represents
114a consecutive input element, in its Lisp form. @xref{Input Events}.
115For example, ordinary keyboard events are represented by Lisp
116characters (@pxref{Keyboard Events}), so the character @code{?a}
117represents @key{a}.
104 118
105@defmac kbd keyseq-text 119@defmac kbd keyseq-text
106This macro converts the text @var{keyseq-text} (a string constant) 120This macro converts the text @var{keyseq-text} (a string constant)
@@ -129,7 +143,13 @@ Macro,,, emacs, The GNU Emacs Manual}).
129@cindex full keymap 143@cindex full keymap
130@cindex sparse keymap 144@cindex sparse keymap
131 145
132 A keymap is a list whose @sc{car} is the symbol @code{keymap}. The 146 A @dfn{keymap} is a table mapping event types to definitions (which
147can be any Lisp objects, though only certain types are meaningful for
148execution by the command loop). Given an event (or an event type) and a
149keymap, Emacs can get the event's definition. Events include
150characters, function keys, and mouse actions (@pxref{Input Events}).
151
152 Each keymap is a list whose @sc{car} is the symbol @code{keymap}. The
133remaining elements of the list define the key bindings of the keymap. 153remaining elements of the list define the key bindings of the keymap.
134A symbol whose function definition is a keymap is also a keymap. Use 154A symbol whose function definition is a keymap is also a keymap. Use
135the function @code{keymapp} (see below) to test whether an object is a 155the function @code{keymapp} (see below) to test whether an object is a
@@ -1197,8 +1217,8 @@ numeric codes for the modifier bits don't appear in compiled files.
1197 For the functions below, an error is signaled if @var{keymap} is not 1217 For the functions below, an error is signaled if @var{keymap} is not
1198a keymap or if @var{key} is not a string or vector representing a key 1218a keymap or if @var{key} is not a string or vector representing a key
1199sequence. You can use event types (symbols) as shorthand for events 1219sequence. You can use event types (symbols) as shorthand for events
1200that are lists. The @code{kbd} macro (@pxref{Keymap Terminology}) is 1220that are lists. The @code{kbd} macro (@pxref{Key Sequences}) is a
1201a convenient way to specify the key sequence. 1221convenient way to specify the key sequence.
1202 1222
1203@defun define-key keymap key binding 1223@defun define-key keymap key binding
1204This function sets the binding for @var{key} in @var{keymap}. (If 1224This function sets the binding for @var{key} in @var{keymap}. (If