emacs-23   [plain text]


This is ../info/emacs, produced by makeinfo version 4.0 from emacs.texi.

   This is the thirteenth edition of the `GNU Emacs Manual', updated
for Emacs version 20.7.

INFO-DIR-SECTION Editors
START-INFO-DIR-ENTRY
* Emacs: (emacs).	The extensible self-documenting text editor.
END-INFO-DIR-ENTRY

   Published by the Free Software Foundation 59 Temple Place, Suite 330
Boston, MA  02111-1307 USA

   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998,
1999    Free Software Foundation, Inc.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
General Public License" are included exactly as in the original, and
provided that the entire resulting derived work is distributed under the
terms of a permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the sections entitled "The GNU Manifesto",
"Distribution" and "GNU General Public License" may be included in a
translation approved by the Free Software Foundation instead of in the
original English.


File: emacs,  Node: Mouse Buttons,  Next: Disabling,  Prev: Non-ASCII Rebinding,  Up: Key Bindings

Rebinding Mouse Buttons
-----------------------

   Emacs uses Lisp symbols to designate mouse buttons, too.  The
ordinary mouse events in Emacs are "click" events; these happen when you
press a button and release it without moving the mouse.  You can also
get "drag" events, when you move the mouse while holding the button
down.  Drag events happen when you finally let go of the button.

   The symbols for basic click events are `mouse-1' for the leftmost
button, `mouse-2' for the next, and so on.  Here is how you can
redefine the second mouse button to split the current window:

     (global-set-key [mouse-2] 'split-window-vertically)

   The symbols for drag events are similar, but have the prefix `drag-'
before the word `mouse'.  For example, dragging the first button
generates a `drag-mouse-1' event.

   You can also define bindings for events that occur when a mouse
button is pressed down.  These events start with `down-' instead of
`drag-'.  Such events are generated only if they have key bindings.
When you get a button-down event, a corresponding click or drag event
will always follow.

   If you wish, you can distinguish single, double, and triple clicks.
A double click means clicking a mouse button twice in approximately the
same place.  The first click generates an ordinary click event.  The
second click, if it comes soon enough, generates a double-click event
instead.  The event type for a double-click event starts with
`double-': for example, `double-mouse-3'.

   This means that you can give a special meaning to the second click at
the same place, but it must act on the assumption that the ordinary
single click definition has run when the first click was received.

   This constrains what you can do with double clicks, but user
interface designers say that this constraint ought to be followed in
any case.  A double click should do something similar to the single
click, only "more so."  The command for the double-click event should
perform the extra work for the double click.

   If a double-click event has no binding, it changes to the
corresponding single-click event.  Thus, if you don't define a
particular double click specially, it executes the single-click command
twice.

   Emacs also supports triple-click events whose names start with
`triple-'.  Emacs does not distinguish quadruple clicks as event types;
clicks beyond the third generate additional triple-click events.
However, the full number of clicks is recorded in the event list, so you
can distinguish if you really want to.  We don't recommend distinct
meanings for more than three clicks, but sometimes it is useful for
subsequent clicks to cycle through the same set of three meanings, so
that four clicks are equivalent to one click, five are equivalent to
two, and six are equivalent to three.

   Emacs also records multiple presses in drag and button-down events.
For example, when you press a button twice, then move the mouse while
holding the button, Emacs gets a `double-drag-' event.  And at the
moment when you press it down for the second time, Emacs gets a
`double-down-' event (which is ignored, like all button-down events, if
it has no binding).

   The variable `double-click-time' specifies how long may elapse
between clicks that are recognized as a pair.  Its value is measured in
milliseconds.  If the value is `nil', double clicks are not detected at
all.  If the value is `t', then there is no time limit.

   The symbols for mouse events also indicate the status of the modifier
keys, with the usual prefixes `C-', `M-', `H-', `s-', `A-' and `S-'.
These always precede `double-' or `triple-', which always precede
`drag-' or `down-'.

   A frame includes areas that don't show text from the buffer, such as
