]> code.delx.au - gnu-emacs/blobdiff - man/fixit.texi
*** empty log message ***
[gnu-emacs] / man / fixit.texi
index 591c50495bbb7c44f5191af0c4175d2b09500176..1d7c1b6eb4194fb8e3143237ee7b98d700f4f73c 100644 (file)
@@ -1,7 +1,8 @@
 @c This is part of the Emacs manual.
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
+@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2002, 2003,
+@c   2004, 2005, 2006 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c See file emacs.texi for copying conditions.
-@node Fixit, Files, Search, Top
+@node Fixit, Keyboard Macros, Search, Top
 @chapter Commands for Fixing Typos
 @cindex typos, fixing
 @cindex mistakes, correcting
 @chapter Commands for Fixing Typos
 @cindex typos, fixing
 @cindex mistakes, correcting
@@ -11,20 +12,134 @@ the times when you catch a mistake in your text just after you have made
 it, or change your mind while composing text on the fly.
 
   The most fundamental command for correcting erroneous editing is the
 it, or change your mind while composing text on the fly.
 
   The most fundamental command for correcting erroneous editing is the
-undo command, @kbd{C-x u} or @kbd{C-_}.  This command undoes a single
-command (usually), a part of a command (in the case of
-@code{query-replace}), or several consecutive self-inserting characters.
-Consecutive repetitions of @kbd{C-_} or @kbd{C-x u} undo earlier and
-earlier changes, back to the limit of the undo information available.
-@xref{Undo}, for for more information.
+undo command, @kbd{C-x u} or @kbd{C-_} or @kbd{C-/}.  This command
+undoes a single command (usually), a part of a command (in the case of
+@code{query-replace}), or several consecutive self-inserting
+characters.  Consecutive repetitions of the undo command undo earlier
+and earlier changes, back to the limit of the undo information
+available.  @xref{Undo}, for more information.
 
 @menu
 
 @menu
+* Undo::        The Undo commands.
 * Kill Errors:: Commands to kill a batch of recently entered text.
 * Transpose::   Exchanging two characters, words, lines, lists...
 * Fixing Case:: Correcting case of last word entered.
 * Spelling::    Apply spelling checker to a word, or a whole file.
 @end menu
 
 * Kill Errors:: Commands to kill a batch of recently entered text.
 * Transpose::   Exchanging two characters, words, lines, lists...
 * Fixing Case:: Correcting case of last word entered.
 * Spelling::    Apply spelling checker to a word, or a whole file.
 @end menu
 
