Mercurial > emacs
annotate man/fixit.texi @ 32131:3a54b3a6bf40
(substitute-key-definition): Doc fix.
(play-sound-file): new command.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 04 Oct 2000 11:24:51 +0000 |
parents | b65102a3c19d |
children | 11db0318031d |
rev | line source |
---|---|
25829 | 1 @c This is part of the Emacs manual. |
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc. | |
3 @c See file emacs.texi for copying conditions. | |
4 @node Fixit, Files, Search, Top | |
5 @chapter Commands for Fixing Typos | |
6 @cindex typos, fixing | |
7 @cindex mistakes, correcting | |
8 | |
9 In this chapter we describe the commands that are especially useful for | |
10 the times when you catch a mistake in your text just after you have made | |
11 it, or change your mind while composing text on the fly. | |
12 | |
13 The most fundamental command for correcting erroneous editing is the | |
14 undo command, @kbd{C-x u} or @kbd{C-_}. This command undoes a single | |
15 command (usually), a part of a command (in the case of | |
16 @code{query-replace}), or several consecutive self-inserting characters. | |
17 Consecutive repetitions of @kbd{C-_} or @kbd{C-x u} undo earlier and | |
18 earlier changes, back to the limit of the undo information available. | |
19 @xref{Undo}, for for more information. | |
20 | |
21 @menu | |
22 * Kill Errors:: Commands to kill a batch of recently entered text. | |
23 * Transpose:: Exchanging two characters, words, lines, lists... | |
24 * Fixing Case:: Correcting case of last word entered. | |
25 * Spelling:: Apply spelling checker to a word, or a whole file. | |
26 @end menu | |
27 | |
28 @node Kill Errors | |
29 @section Killing Your Mistakes | |
30 | |
31 @table @kbd | |
32 @item @key{DEL} | |
33 Delete last character (@code{delete-backward-char}). | |
34 @item M-@key{DEL} | |
35 Kill last word (@code{backward-kill-word}). | |
36 @item C-x @key{DEL} | |
37 Kill to beginning of sentence (@code{backward-kill-sentence}). | |
38 @end table | |
39 | |
40 The @key{DEL} character (@code{delete-backward-char}) is the most | |
41 important correction command. It deletes the character before point. | |
42 When @key{DEL} follows a self-inserting character command, you can think | |
43 of it as canceling that command. However, avoid the mistake of thinking | |
44 of @key{DEL} as a general way to cancel a command! | |
45 | |
46 When your mistake is longer than a couple of characters, it might be | |
47 more convenient to use @kbd{M-@key{DEL}} or @kbd{C-x @key{DEL}}. | |
48 @kbd{M-@key{DEL}} kills back to the start of the last word, and @kbd{C-x | |
49 @key{DEL}} kills back to the start of the last sentence. @kbd{C-x | |
50 @key{DEL}} is particularly useful when you change your mind about the | |
51 phrasing of the text you are writing. @kbd{M-@key{DEL}} and @kbd{C-x | |
52 @key{DEL}} save the killed text for @kbd{C-y} and @kbd{M-y} to | |
53 retrieve. @xref{Yanking}.@refill | |
54 | |
55 @kbd{M-@key{DEL}} is often useful even when you have typed only a few | |
56 characters wrong, if you know you are confused in your typing and aren't | |
57 sure exactly what you typed. At such a time, you cannot correct with | |
58 @key{DEL} except by looking at the screen to see what you did. Often it | |
59 requires less thought to kill the whole word and start again. | |
60 | |
61 @node Transpose | |
62 @section Transposing Text | |
63 | |
64 @table @kbd | |
65 @item C-t | |
66 Transpose two characters (@code{transpose-chars}). | |
67 @item M-t | |
68 Transpose two words (@code{transpose-words}). | |
69 @item C-M-t | |
70 Transpose two balanced expressions (@code{transpose-sexps}). | |
71 @item C-x C-t | |
72 Transpose two lines (@code{transpose-lines}). | |
73 @end table | |
74 | |
75 @kindex C-t | |
76 @findex transpose-chars | |
77 The common error of transposing two characters can be fixed, when they | |
78 are adjacent, with the @kbd{C-t} command (@code{transpose-chars}). Normally, | |
79 @kbd{C-t} transposes the two characters on either side of point. When | |
80 given at the end of a line, rather than transposing the last character of | |
81 the line with the newline, which would be useless, @kbd{C-t} transposes the | |
82 last two characters on the line. So, if you catch your transposition error | |
83 right away, you can fix it with just a @kbd{C-t}. If you don't catch it so | |
84 fast, you must move the cursor back to between the two transposed | |
85 characters. If you transposed a space with the last character of the word | |
86 before it, the word motion commands are a good way of getting there. | |
87 Otherwise, a reverse search (@kbd{C-r}) is often the best way. | |
88 @xref{Search}. | |
89 | |
90 | |
91 @kindex C-x C-t | |
92 @findex transpose-lines | |
93 @kindex M-t | |
94 @findex transpose-words | |
95 @kindex C-M-t | |
96 @findex transpose-sexps | |
97 @kbd{M-t} (@code{transpose-words}) transposes the word before point | |
98 with the word after point. It moves point forward over a word, dragging | |
99 the word preceding or containing point forward as well. The punctuation | |
100 characters between the words do not move. For example, @w{@samp{FOO, BAR}} | |
101 transposes into @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}. | |
102 | |
103 @kbd{C-M-t} (@code{transpose-sexps}) is a similar command for transposing | |
104 two expressions (@pxref{Lists}), and @kbd{C-x C-t} (@code{transpose-lines}) | |
105 exchanges lines. They work like @kbd{M-t} except in determining the | |
106 division of the text into syntactic units. | |
107 | |
108 A numeric argument to a transpose command serves as a repeat count: it | |
109 tells the transpose command to move the character (word, sexp, line) | |
110 before or containing point across several other characters (words, | |
111 sexps, lines). For example, @kbd{C-u 3 C-t} moves the character before | |
112 point forward across three other characters. It would change | |
113 @samp{f@point{}oobar} into @samp{oobf@point{}ar}. This is equivalent to | |
114 repeating @kbd{C-t} three times. @kbd{C-u - 4 M-t} moves the word | |
115 before point backward across four words. @kbd{C-u - C-M-t} would cancel | |
116 the effect of plain @kbd{C-M-t}.@refill | |
117 | |
118 A numeric argument of zero is assigned a special meaning (because | |
119 otherwise a command with a repeat count of zero would do nothing): to | |
120 transpose the character (word, sexp, line) ending after point with the | |
121 one ending after the mark. | |
122 | |
123 @node Fixing Case | |
124 @section Case Conversion | |
125 | |
126 @table @kbd | |
127 @item M-- M-l | |
128 Convert last word to lower case. Note @kbd{Meta--} is Meta-minus. | |
129 @item M-- M-u | |
130 Convert last word to all upper case. | |
131 @item M-- M-c | |
132 Convert last word to lower case with capital initial. | |
133 @end table | |
134 | |
135 @kindex M-@t{-} M-l | |
136 @kindex M-@t{-} M-u | |
137 @kindex M-@t{-} M-c | |
138 A very common error is to type words in the wrong case. Because of this, | |
139 the word case-conversion commands @kbd{M-l}, @kbd{M-u} and @kbd{M-c} have a | |
140 special feature when used with a negative argument: they do not move the | |
141 cursor. As soon as you see you have mistyped the last word, you can simply | |
142 case-convert it and go on typing. @xref{Case}.@refill | |
143 | |
144 @node Spelling | |
145 @section Checking and Correcting Spelling | |
146 @cindex spelling, checking and correcting | |
147 @cindex checking spelling | |
148 @cindex correcting spelling | |
149 | |
150 This section describes the commands to check the spelling of a single | |
151 word or of a portion of a buffer. These commands work with the spelling | |
152 checker program Ispell, which is not part of Emacs. | |
153 @ifinfo | |
154 @xref{Top, Ispell, Overview ispell, ispell.info, The Ispell Manual}. | |
155 @end ifinfo | |
156 | |
157 @table @kbd | |
158 @item M-x flyspell-mode | |
159 Enable Flyspell mode, which highlights all misspelled words. | |
160 @item M-$ | |
161 Check and correct spelling of the word at point (@code{ispell-word}). | |
162 @item M-@key{TAB} | |
163 Complete the word before point based on the spelling dictionary | |
164 (@code{ispell-complete-word}). | |
31059
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
165 @item M-x ispell |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
166 Spell-check the active region or the current buffer. |
25829 | 167 @item M-x ispell-buffer |
168 Check and correct spelling of each word in the buffer. | |
169 @item M-x ispell-region | |
170 Check and correct spelling of each word in the region. | |
171 @item M-x ispell-message | |
172 Check and correct spelling of each word in a draft mail message, | |
173 excluding cited material. | |
174 @item M-x ispell-change-dictionary @key{RET} @var{dict} @key{RET} | |
175 Restart the Ispell process, using @var{dict} as the dictionary. | |
176 @item M-x ispell-kill-ispell | |
177 Kill the Ispell subprocess. | |
178 @end table | |
179 | |
180 @cindex Flyspell mode | |
181 @findex flyspell-mode | |
182 Flyspell mode is a fully-automatic way to check spelling as you edit | |
183 in Emacs. It operates by checking words as you change or insert them. | |
184 When it finds a word that it does not recognize, it highlights that | |
185 word. This does not interfere with your editing, but when you see the | |
186 highlighted word, you can move to it and fix it. Type @kbd{M-x | |
187 flyspell-mode} to enable or disable this mode in the current buffer. | |
188 | |
189 When Flyspell mode highlights a word as misspelled, you can click on | |
190 it with @kbd{Mouse-2} to display a menu of possible corrections and | |
191 actions. You can also correct the word by editing it manually in any | |
192 way you like. | |
193 | |
194 The other Emacs spell-checking features check or look up words when | |
195 you give an explicit command to do so. Checking all or part of the | |
196 buffer is useful when you have text that was written outside of this | |
197 Emacs session and might contain any number of misspellings. | |
198 | |
199 @kindex M-$ | |
200 @findex ispell-word | |
201 To check the spelling of the word around or next to point, and | |
202 optionally correct it as well, use the command @kbd{M-$} | |
203 (@code{ispell-word}). If the word is not correct, the command offers | |
204 you various alternatives for what to do about it. | |
205 | |
206 @findex ispell-buffer | |
207 @findex ispell-region | |
208 To check the entire current buffer, use @kbd{M-x ispell-buffer}. Use | |
209 @kbd{M-x ispell-region} to check just the current region. To check | |
210 spelling in an email message you are writing, use @kbd{M-x | |
211 ispell-message}; that checks the whole buffer, but does not check | |
212 material that is indented or appears to be cited from other messages. | |
213 | |
31059
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
214 @findex ispell |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
215 @cindex spell-checking the active region |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
216 The @kbd{M-x ispell} command spell-checks the active region if the |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
217 Transient Mark mode is on (@pxref{Transient Mark}), otherwise it |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
218 spell-checks the current buffer. |
b65102a3c19d
Document the new operation of the `ispell' command.
Eli Zaretskii <eliz@gnu.org>
parents:
25829
diff
changeset
|
219 |
25829 | 220 Each time these commands encounter an incorrect word, they ask you |
221 what to do. They display a list of alternatives, usually including | |
222 several ``near-misses''---words that are close to the word being | |
223 checked. Then you must type a character. Here are the valid responses: | |
224 | |
225 @table @kbd | |
226 @item @key{SPC} | |
227 Skip this word---continue to consider it incorrect, but don't change it | |
228 here. | |
229 | |
230 @item r @var{new} @key{RET} | |
231 Replace the word (just this time) with @var{new}. | |
232 | |
233 @item R @var{new} @key{RET} | |
234 Replace the word with @var{new}, and do a @code{query-replace} so you | |
235 can replace it elsewhere in the buffer if you wish. | |
236 | |
237 @item @var{digit} | |
238 Replace the word (just this time) with one of the displayed | |
239 near-misses. Each near-miss is listed with a digit; type that digit to | |
240 select it. | |
241 | |
242 @item a | |
243 Accept the incorrect word---treat it as correct, but only in this | |
244 editing session. | |
245 | |
246 @item A | |
247 Accept the incorrect word---treat it as correct, but only in this | |
248 editing session and for this buffer. | |
249 | |
250 @item i | |
251 Insert this word in your private dictionary file so that Ispell will | |
252 consider it correct it from now on, even in future sessions. | |
253 | |
254 @item u | |
255 Insert the lower-case version of this word in your private dictionary | |
256 file. | |
257 | |
258 @item m | |
259 Like @kbd{i}, but you can also specify dictionary completion | |
260 information. | |
261 | |
262 @item l @var{word} @key{RET} | |
263 Look in the dictionary for words that match @var{word}. These words | |
264 become the new list of ``near-misses''; you can select one of them to | |
265 replace with by typing a digit. You can use @samp{*} in @var{word} as a | |
266 wildcard. | |
267 | |
268 @item C-g | |
269 Quit interactive spell checking. You can restart it again afterward | |
270 with @kbd{C-u M-$}. | |
271 | |
272 @item X | |
273 Same as @kbd{C-g}. | |
274 | |
275 @item x | |
276 Quit interactive spell checking and move point back to where it was | |
277 when you started spell checking. | |
278 | |
279 @item q | |
280 Quit interactive spell checking and kill the Ispell subprocess. | |
281 | |
282 @item C-l | |
283 Refresh the screen. | |
284 | |
285 @item C-z | |
286 This key has its normal command meaning (suspend Emacs or iconify this | |
287 frame). | |
288 @end table | |
289 | |
290 @findex ispell-complete-word | |
291 The command @code{ispell-complete-word}, which is bound to the key | |
292 @kbd{M-@key{TAB}} in Text mode and related modes, shows a list of | |
293 completions based on spelling correction. Insert the beginning of a | |
294 word, and then type @kbd{M-@key{TAB}}; the command displays a completion | |
295 list window. To choose one of the completions listed, click | |
296 @kbd{Mouse-2} on it, or move the cursor there in the completions window | |
297 and type @key{RET}. @xref{Text Mode}. | |
298 | |
299 @ignore | |
300 @findex reload-ispell | |
301 The first time you use any of the spell checking commands, it starts | |
302 an Ispell subprocess. The first thing the subprocess does is read your | |
303 private dictionary, which defaults to the file @file{~/ispell.words}. | |
304 Words that you ``insert'' with the @kbd{i} command are added to that | |
305 file, but not right away---only at the end of the interactive | |
306 replacement procedure. Use the @kbd{M-x reload-ispell} command to | |
307 reload your private dictionary if you edit the file outside of Ispell. | |
308 @end ignore | |
309 | |
310 @cindex @code{ispell} program | |
311 @findex ispell-kill-ispell | |
312 Once started, the Ispell subprocess continues to run (waiting for | |
313 something to do), so that subsequent spell checking commands complete | |
314 more quickly. If you want to get rid of the Ispell process, use | |
315 @kbd{M-x ispell-kill-ispell}. This is not usually necessary, since the | |
316 process uses no time except when you do spelling correction. | |
317 | |
318 @vindex ispell-dictionary | |
319 Ispell uses two dictionaries: the standard dictionary and your private | |
320 dictionary. The variable @code{ispell-dictionary} specifies the file | |
321 name of the standard dictionary to use. A value of @code{nil} says to | |
322 use the default dictionary. The command @kbd{M-x | |
323 ispell-change-dictionary} sets this variable and then restarts the | |
324 Ispell subprocess, so that it will use a different dictionary. | |
325 |