the mode line and the scroll bar.  You can tell whether a mouse button
comes from a special area of the screen by means of dummy "prefix
keys."  For example, if you click the mouse in the mode line, you get
the prefix key `mode-line' before the ordinary mouse-button symbol.
Thus, here is how to define the command for clicking the first button in
a mode line to run `scroll-up':

     (global-set-key [mode-line mouse-1] 'scroll-up)

   Here is the complete list of these dummy prefix keys and their
meanings:

`mode-line'
     The mouse was in the mode line of a window.

`vertical-line'
     The mouse was in the vertical line separating side-by-side
     windows.  (If you use scroll bars, they appear in place of these
     vertical lines.)

`vertical-scroll-bar'
     The mouse was in a vertical scroll bar.  (This is the only kind of
     scroll bar Emacs currently supports.)

   You can put more than one mouse button in a key sequence, but it
isn't usual to do so.


File: emacs,  Node: Disabling,  Prev: Mouse Buttons,  Up: Key Bindings

Disabling Commands
------------------

   Disabling a command marks the command as requiring confirmation
before it can be executed.  The purpose of disabling a command is to
prevent beginning users from executing it by accident and being
confused.

   An attempt to invoke a disabled command interactively in Emacs
displays a window containing the command's name, its documentation, and
some instructions on what to do immediately; then Emacs asks for input
saying whether to execute the command as requested, enable it and
execute it, or cancel.  If you decide to enable the command, you are
asked whether to do this permanently or just for the current session.
Enabling permanently works by automatically editing your `.emacs' file.

   The direct mechanism for disabling a command is to put a non-`nil'
`disabled' property on the Lisp symbol for the command.  Here is the
Lisp program to do this:

     (put 'delete-region 'disabled t)

   If the value of the `disabled' property is a string, that string is
included in the message printed when the command is used:

     (put 'delete-region 'disabled
          "It's better to use `kill-region' instead.\n")

   You can make a command disabled either by editing the `.emacs' file
directly or with the command `M-x disable-command', which edits the
`.emacs' file for you.  Likewise, `M-x enable-command' edits `.emacs'
to enable a command permanently.  *Note Init File::.

   Whether a command is disabled is independent of what key is used to
invoke it; disabling also applies if the command is invoked using
`M-x'.  Disabling a command has no effect on calling it as a function
from Lisp programs.


File: emacs,  Node: Keyboard Translations,  Next: Syntax,  Prev: Key Bindings,  Up: Customization

Keyboard Translations
=====================

   Some keyboards do not make it convenient to send all the special
characters that Emacs uses.  The most common problem case is the <DEL>
character.  Some keyboards provide no convenient way to type this very
important character--usually because they were designed to expect the
character `C-h' to be used for deletion.  On these keyboards, if you
press the key normally used for deletion, Emacs handles the `C-h' as a
prefix character and offers you a list of help options, which is not
what you want.

   You can work around this problem within Emacs by setting up keyboard
translations to turn `C-h' into <DEL> and <DEL> into `C-h', as follows:

     ;; Translate `C-h' to <DEL>.
     (keyboard-translate ?\C-h ?\C-?)
     
     ;; Translate <DEL> to `C-h'.
     (keyboard-translate ?\C-? ?\C-h)

   Keyboard translations are not the same as key bindings in keymaps
(*note Keymaps::).  Emacs contains numerous keymaps that apply in
different situations, but there is only one set of keyboard
translations, and it applies to every character that Emacs reads from
the terminal.  Keyboard translations take place at the lowest level of
input processing; the keys that are looked up in keymaps contain the
characters that result from keyboard translation.

   Under X, the keyboard key named <DELETE> is a function key and is
distinct from the ASCII character named <DEL>.  *Note Named ASCII
Chars::.  Keyboard translations affect only ASCII character input, not
function keys; thus, the above example used under X does not affect the
<DELETE> key.  However, the translation above isn't necessary under X,
because Emacs can also distinguish between the <BACKSPACE> key and
`C-h'; and it normally treats <BACKSPACE> as <DEL>.

   For full information about how to use keyboard translations, see
*Note Translating Input: (elisp)Translating Input.


File: emacs,  Node: Syntax,  Next: Init File,  Prev: Keyboard Translations,  Up: Customization

The Syntax Table
================

   All the Emacs commands which parse words or balance parentheses are
controlled by the "syntax table".  The syntax table says which
characters are opening delimiters, which are parts of words, which are
string quotes, and so on.  Each major mode has its own syntax table
(though sometimes related major modes use the same one) which it
installs in each buffer that uses that major mode.  The syntax table
installed in the current buffer is the one that all commands use, so we
call it "the" syntax table.  A syntax table is a Lisp object, a
char-table, whose elements are numbers.

   To display a description of the contents of the current syntax table,
type `C-h s' (`describe-syntax').  The description of each character
includes both the string you would have to give to
`modify-syntax-entry' to set up that character's current syntax, and
some English to explain that string if necessary.

   For full information on the syntax table, see *Note Syntax Tables:
(elisp)Syntax Tables.


File: emacs,  Node: Init File,  Prev: Syntax,  Up: Customization

The Init File, `~/.emacs'
=========================

   When Emacs is started, it normally loads a Lisp program from the file