+@node Undo
+@section Undo
+@cindex undo
+@cindex changes, undoing
+
+  The @dfn{undo} commands undo recent changes in the buffer's text.
+Each buffer records changes individually, and the undo command always
+applies to the current buffer.  You can undo all the changes in a
+buffer for as far as back these records go.  Usually each editing
+command makes a separate entry in the undo records, but some commands
+such as @code{query-replace} divide their changes into multiple
+entries for flexibility in undoing.  Meanwhile, self-inserting
+characters are usually grouped to make undoing less tedious.
+
+@table @kbd
+@item C-x u
+@itemx C-_
+@itemx C-/
+Undo one entry in the current buffer's undo records (@code{undo}).
+@end table
+
+@kindex C-x u
+@kindex C-_
+@kindex C-/
+@findex undo
+  To begin to undo, type the command @kbd{C-x u} (or its aliases,
+@kbd{C-_} or @kbd{C-/}).  This undoes the most recent change in the
+buffer, and moves point back to where it was before that change.
+
+  Consecutive repetitions of @kbd{C-x u} (or its aliases) undo earlier
+and earlier changes in the current buffer, back to the limit of the
+current buffer's undo records.  If all the recorded changes have
+already been undone, the undo command just signals an error.
+
+  If you notice that a buffer has been modified accidentally, the
+easiest way to recover is to type @kbd{C-_} repeatedly until the stars
+disappear from the front of the mode line.  At this time, all the
+modifications you made have been canceled.  Whenever an undo command
+makes the stars disappear from the mode line, it means that the buffer
+contents are the same as they were when the file was last read in or
+saved.
+
+  If you do not remember whether you changed the buffer deliberately,
+type @kbd{C-_} once.  When you see the last change you made undone, you
+will see whether it was an intentional change.  If it was an accident,
+leave it undone.  If it was deliberate, redo the change as described
+below.
+
+@findex undo-only
+  Any command other than an undo command breaks the sequence of undo
+commands.  Starting from that moment, the previous undo commands
+become ordinary changes that you can undo.  Thus, to redo changes you
+have undone, type @kbd{C-f} or any other command that will harmlessly
+break the sequence of undoing, then type undo commands again.  On the
+other hand, if you want to resume undoing, without redoing previous
+undo commands, use @kbd{M-x undo-only}.  This is like @code{undo}, but
+will not redo changes you have just undone.
+
+@cindex selective undo
+@kindex C-u C-x u
+  Ordinary undo applies to all changes made in the current buffer.  You
+can also perform @dfn{selective undo}, limited to the region.
+
+  To do this, specify the region you want, then run the @code{undo}
+command with a prefix argument (the value does not matter): @kbd{C-u
+C-x u} or @kbd{C-u C-_}.  This undoes the most recent change in the
+region.  To undo further changes in the same region, repeat the
+@code{undo} command (no prefix argument is needed).  In Transient Mark
+mode (@pxref{Transient Mark}), any use of @code{undo} when there is an
+active region performs selective undo; you do not need a prefix
+argument.
+
+  Some specialized buffers do not make undo records.  Buffers
+whose names start with spaces never do; these buffers are used
+internally by Emacs and its extensions to hold text that users don't
+normally look at or edit.
+
+@vindex undo-limit
+@vindex undo-strong-limit
+@vindex undo-outer-limit
+@cindex undo limit
+  When the undo records for a buffer becomes too large, Emacs
+discards the oldest undo records from time to time (during garbage
+collection).  You can specify how much undo records to keep by
+setting three variables: @code{undo-limit}, @code{undo-strong-limit},
+and @code{undo-outer-limit}.  Their values are expressed in units of
+bytes of space.
+
+  The variable @code{undo-limit} sets a soft limit: Emacs keeps undo
+data for enough commands to reach this size, and perhaps exceed it,
+but does not keep data for any earlier commands beyond that.  Its
+default value is 20000.  The variable @code{undo-strong-limit} sets a
+stricter limit: a previous command (not the most recent one) which
+pushes the size past this amount is itself forgotten.  The default
+value of @code{undo-strong-limit} is 30000.
+
+  Regardless of the values of those variables, the most recent change
+is never discarded unless it gets bigger than @code{undo-outer-limit}
+(normally 3,000,000).  At that point, Emacs discards the undo data and
+warns you about it.  This is the only situation in which you cannot
+undo the last command.  If this happens, you can increase the value of
+@code{undo-outer-limit} to make it even less likely to happen in the
+future.  But if you didn't expect the command to create such large
+undo data, then it is probably a bug and you should report it.
+@xref{Bugs,, Reporting Bugs}.
+
+  The reason the @code{undo} command has three key bindings, @kbd{C-x
+u}, @kbd{C-_} and @kbd{C-/}, is that it is worthy of a
+single-character key, but @kbd{C-x u} is more straightforward for
+beginners to remember and type.  Meanwhile, @kbd{C--} on a text-only
+terminal is really @kbd{C-_}, which makes it a natural and easily
+typed binding for undoing.
+
 @node Kill Errors
 @section Killing Your Mistakes
 
 @node Kill Errors
 @section Killing Your Mistakes
 
@@ -40,7 +155,7 @@ Kill to beginning of sentence (@code{backward-kill-sentence}).
   The @key{DEL} character (@code{delete-backward-char}) is the most
 important correction command.  It deletes the character before point.
 When @key{DEL} follows a self-inserting character command, you can think
   The @key{DEL} character (@code{delete-backward-char}) is the most
 important correction command.  It deletes the character before point.
 When @key{DEL} follows a self-inserting character command, you can think
