view doc/emacs/commands.texi @ 112444:4302934369fd

Improve configuration of makeinfo. * Makefile.in (MAKEINFO): Now controlled by `configure'. (MAKEINFO_OPTS): New variable. Use it where appropriate. (ENVADD): Updated.
author Werner Lemberg <wl@gnu.org>
date Sun, 23 Jan 2011 11:34:39 +0100
parents ef719132ddfa
children
line wrap: on
line source

@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, 2011  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