`.emacs' or `.emacs.el' in your home directory.  We call this file your
"init file" because it specifies how to initialize Emacs for you.  You
can use the command line switch `-q' to prevent loading your init file,
and `-u' (or `--user') to specify a different user's init file (*note
Entering Emacs::).

   There can also be a "default init file", which is the library named
`default.el', found via the standard search path for libraries.  The
Emacs distribution contains no such library; your site may create one
for local customizations.  If this library exists, it is loaded
whenever you start Emacs (except when you specify `-q').  But your init
file, if any, is loaded first; if it sets `inhibit-default-init'
non-`nil', then `default' is not loaded.

   Your site may also have a "site startup file"; this is named
`site-start.el', if it exists.  Emacs loads this library before it
loads your init file.  To inhibit loading of this library, use the
option `-no-site-file'.

   If you have a large amount of code in your `.emacs' file, you should
rename it to `~/.emacs.el', and byte-compile it.  *Note Byte
Compilation: (elisp)Byte Compilation, for more information about
compiling Emacs Lisp programs.

   If you are going to write actual Emacs Lisp programs that go beyond
minor customization, you should read the `Emacs Lisp Reference Manual'.
*Note Emacs Lisp: (elisp)Top.

* Menu:

* Init Syntax::	        Syntax of constants in Emacs Lisp.
* Init Examples::       How to do some things with an init file.
* Terminal Init::       Each terminal type can have an init file.
* Find Init::	        How Emacs finds the init file.


File: emacs,  Node: Init Syntax,  Next: Init Examples,  Up: Init File

Init File Syntax
----------------

   The `.emacs' file contains one or more Lisp function call
expressions.  Each of these consists of a function name followed by
arguments, all surrounded by parentheses.  For example, `(setq
fill-column 60)' calls the function `setq' to set the variable
`fill-column' (*note Filling::) to 60.

   The second argument to `setq' is an expression for the new value of
the variable.  This can be a constant, a variable, or a function call
expression.  In `.emacs', constants are used most of the time.  They
can be:

Numbers:
     Numbers are written in decimal, with an optional initial minus
     sign.

Strings:
     Lisp string syntax is the same as C string syntax with a few extra
     features.  Use a double-quote character to begin and end a string
     constant.

     In a string, you can include newlines and special characters
     literally.  But often it is cleaner to use backslash sequences for
     them: `\n' for newline, `\b' for backspace, `\r' for carriage
     return, `\t' for tab, `\f' for formfeed (control-L), `\e' for
     escape, `\\' for a backslash, `\"' for a double-quote, or `\OOO'
     for the character whose octal code is OOO.  Backslash and
     double-quote are the only characters for which backslash sequences
     are mandatory.

     `\C-' can be used as a prefix for a control character, as in
     `\C-s' for ASCII control-S, and `\M-' can be used as a prefix for
     a Meta character, as in `\M-a' for `Meta-A' or `\M-\C-a' for
     `Control-Meta-A'.

Characters:
     Lisp character constant syntax consists of a `?' followed by
     either a character or an escape sequence starting with `\'.
     Examples: `?x', `?\n', `?\"', `?\)'.  Note that strings and
     characters are not interchangeable in Lisp; some contexts require
     one and some contexts require the other.

True:
     `t' stands for `true'.

False:
     `nil' stands for `false'.