-of it as canceling that command.  However, avoid the mistake of thinking
+of it as canceling that command.  However, avoid the confusion of thinking
 of @key{DEL} as a general way to cancel a command!
 
   When your mistake is longer than a couple of characters, it might be
 of @key{DEL} as a general way to cancel a command!
 
   When your mistake is longer than a couple of characters, it might be
@@ -81,34 +196,36 @@ given at the end of a line, rather than transposing the last character of
 the line with the newline, which would be useless, @kbd{C-t} transposes the
 last two characters on the line.  So, if you catch your transposition error
 right away, you can fix it with just a @kbd{C-t}.  If you don't catch it so
 the line with the newline, which would be useless, @kbd{C-t} transposes the
 last two characters on the line.  So, if you catch your transposition error
 right away, you can fix it with just a @kbd{C-t}.  If you don't catch it so
-fast, you must move the cursor back to between the two transposed
-characters.  If you transposed a space with the last character of the word
-before it, the word motion commands are a good way of getting there.
-Otherwise, a reverse search (@kbd{C-r}) is often the best way.
-@xref{Search}.
-
+fast, you must move the cursor back between the two transposed
+characters before you type @kbd{C-t}.  If you transposed a space with
+the last character of the word before it, the word motion commands are
+a good way of getting there.  Otherwise, a reverse search (@kbd{C-r})
+is often the best way.  @xref{Search}.
 
 @kindex C-x C-t
 @findex transpose-lines
 @kindex M-t
 @findex transpose-words
 
 @kindex C-x C-t
 @findex transpose-lines
 @kindex M-t
 @findex transpose-words
-@kindex C-M-t
-@findex transpose-sexps
-  @kbd{M-t} (@code{transpose-words}) transposes the word before point
-with the word after point.  It moves point forward over a word, dragging
-the word preceding or containing point forward as well.  The punctuation
-characters between the words do not move.  For example, @w{@samp{FOO, BAR}}
-transposes into @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}.
-
-  @kbd{C-M-t} (@code{transpose-sexps}) is a similar command for transposing
-two expressions (@pxref{Lists}), and @kbd{C-x C-t} (@code{transpose-lines})
-exchanges lines.  They work like @kbd{M-t} except in determining the
-division of the text into syntactic units.
+@c Don't index C-M-t and transpose-sexps here, they are indexed in
+@c programs.texi, in the "List Commands" node.
+@c @kindex C-M-t
+@c @findex transpose-sexps
+  @kbd{M-t} transposes the word before point with the word after point
+(@code{transpose-words}).  It moves point forward over a word,
+dragging the word preceding or containing point forward as well.  The
+punctuation characters between the words do not move.  For example,
+@w{@samp{FOO, BAR}} transposes into @w{@samp{BAR, FOO}} rather than
+@samp{@w{BAR FOO,}}.
+
+  @kbd{C-M-t} (@code{transpose-sexps}) is a similar command for
+transposing two expressions (@pxref{Expressions}), and @kbd{C-x C-t}
+(@code{transpose-lines}) exchanges lines.  They work like @kbd{M-t}
+except as regards what units of text they transpose.
 
   A numeric argument to a transpose command serves as a repeat count: it
 
   A numeric argument to a transpose command serves as a repeat count: it
-tells the transpose command to move the character (word, sexp, line)
+tells the transpose command to move the character (word, expression, line)
 before or containing point across several other characters (words,
 before or containing point across several other characters (words,
-sexps, lines).  For example, @kbd{C-u 3 C-t} moves the character before
+expressions, lines).  For example, @kbd{C-u 3 C-t} moves the character before
 point forward across three other characters.  It would change
 @samp{f@point{}oobar} into @samp{oobf@point{}ar}.  This is equivalent to
 repeating @kbd{C-t} three times.  @kbd{C-u - 4 M-t} moves the word
 point forward across three other characters.  It would change
 @samp{f@point{}oobar} into @samp{oobf@point{}ar}.  This is equivalent to
 repeating @kbd{C-t} three times.  @kbd{C-u - 4 M-t} moves the word
