1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
@c This is part of the Emacs manual.
@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2001, 2002,
@c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@iftex
@chapter Characters, Keys and Commands
This chapter explains the character sets used by Emacs for input
commands, and the fundamental concepts of @dfn{keys} and
@dfn{commands}, whereby Emacs interprets your keyboard and mouse
input.
@end iftex
@ifnottex
@raisesections
@end ifnottex
@node User Input, Keys, Screen, Top
@section Kinds of User Input
@cindex input with the keyboard
@cindex keyboard input
@cindex character set (keyboard)
@cindex @acronym{ASCII}
@cindex C-
@cindex Control
@cindex control characters
GNU Emacs is primarily designed for use with the keyboard. While it
is possible to use the mouse to issue editing commands through the
menu bar and tool bar, that is not as efficient as using the keyboard.
Therefore, this manual mainly documents how to edit with the keyboard.
Keyboard input into Emacs is based on a heavily-extended version of
@acronym{ASCII}. The simplest characters that you can input into
Emacs correspond to graphic symbols such as @samp{a}, @samp{B},
@samp{3}, @samp{=}, the space character (conventionally denoted as
@key{SPC}), and so on. Entering these using the keyboard is
straightforward. Certain characters found on non-English keyboards
also fall into this category (@pxref{International}).
In addition to these simple characters, Emacs recognizes
@dfn{control characters} such as @key{RET}, @key{TAB}, @key{DEL},
@key{ESC}, @key{F1}, @key{Home}, @key{left}, etc. Most keyboards have
special keys for entering these.
@cindex modifier keys
@cindex Control
@cindex C-
@cindex Meta
@cindex M-
Emacs also recognizes control characters that are entered using
@dfn{modifier keys}. Two commonly-used modifier keys are
@key{Control} (which is usually labelled as @key{Ctrl}), and
@key{Meta} (which is usually labeled as @key{Alt})@footnote{We refer
to @key{Alt} as @key{Meta} for historical reasons.}. For example,
@kbd{Control-a} is entered by holding down the @key{Ctrl} key while
pressing @kbd{a}; we will refer to this as @kbd{C-a} for short.
Similarly @kbd{Meta-a}, or @kbd{M-a} for short, is entered by holding
down the @key{Alt} key and pressing @kbd{a}.
@cindex @key{ESC} replacing @key{Meta} key
You can also type Meta characters using two-character sequences
starting with @key{ESC}. Thus, you can enter @kbd{M-a} by typing
@kbd{@key{ESC} a}. You can enter @kbd{C-M-a} by typing @kbd{@key{ESC}
C-a}. Unlike @key{Meta}, @key{ESC} is entered as a separate
character. You don't hold down @key{ESC} while typing the next
character; instead, press @key{ESC} and release it, then enter the
next character. This feature is useful on certain text-only terminals
where the @key{Meta} key does not function reliably.
Modifier keys can apply not only to alphanumerical characters, but
also to special input characters, such as the arrow keys and mouse
buttons.
@cindex input event
@xref{Input Events,,, elisp, The Emacs Lisp Reference Manual}, for
the full Lisp-level details about keyboard and mouse input, which are
collectively referred to as @dfn{input events}. If you are not doing
Lisp programming, but simply want to redefine the meaning of some
characters or non-character events, see @ref{Customization}.
@cindex keys stolen by window manager
@cindex window manager, keys stolen by
On graphical displays, the window manager is likely to block the
character @kbd{M-@key{TAB}} before Emacs can see it. It may also
block @kbd{M-@key{SPC}}, @kbd{C-M-d} and @kbd{C-M-l}. If you have
these problems, we recommend that you customize your window manager to
turn off those commands, or put them on key combinations that Emacs
does not use.
@node Keys, Commands, User Input, Top
@section Keys
Some Emacs commands are invoked by just one input event; for
example, @kbd{C-f} moves forward one character in the buffer. But
Emacs also has commands that take two or more input events to invoke,
such as @kbd{C-x C-f} and @kbd{C-x 4 C-f}.
@cindex key
@cindex key sequence
@cindex complete key
@cindex prefix key
A @dfn{key sequence}, or @dfn{key} for short, is a sequence of one
or more input events that is meaningful as a unit. If a key sequence
invokes a command, we call it a @dfn{complete key}; for example,
@kbd{C-f}, @kbd{C-x C-f} and @kbd{C-x 4 C-f} are all complete keys.
If a key sequence isn't long enough to invoke a command, we call it a
@dfn{prefix key}; from the preceding example, we see that @kbd{C-x}
and @kbd{C-x 4} are prefix keys. Every key is either a complete key
or a prefix key.
A prefix key combines with the following input event to make a
longer key sequence, which may itself be complete or a prefix. For
example, @kbd{C-x} is a prefix key, so @kbd{C-x} and the next input
event combine to make a two-event key sequence. This two-event key
sequence could itself be a prefix key (such as @kbd{C-x 4}), or a
complete key (such as @kbd{C-x C-f}). There is no limit to the length
of a key sequence, but in practice people rarely use sequences longer
than three or four input events.
You can't add input events onto a complete key. For example, the
two-event sequence @kbd{C-f C-k} is not a key, because the @kbd{C-f}
is a complete key in itself, so @kbd{C-f C-k} cannot have an
independent meaning as a command. @kbd{C-f C-k} is two key sequences,
not one.@refill
By default, the prefix keys in Emacs are @kbd{C-c}, @kbd{C-h},
@kbd{C-x}, @kbd{C-x @key{RET}}, @kbd{C-x @@}, @kbd{C-x a}, @kbd{C-x
n}, @kbd{C-x r}, @kbd{C-x v}, @kbd{C-x 4}, @kbd{C-x 5}, @kbd{C-x 6},
@key{ESC}, @kbd{M-g}, and @kbd{M-o}. (@key{F1} and @key{F2} are
aliases for @kbd{C-h} and @kbd{C-x 6}.) This list is not cast in
stone; if you customize Emacs, you can make new prefix keys. You
could even eliminate some of the standard ones, though this is not
recommended for most users; for example, if you remove the prefix
definition of @kbd{C-x 4}, then @kbd{C-x 4 @var{anything}} would
become an invalid key sequence. @xref{Key Bindings}.
Typing the help character (@kbd{C-h} or @key{F1}) after a prefix key
displays a list of the commands starting with that prefix. The sole
exception to this rule is @key{ESC}: @kbd{@key{ESC}C-h} is equivalent
to @kbd{C-M-h}, which does something else entirely. You can, however,
use @key{F1} to displays a list of the commands starting with
@key{ESC}.
@node Commands, Entering Emacs, Keys, Top
@section Keys and Commands
@cindex binding
@cindex command
@cindex function definition
This manual is full of passages that tell you what particular keys
do. But Emacs does not assign meanings to keys directly. Instead,
Emacs assigns meanings to named @dfn{commands}, and then gives keys
their meanings by @dfn{binding} them to commands.
Every command has a name chosen by a programmer. The name is
usually made of a few English words separated by dashes; for example,
@code{next-line} or @code{forward-word}. A command also has a
@dfn{function definition} which is a Lisp program; this is how the
command does its work. In Emacs Lisp, a command is a Lisp function
with special properties that make it suitable for interactive use.
For more information on commands and functions, see @ref{What Is a
Function,, What Is a Function, elisp, The Emacs Lisp Reference
Manual}.
The bindings between keys and commands are recorded in tables called
@dfn{keymaps}. @xref{Keymaps}.
When we say that ``@kbd{C-n} moves down vertically one line'' we are
glossing over a subtle distinction that is irrelevant in ordinary use,
but vital for Emacs customization. The command @code{next-line} does
a vertical move downward. @kbd{C-n} has this effect @emph{because} it
is bound to @code{next-line}. If you rebind @kbd{C-n} to the command
@code{forward-word}, @kbd{C-n} will move forward one word instead.
In this manual, we will often speak of keys like @kbd{C-n} as
commands, even though strictly speaking the key is bound to a command.
Usually we state the name of the command which really does the work in
parentheses after mentioning the key that runs it. For example, we
will say that ``The command @kbd{C-n} (@code{next-line}) moves point
vertically down,'' meaning that the command @code{next-line} moves
vertically down, and the key @kbd{C-n} is normally bound to it.
Since we are discussing customization, we should tell you about
@dfn{variables}. Often the description of a command will say, ``To
change this, set the variable @code{mumble-foo}.'' A variable is a
name used to store a value. Most of the variables documented in this
manual are meant for customization: some command or other part of
Emacs examines the variable and behaves differently according to the
value that you set. You can ignore the information about variables
until you are interested in customizing them. Then read the basic
information on variables (@pxref{Variables}) and the information about
specific variables will make sense.
@ifnottex
@lowersections
@end ifnottex
@ignore
arch-tag: 9be43eef-d1f4-4d03-a916-c741ea713a45
@end ignore
|