Other Lisp objects:
     Write a single-quote (') followed by the Lisp object you want.


File: emacs,  Node: Init Examples,  Next: Terminal Init,  Prev: Init Syntax,  Up: Init File

Init File Examples
------------------

   Here are some examples of doing certain commonly desired things with
Lisp expressions:

   * Make <TAB> in C mode just insert a tab if point is in the middle
     of a line.

          (setq c-tab-always-indent nil)

     Here we have a variable whose value is normally `t' for `true' and
     the alternative is `nil' for `false'.

   * Make searches case sensitive by default (in all buffers that do not
     override this).

          (setq-default case-fold-search nil)

     This sets the default value, which is effective in all buffers
     that do not have local values for the variable.  Setting
     `case-fold-search' with `setq' affects only the current buffer's
     local value, which is not what you probably want to do in an init
     file.

   * Specify your own email address, if Emacs can't figure it out
     correctly.

          (setq user-mail-address "coon@yoyodyne.com")

     Various Emacs packages that need your own email address use the
     value of `user-mail-address'.

   * Make Text mode the default mode for new buffers.

          (setq default-major-mode 'text-mode)

     Note that `text-mode' is used because it is the command for
     entering Text mode.  The single-quote before it makes the symbol a
     constant; otherwise, `text-mode' would be treated as a variable
     name.

   * Set up defaults for the Latin-1 character set which supports most
     of the languages of Western Europe.

          (set-language-environment "Latin-1")

   * Turn on Auto Fill mode automatically in Text mode and related
     modes.

          (add-hook 'text-mode-hook
            '(lambda () (auto-fill-mode 1)))

     This shows how to add a hook function to a normal hook variable
     (*note Hooks::).  The function we supply is a list starting with
     `lambda', with a single-quote in front of it to make it a list
     constant rather than an expression.

     It's beyond the scope of this manual to explain Lisp functions,
     but for this example it is enough to know that the effect is to
     execute `(auto-fill-mode 1)' when Text mode is entered.  You can
     replace that with any other expression that you like, or with
     several expressions in a row.

     Emacs comes with a function named `turn-on-auto-fill' whose
     definition is `(lambda () (auto-fill-mode 1))'.  Thus, a simpler
     way to write the above example is as follows:

          (add-hook 'text-mode-hook 'turn-on-auto-fill)

   * Load the installed Lisp library named `foo' (actually a file
     `foo.elc' or `foo.el' in a standard Emacs directory).

          (load "foo")

     When the argument to `load' is a relative file name, not starting
     with `/' or `~', `load' searches the directories in `load-path'
     (*note Lisp Libraries::).

   * Load the compiled Lisp file `foo.elc' from your home directory.

          (load "~/foo.elc")

     Here an absolute file name is used, so no searching is done.

   * Rebind the key `C-x l' to run the function `make-symbolic-link'.

          (global-set-key "\C-xl" 'make-symbolic-link)

     or

          (define-key global-map "\C-xl" 'make-symbolic-link)

     Note once again the single-quote used to refer to the symbol
     `make-symbolic-link' instead of its value as a variable.

   * Do the same thing for Lisp mode only.

          (define-key lisp-mode-map "\C-xl" 'make-symbolic-link)

   * Redefine all keys which now run `next-line' in Fundamental mode so
     that they run `forward-line' instead.

          (substitute-key-definition 'next-line 'forward-line
                                     global-map)

   * Make `C-x C-v' undefined.

          (global-unset-key "\C-x\C-v")

     One reason to undefine a key is so that you can make it a prefix.
     Simply defining `C-x C-v ANYTHING' will make `C-x C-v' a prefix,
     but `C-x C-v' must first be freed of its usual non-prefix
     definition.

   * Make `$' have the syntax of punctuation in Text mode.  Note the
     use of a character constant for `$'.

          (modify-syntax-entry ?\$ "." text-mode-syntax-table)

   * Enable the use of the command `narrow-to-region' without
     confirmation.

          (put 'narrow-to-region 'disabled nil)


File: emacs,  Node: Terminal Init,  Next: Find Init,  Prev: Init Examples,  Up: Init File

Terminal-specific Initialization
--------------------------------

   Each terminal type can have a Lisp library to be loaded into Emacs
when it is run on that type of terminal.  For a terminal type named
TERMTYPE, the library is called `term/TERMTYPE' and it is found by
searching the directories `load-path' as usual and trying the suffixes
`.elc' and `.el'.  Normally it appears in the subdirectory `term' of
the directory where most Emacs libraries are kept.

   The usual purpose of the terminal-specific library is to map the
escape sequences used by the terminal's function keys onto more
meaningful names, using `function-key-map'.  See the file
`term/lk201.el' for an example of how this is done.  Many function keys
are mapped automatically according to the information in the Termcap
data base; the terminal-specific library needs to map only the function
keys that Termcap does not specify.

   When the terminal type contains a hyphen, only the part of the name
before the first hyphen is significant in choosing the library name.
Thus, terminal types `aaa-48' and `aaa-30-rv' both use the library
`term/aaa'.  The code in the library can use `(getenv "TERM")' to find
the full terminal type name.

   The library's name is constructed by concatenating the value of the
variable `term-file-prefix' and the terminal type.  Your `.emacs' file
can prevent the loading of the terminal-specific library by setting
`term-file-prefix' to `nil'.

   Emacs runs the hook `term-setup-hook' at the end of initialization,
after both your `.emacs' file and any terminal-specific library have
been read in.  Add hook functions to this hook if you wish to override
part of any of the terminal-specific libraries and to define
initializations for terminals that do not have a library.  *Note
Hooks::.


File: emacs,  Node: Find Init,  Prev: Terminal Init,  Up: Init File

How Emacs Finds Your Init File
------------------------------

   Normally Emacs uses the environment variable `HOME' to find
`.emacs'; that's what `~' means in a file name.  But if you have done
`su', Emacs tries to find your own `.emacs', not that of the user you
are currently pretending to be.  The idea is that you should get your
own editor customizations even if you are running as the super user.

   More precisely, Emacs first determines which user's init file to use.
It gets the user name from the environment variables `LOGNAME' and
`USER'; if neither of those exists, it uses effective user-ID.  If that
user name matches the real user-ID, then Emacs uses `HOME'; otherwise,
it looks up the home directory corresponding to that user name in the
system's data base of users.


File: emacs,  Node: Quitting,  Next: Lossage,  Prev: Customization,  Up: Top

Quitting and Aborting
=====================

`C-g'
`C-<BREAK> (MS-DOS)'
     Quit.  Cancel running or partially typed command.

`C-]'
     Abort innermost recursive editing level and cancel the command
     which invoked it (`abort-recursive-edit').

`<ESC> <ESC> <ESC>'
     Either quit or abort, whichever makes sense
     (`keyboard-escape-quit').

`M-x top-level'
     Abort all recursive editing levels that are currently executing.

`C-x u'
     Cancel a previously made change in the buffer contents (`undo').

   There are two ways of canceling commands which are not finished
executing: "quitting" with `C-g', and "aborting" with `C-]' or `M-x
top-level'.  Quitting cancels a partially typed command or one which is
already running.  Aborting exits a recursive editing level and cancels
the command that invoked the recursive edit.  (*Note Recursive Edit::.)

   Quitting with `C-g' is used for getting rid of a partially typed
command, or a numeric argument that you don't want.  It also stops a
running command in the middle in a relatively safe way, so you can use
it if you accidentally give a command which takes a long time.  In
particular, it is safe to quit out of killing; either your text will
_all_ still be in the buffer, or it will _all_ be in the kill ring (or
maybe both).  Quitting an incremental search does special things
documented under searching; in general, it may take two successive
`C-g' characters to get out of a search (*note Incremental Search::).

   On MS-DOS, the character `C-<BREAK>' serves as a quit character like
`C-g'.  The reason is that it is not feasible, on MS-DOS, to recognize
`C-g' while a command is running, between interactions with the user.
By contrast, it _is_ feasible to recognize `C-<BREAK>' at all times.
*Note MS-DOS Input::.

   `C-g' works by setting the variable `quit-flag' to `t' the instant
`C-g' is typed; Emacs Lisp checks this variable frequently and quits if
it is non-`nil'.  `C-g' is only actually executed as a command if you
type it while Emacs is waiting for input.

   If you quit with `C-g' a second time before the first `C-g' is
recognized, you activate the "emergency escape" feature and return to
the shell.  *Note Emergency Escape::.

   There may be times when you cannot quit.  When Emacs is waiting for
the operating system to do something, quitting is impossible unless
special pains are taken for the particular system call within Emacs
where the waiting occurs.  We have done this for the system calls that
users are likely to want to quit from, but it's possible you will find
another.  In one very common case--waiting for file input or output
using NFS--Emacs itself knows how to quit, but most NFS implementations
simply do not allow user programs to stop waiting for NFS when the NFS
server is hung.

   Aborting with `C-]' (`abort-recursive-edit') is used to get out of a
recursive editing level and cancel the command which invoked it.
Quitting with `C-g' does not do this, and could not do this, because it
is used to cancel a partially typed command _within_ the recursive
editing level.  Both operations are useful.  For example, if you are in
a recursive edit and type `C-u 8' to enter a numeric argument, you can
cancel that argument with `C-g' and remain in the recursive edit.

   The command `<ESC> <ESC> <ESC>' (`keyboard-escape-quit') can either
quit or abort.  This key was defined because <ESC> is used to "get out"
in many PC programs.  It can cancel a prefix argument, clear a selected
region, or get out of a Query Replace, like `C-g'.  It can get out of
the minibuffer or a recursive edit, like `C-]'.  It can also get out of
splitting the frame into multiple windows, like `C-x 1'.  One thing it
cannot do, however, is stop a command that is running.  That's because
it executes as an ordinary command, and Emacs doesn't notice it until
it is ready for a command.

   The command `M-x top-level' is equivalent to "enough" `C-]' commands
to get you out of all the levels of recursive edits that you are in.
`C-]' gets you out one level at a time, but `M-x top-level' goes out
all levels at once.  Both `C-]' and `M-x top-level' are like all other
commands, and unlike `C-g', in that they take effect only when Emacs is
ready for a command.  `C-]' is an ordinary key and has its meaning only
because of its binding in the keymap.  *Note Recursive Edit::.

   `C-x u' (`undo') is not strictly speaking a way of canceling a