@@ -117,8 +234,8 @@ the effect of plain @kbd{C-M-t}.@refill
 
   A numeric argument of zero is assigned a special meaning (because
 otherwise a command with a repeat count of zero would do nothing): to
 
   A numeric argument of zero is assigned a special meaning (because
 otherwise a command with a repeat count of zero would do nothing): to
-transpose the character (word, sexp, line) ending after point with the
-one ending after the mark.
+transpose the character (word, expression, line) ending after point
+with the one ending after the mark.
 
 @node Fixing Case
 @section Case Conversion
 
 @node Fixing Case
 @section Case Conversion
@@ -149,17 +266,20 @@ case-convert it and go on typing.  @xref{Case}.@refill
 
   This section describes the commands to check the spelling of a single
 word or of a portion of a buffer.  These commands work with the spelling
 
   This section describes the commands to check the spelling of a single
 word or of a portion of a buffer.  These commands work with the spelling
-checker program Ispell, which is not part of Emacs.
-@ifinfo
-@xref{Top, Ispell, Overview ispell, ispell.info, The Ispell Manual}.
-@end ifinfo
+checker programs Aspell and Ispell, which are not part of Emacs.
+@ifnottex
+@xref{Top, Aspell,, aspell, The Aspell Manual}.
+@end ifnottex
 
 @table @kbd
 @item M-x flyspell-mode
 Enable Flyspell mode, which highlights all misspelled words.
 
 @table @kbd
 @item M-x flyspell-mode
 Enable Flyspell mode, which highlights all misspelled words.
+@item M-x flyspell-prog-mode
+Enable Flyspell mode for comments and strings only.
 @item M-$
 Check and correct spelling of the word at point (@code{ispell-word}).
 @item M-@key{TAB}
 @item M-$
 Check and correct spelling of the word at point (@code{ispell-word}).
 @item M-@key{TAB}
+@itemx @key{ESC} @key{TAB}
 Complete the word before point based on the spelling dictionary
 (@code{ispell-complete-word}).
 @item M-x ispell
 Complete the word before point based on the spelling dictionary
 (@code{ispell-complete-word}).
 @item M-x ispell
@@ -169,12 +289,12 @@ Check and correct spelling of each word in the buffer.
 @item M-x ispell-region
 Check and correct spelling of each word in the region.
 @item M-x ispell-message
 @item M-x ispell-region
 Check and correct spelling of each word in the region.
 @item M-x ispell-message
-Check and correct spelling of each word in a draft mail message, 
+Check and correct spelling of each word in a draft mail message,
 excluding cited material.
 @item M-x ispell-change-dictionary @key{RET} @var{dict} @key{RET}
 excluding cited material.
 @item M-x ispell-change-dictionary @key{RET} @var{dict} @key{RET}
-Restart the Ispell process, using @var{dict} as the dictionary.
+Restart the Aspell or Ispell process, using @var{dict} as the dictionary.
 @item M-x ispell-kill-ispell
 @item M-x ispell-kill-ispell
-Kill the Ispell subprocess.
+Kill the Aspell or Ispell subprocess.
 @end table
 
 @cindex Flyspell mode
 @end table
 
 @cindex Flyspell mode
@@ -191,14 +311,18 @@ it with @kbd{Mouse-2} to display a menu of possible corrections and
 actions.  You can also correct the word by editing it manually in any
 way you like.
 
 actions.  You can also correct the word by editing it manually in any
 way you like.
 
+@findex flyspell-prog-mode
+Flyspell Prog mode works just like ordinary Flyspell mode, except that
+it only checks words in comments and string constants.  This feature
+is useful for editing programs.  Type @kbd{M-x flyspell-prog-mode} to
+enable or disable this mode in the current buffer.
+
   The other Emacs spell-checking features check or look up words when
   The other Emacs spell-checking features check or look up words when
-you give an explicit command to do so.  Checking all or part of the
-buffer is useful when you have text that was written outside of this
-Emacs session and might contain any number of misspellings.
+you give an explicit command to do so.
 
 @kindex M-$
 @findex ispell-word
 
 @kindex M-$
 @findex ispell-word