command, but you can think of it as canceling a command that already
finished executing.  *Note Undo::.


File: emacs,  Node: Lossage,  Next: Bugs,  Prev: Quitting,  Up: Top

Dealing with Emacs Trouble
==========================

   This section describes various conditions in which Emacs fails to
work normally, and how to recognize them and correct them.

* Menu:

* DEL Gets Help::       What to do if <DEL> doesn't delete.
* Stuck Recursive::     `[...]' in mode line around the parentheses.
* Screen Garbled::      Garbage on the screen.
* Text Garbled::        Garbage in the text.
* Unasked-for Search::  Spontaneous entry to incremental search.
* Memory Full::         How to cope when you run out of memory.
* After a Crash::       Recovering editing in an Emacs session that crashed.
* Emergency Escape::    Emergency escape---
                          What to do if Emacs stops responding.
* Total Frustration::   When you are at your wits' end.


File: emacs,  Node: DEL Gets Help,  Next: Stuck Recursive,  Up: Lossage

If <DEL> Fails to Delete
------------------------

   If you find that <DEL> enters Help like `Control-h' instead of
deleting a character, your terminal is sending the wrong code for
<DEL>.  You can work around this problem by changing the keyboard
translation table (*note Keyboard Translations::).


File: emacs,  Node: Stuck Recursive,  Next: Screen Garbled,  Prev: DEL Gets Help,  Up: Lossage

Recursive Editing Levels
------------------------

   Recursive editing levels are important and useful features of Emacs,
but they can seem like malfunctions to the user who does not understand
them.

   If the mode line has square brackets `[...]' around the parentheses
that contain the names of the major and minor modes, you have entered a
recursive editing level.  If you did not do this on purpose, or if you
don't understand what that means, you should just get out of the
recursive editing level.  To do so, type `M-x top-level'.  This is
called getting back to top level.  *Note Recursive Edit::.


File: emacs,  Node: Screen Garbled,  Next: Text Garbled,  Prev: Stuck Recursive,  Up: Lossage

Garbage on the Screen
---------------------

   If the data on the screen looks wrong, the first thing to do is see
whether the text is really wrong.  Type `C-l', to redisplay the entire
screen.  If the screen appears correct after this, the problem was
entirely in the previous screen update.  (Otherwise, see *Note Text
Garbled::.)

   Display updating problems often result from an incorrect termcap
entry for the terminal you are using.  The file `etc/TERMS' in the Emacs
distribution gives the fixes for known problems of this sort.
`INSTALL' contains general advice for these problems in one of its
sections.  Very likely there is simply insufficient padding for certain
display operations.  To investigate the possibility that you have this
sort of problem, try Emacs on another terminal made by a different
manufacturer.  If problems happen frequently on one kind of terminal
but not another kind, it is likely to be a bad termcap entry, though it
could also be due to a bug in Emacs that appears for terminals that
have or that lack specific features.


File: emacs,  Node: Text Garbled,  Next: Unasked-for Search,  Prev: Screen Garbled,  Up: Lossage

Garbage in the Text
-------------------

   If `C-l' shows that the text is wrong, try undoing the changes to it
using `C-x u' until it gets back to a state you consider correct.  Also
try `C-h l' to find out what command you typed to produce the observed
results.

   If a large portion of text appears to be missing at the beginning or
end of the buffer, check for the word `Narrow' in the mode line.  If it
appears, the text you don't see is probably still present, but
temporarily off-limits.  To make it accessible again, type `C-x n w'.
*Note Narrowing::.


File: emacs,  Node: Unasked-for Search,  Next: Memory Full,  Prev: Text Garbled,  Up: Lossage

Spontaneous Entry to Incremental Search
---------------------------------------

   If Emacs spontaneously displays `I-search:' at the bottom of the
screen, it means that the terminal is sending `C-s' and `C-q' according
to the poorly designed xon/xoff "flow control" protocol.

   If this happens to you, your best recourse is to put the terminal in
a mode where it will not use flow control, or give it so much padding
that it will never send a `C-s'.  (One way to increase the amount of
padding is to set the variable `baud-rate' to a larger value.  Its
value is the terminal output speed, measured in the conventional units
of baud.)

   If you don't succeed in turning off flow control, the next best thing
is to tell Emacs to cope with it.  To do this, call the function
`enable-flow-control'.

   Typically there are particular terminal types with which you must use
flow control.  You can conveniently ask for flow control on those
terminal types only, using `enable-flow-control-on'.  For example, if
you find you must use flow control on VT-100 and H19 terminals, put the
following in your `.emacs' file:

     (enable-flow-control-on "vt100" "h19")

   When flow control is enabled, you must type `C-\' to get the effect
of a `C-s', and type `C-^' to get the effect of a `C-q'.  (These
aliases work by means of keyboard translations; see *Note Keyboard
Translations::.)


File: emacs,  Node: Memory Full,  Next: After a Crash,  Prev: Unasked-for Search,  Up: Lossage