-  To check the spelling of the word around or next to point, and
+  To check the spelling of the word around or before point, and
 optionally correct it as well, use the command @kbd{M-$}
 (@code{ispell-word}).  If the word is not correct, the command offers
 you various alternatives for what to do about it.
 optionally correct it as well, use the command @kbd{M-$}
 (@code{ispell-word}).  If the word is not correct, the command offers
 you various alternatives for what to do about it.
@@ -208,7 +332,7 @@ you various alternatives for what to do about it.
   To check the entire current buffer, use @kbd{M-x ispell-buffer}.  Use
 @kbd{M-x ispell-region} to check just the current region.  To check
 spelling in an email message you are writing, use @kbd{M-x
   To check the entire current buffer, use @kbd{M-x ispell-buffer}.  Use
 @kbd{M-x ispell-region} to check just the current region.  To check
 spelling in an email message you are writing, use @kbd{M-x
-ispell-message}; that checks the whole buffer, but does not check
+ispell-message}; that command checks the whole buffer, except for
 material that is indented or appears to be cited from other messages.
 
 @findex ispell
 material that is indented or appears to be cited from other messages.
 
 @findex ispell
@@ -220,7 +344,8 @@ spell-checks the current buffer.
   Each time these commands encounter an incorrect word, they ask you
 what to do.  They display a list of alternatives, usually including
 several ``near-misses''---words that are close to the word being
   Each time these commands encounter an incorrect word, they ask you
 what to do.  They display a list of alternatives, usually including
 several ``near-misses''---words that are close to the word being
-checked.  Then you must type a character.  Here are the valid responses:
+checked.  Then you must type a single-character response.  Here are
+the valid responses:
 
 @table @kbd
 @item @key{SPC}
 
 @table @kbd
 @item @key{SPC}
@@ -228,11 +353,13 @@ Skip this word---continue to consider it incorrect, but don't change it
 here.
 
 @item r @var{new} @key{RET}
 here.
 
 @item r @var{new} @key{RET}
-Replace the word (just this time) with @var{new}.
+Replace the word (just this time) with @var{new}.  (The replacement
+string will be rescanned for more spelling errors.)
 
 @item R @var{new} @key{RET}
 Replace the word with @var{new}, and do a @code{query-replace} so you
 
 @item R @var{new} @key{RET}
 Replace the word with @var{new}, and do a @code{query-replace} so you
-can replace it elsewhere in the buffer if you wish.
+can replace it elsewhere in the buffer if you wish.  (The replacements
+will be rescanned for more spelling errors.)
 
 @item @var{digit}
 Replace the word (just this time) with one of the displayed
 
 @item @var{digit}
 Replace the word (just this time) with one of the displayed
@@ -248,11 +375,11 @@ Accept the incorrect word---treat it as correct, but only in this
 editing session and for this buffer.
 
 @item i
 editing session and for this buffer.
 
 @item i
-Insert this word in your private dictionary file so that Ispell will
-consider it correct it from now on, even in future sessions.
+Insert this word in your private dictionary file so that Aspell or Ispell will
+consider it correct from now on, even in future sessions.
 
 @item u
 
 @item u
-Insert the lower-case version of this word in your private dictionary
+Insert the lower-case version of this word in your private dic@-tion@-ary
 file.
 
 @item m
 file.
 
 @item m
@@ -261,13 +388,14 @@ information.
 
 @item l @var{word} @key{RET}
 Look in the dictionary for words that match @var{word}.  These words
 
 @item l @var{word} @key{RET}
 Look in the dictionary for words that match @var{word}.  These words
-become the new list of ``near-misses''; you can select one of them to
-replace with by typing a digit.  You can use @samp{*} in @var{word} as a
+become the new list of ``near-misses''; you can select one of them as
+the replacement by typing a digit.  You can use @samp{*} in @var{word} as a
 wildcard.
 
 @item C-g
 wildcard.
 
 @item C-g
-Quit interactive spell checking.  You can restart it again afterward
-with @kbd{C-u M-$}.
+Quit interactive spell checking, leaving point at the word that was
+being checked.  You can restart checking again afterward with @kbd{C-u
+M-$}.
 
 @item X
 Same as @kbd{C-g}.
 
 @item X
 Same as @kbd{C-g}.
@@ -285,16 +413,21 @@ Refresh the screen.
 @item C-z
 This key has its normal command meaning (suspend Emacs or iconify this
 frame).
 @item C-z
 This key has its normal command meaning (suspend Emacs or iconify this
 frame).
+
+@item ?
+Show the list of options.
 @end table
 
 @findex ispell-complete-word
   The command @code{ispell-complete-word}, which is bound to the key
 @kbd{M-@key{TAB}} in Text mode and related modes, shows a list of
 completions based on spelling correction.  Insert the beginning of a
 @end table
 
 @findex ispell-complete-word
   The command @code{ispell-complete-word}, which is bound to the key
 @kbd{M-@key{TAB}} in Text mode and related modes, shows a list of
 completions based on spelling correction.  Insert the beginning of a
-word, and then type @kbd{M-@key{TAB}}; the command displays a completion
-list window.  To choose one of the completions listed, click
-@kbd{Mouse-2} on it, or move the cursor there in the completions window
-and type @key{RET}.  @xref{Text Mode}.
+word, and then type @kbd{M-@key{TAB}}; the command displays a
+completion list window.  (If your window manager intercepts
+@kbd{M-@key{TAB}}, type @kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.)  To
+choose one of the completions listed, click @kbd{Mouse-2} or
+@kbd{Mouse-1} fast on it, or move the cursor there in the completions
+window and type @key{RET}.  @xref{Text Mode}.
 
 @ignore
 @findex reload-ispell
 
 @ignore
 @findex reload-ispell
@@ -309,17 +442,30 @@ reload your private dictionary if you edit the file outside of Ispell.
 
 @cindex @code{ispell} program
 @findex ispell-kill-ispell
 
 @cindex @code{ispell} program
 @findex ispell-kill-ispell
-  Once started, the Ispell subprocess continues to run (waiting for
-something to do), so that subsequent spell checking commands complete
-more quickly.  If you want to get rid of the Ispell process, use
-@kbd{M-x ispell-kill-ispell}.  This is not usually necessary, since the
-process uses no time except when you do spelling correction.
+  Once started, the Aspell or Ispell subprocess continues to run
+(waiting for something to do), so that subsequent spell checking
+commands complete more quickly.  If you want to get rid of the
+process, use @kbd{M-x ispell-kill-ispell}.  This is not usually
+necessary, since the process uses no time except when you do spelling
+correction.
 
 @vindex ispell-dictionary
 
 @vindex ispell-dictionary
-  Ispell uses two dictionaries: the standard dictionary and your private
-dictionary.  The variable @code{ispell-dictionary} specifies the file
-name of the standard dictionary to use.  A value of @code{nil} says to
-use the default dictionary.  The command @kbd{M-x
-ispell-change-dictionary} sets this variable and then restarts the
-Ispell subprocess, so that it will use a different dictionary.
+  Ispell and Aspell use two dictionaries together for spell checking: the
+standard dictionary and your private dictionary.  The variable
+@code{ispell-dictionary} specifies the file name to use for the
+standard dictionary; a value of @code{nil} selects the default
+dictionary.  The command @kbd{M-x ispell-change-dictionary} sets this
+variable and then restarts the subprocess, so that it will use
+a different standard dictionary.
+
+@vindex ispell-complete-word-dict
+  Aspell and Ispell use a separate dictionary for word completion.
+The variable @code{ispell-complete-word-dict} specifies the file name
+of this dictionary.  The completion dictionary must be different
+because it cannot use root and affix information.  For some languages
+there is a spell checking dictionary but no word completion
+dictionary.
 
 
+@ignore
+   arch-tag: 3359a443-96ed-448f-9f05-c8111ba8eac0
+@end ignore