Running out of Memory
---------------------

   If you get the error message `Virtual memory exceeded', save your
modified buffers with `C-x s'.  This method of saving them has the
smallest need for additional memory.  Emacs keeps a reserve of memory
which it makes available when this error happens; that should be enough
to enable `C-x s' to complete its work.

   Once you have saved your modified buffers, you can exit this Emacs
job and start another, or you can use `M-x kill-some-buffers' to free
space in the current Emacs job.  If you kill buffers containing a
substantial amount of text, you can safely go on editing.  Emacs refills
its memory reserve automatically when it sees sufficient free space
available, in case you run out of memory another time.

   Do not use `M-x buffer-menu' to save or kill buffers when you run
out of memory, because the buffer menu needs a fair amount memory
itself, and the reserve supply may not be enough.


File: emacs,  Node: After a Crash,  Next: Emergency Escape,  Prev: Memory Full,  Up: Lossage

Recovery After a Crash
----------------------

   If Emacs or the computer crashes, you can recover the files you were
editing at the time of the crash from their auto-save files.  To do
this, start Emacs again and type the command `M-x recover-session'.

   This command initially displays a buffer which lists interrupted
session files, each with its date.  You must choose which session to
recover from.  Typically the one you want is the most recent one.  Move
point to the one you choose, and type `C-c C-c'.

   Then `recover-session' asks about each of the files that you were
editing during that session; it asks whether to recover that file.  If
you answer `y' for a file, it shows the dates of that file and its
auto-save file, then asks once again whether to recover that file.  For
the second question, you must confirm with `yes'.  If you do, Emacs
visits the file but gets the text from the auto-save file.

   When `recover-session' is done, the files you've chosen to recover
are present in Emacs buffers.  You should then save them.  Only
this--saving them--updates the files themselves.


File: emacs,  Node: Emergency Escape,  Next: Total Frustration,  Prev: After a Crash,  Up: Lossage

Emergency Escape
----------------

   Because at times there have been bugs causing Emacs to loop without
checking `quit-flag', a special feature causes Emacs to be suspended
immediately if you type a second `C-g' while the flag is already set,
so you can always get out of GNU Emacs.  Normally Emacs recognizes and
clears `quit-flag' (and quits!) quickly enough to prevent this from
happening.  (On MS-DOS and compatible systems, type `C-<BREAK>' twice.)

   When you resume Emacs after a suspension caused by multiple `C-g', it
asks two questions before going back to what it had been doing:

     Auto-save? (y or n)
     Abort (and dump core)? (y or n)

Answer each one with `y' or `n' followed by <RET>.

   Saying `y' to `Auto-save?' causes immediate auto-saving of all
modified buffers in which auto-saving is enabled.

   Saying `y' to `Abort (and dump core)?' causes an illegal instruction
to be executed, dumping core.  This is to enable a wizard to figure out
why Emacs was failing to quit in the first place.  Execution does not
continue after a core dump.  If you answer `n', execution does
continue.  With luck, GNU Emacs will ultimately check `quit-flag' and
quit normally.  If not, and you type another `C-g', it is suspended
again.

   If Emacs is not really hung, just slow, you may invoke the double
`C-g' feature without really meaning to.  Then just resume and answer
`n' to both questions, and you will arrive at your former state.
Presumably the quit you requested will happen soon.

   The double-`C-g' feature is turned off when Emacs is running under
the X Window System, since you can use the window manager to kill Emacs
or to create another window and run another program.

   On MS-DOS and compatible systems, the emergency escape feature is
sometimes unavailable, even if you press `C-<BREAK>' twice, when some
system call (MS-DOS or BIOS) hangs, or when Emacs is stuck in a very
tight endless loop (in C code, *not* in Lisp code).


File: emacs,  Node: Total Frustration,  Prev: Emergency Escape,  Up: Lossage

Help for Total Frustration
--------------------------

   If using Emacs (or something else) becomes terribly frustrating and
none of the techniques described above solve the problem, Emacs can
still help you.

   First, if the Emacs you are using is not responding to commands, type
`C-g C-g' to get out of it and then start a new one.

   Second, type `M-x doctor <RET>'.

   The doctor will help you feel better.  Each time you say something to
the doctor, you must end it by typing <RET> <RET>.  This lets the
doctor know you are finished.


File: emacs,  Node: Bugs,  Next: Contributing,  Prev: Lossage,  Up: Top

Reporting Bugs
==============

   Sometimes you will encounter a bug in Emacs.  Although we cannot
promise we can or will fix the bug, and we might not even agree that it
is a bug, we want to hear about problems you encounter.  Often we agree
they are bugs and want to fix them.

   To make it possible for us to fix a bug, you must report it.  In
order to do so effectively, you must know when and how to do it.

* Menu:

* Criteria:  Bug Criteria.	 Have you really found a bug?
* Understanding Bug Reporting::	 How to report a bug effectively.
* Checklist::			 Steps to follow for a good bug report.
* Sending Patches::		 How to send a patch for GNU Emacs.


File: emacs,  Node: Bug Criteria,  Next: Understanding Bug Reporting,  Up: Bugs

When Is There a Bug
-------------------

   If Emacs executes an illegal instruction, or dies with an operating
system error message that indicates a problem in the program (as
opposed to something like "disk full"), then it is certainly a bug.

   If Emacs updates the display in a way that does not correspond to
what is in the buffer, then it is certainly a bug.  If a command seems
to do the wrong thing but the problem corrects itself if you type
`C-l', it is a case of incorrect display updating.

   Taking forever to complete a command can be a bug, but you must make
certain that it was really Emacs's fault.  Some commands simply take a
long time.  Type `C-g' (`C-<BREAK>' on MS-DOS) and then `C-h l' to see
whether the input Emacs received was what you intended to type; if the
input was such that you _know_ it should have been processed quickly,
report a bug.  If you don't know whether the command should take a long
time, find out by looking in the manual or by asking for assistance.

   If a command you are familiar with causes an Emacs error message in a
case where its usual definition ought to be reasonable, it is probably a
bug.

   If a command does the wrong thing, that is a bug.  But be sure you
know for certain what it ought to have done.  If you aren't familiar
with the command, or don't know for certain how the command is supposed
to work, then it might actually be working right.  Rather than jumping
to conclusions, show the problem to someone who knows for certain.

   Finally, a command's intended definition may not be best for editing
with.  This is a very important sort of problem, but it is also a
matter of judgment.  Also, it is easy to come to such a conclusion out
of ignorance of some of the existing features.  It is probably best not
to complain about such a problem until you have checked the
documentation in the usual ways, feel confident that you understand it,
and know for certain that what you want is not available.  If you are
not sure what the command is supposed to do after a careful reading of
the manual, check the index and glossary for any terms that may be
unclear.

   If after careful rereading of the manual you still do not understand
what the command should do, that indicates a bug in the manual, which
you should report.  The manual's job is to make everything clear to
people who are not Emacs experts--including you.  It is just as
important to report documentation bugs as program bugs.

   If the on-line documentation string of a function or variable
disagrees with the manual, one of them must be wrong; that is a bug.


File: emacs,  Node: Understanding Bug Reporting,  Next: Checklist,  Prev: Bug Criteria,  Up: Bugs

Understanding Bug Reporting
---------------------------

   When you decide that there is a bug, it is important to report it
and to report it in a way which is useful.  What is most useful is an
exact description of what commands you type, starting with the shell
command to run Emacs, until the problem happens.

   The most important principle in reporting a bug is to report
_facts_.  Hypotheses and verbal descriptions are no substitute for the
detailed raw data.  Reporting the facts is straightforward, but many
people strain to posit explanations and report them instead of the
facts.  If the explanations are based on guesses about how Emacs is
implemented, they will be useless; meanwhile, lacking the facts, we will
have no real information about the bug.

   For example, suppose that you type `C-x C-f /glorp/baz.ugh <RET>',
visiting a file which (you know) happens to be rather large, and Emacs
displayed `I feel pretty today'.  The best way to report the bug is
with a sentence like the preceding one, because it gives all the facts.

   A bad way would be to assume that the problem is due to the size of
the file and say, "I visited a large file, and Emacs displayed `I feel
pretty today'."  This is what we mean by "guessing explanations."  The
problem is just as likely to be due to the fact that there is a `z' in
the file name.  If this is so, then when we got your report, we would
try out the problem with some "large file," probably with no `z' in its
name, and not see any problem.  There is no way in the world that we
could guess that we should try visiting a file with a `z' in its name.

   Alternatively, the problem might be due to the fact that the file
starts with exactly 25 spaces.  For this reason, you should make sure
that you inform us of the exact contents of any file that is needed to
reproduce the bug.  What if the problem only occurs when you have typed
the `C-x C-a' command previously?  This is why we ask you to give the
exact sequence of characters you typed since starting the Emacs session.

   You should not even say "visit a file" instead of `C-x C-f' unless
you _know_ that it makes no difference which visiting command is used.
Similarly, rather than saying "if I have three characters on the line,"
say "after I type `<RET> A B C <RET> C-p'," if that is the way you
entered the text.

   So please don't guess any explanations when you report a bug.  If you
want to actually _debug_ the problem, and report explanations that are
more than guesses, that is useful--but please include the facts as well.