Sync with r21-2-33 and r21-2-33-utf-2000.
[chise/xemacs-chise.git-] / info / xemacs.info-6
1 This is ../info/xemacs.info, produced by makeinfo version 4.0 from
2 xemacs/xemacs.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * XEmacs: (xemacs).             XEmacs Editor.
7 END-INFO-DIR-ENTRY
8
9    This file documents the XEmacs editor.
10
11    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
12 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
13 Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
14
15    Permission is granted to make and distribute verbatim copies of this
16 manual provided the copyright notice and this permission notice are
17 preserved on all copies.
18
19    Permission is granted to copy and distribute modified versions of
20 this manual under the conditions for verbatim copying, provided also
21 that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
22 General Public License" are included exactly as in the original, and
23 provided that the entire resulting derived work is distributed under the
24 terms of a permission notice identical to this one.
25
26    Permission is granted to copy and distribute translations of this
27 manual into another language, under the above conditions for modified
28 versions, except that the sections entitled "The GNU Manifesto",
29 "Distribution" and "GNU General Public License" may be included in a
30 translation approved by the author instead of in the original English.
31
32 \1f
33 File: xemacs.info,  Node: Horizontal Scrolling,  Prev: Scrolling,  Up: Display
34
35 Horizontal Scrolling
36 ====================
37
38 `C-x <'
39      Scroll text in current window to the left (`scroll-left').
40
41 `C-x >'
42      Scroll to the right (`scroll-right').
43
44    The text in a window can also be scrolled horizontally.  This means
45 that each line of text is shifted sideways in the window, and one or
46 more characters at the beginning of each line are not displayed at all.
47 When a window has been scrolled horizontally in this way, text lines
48 are truncated rather than continued (*note Continuation Lines::), with
49 a `$' appearing in the first column when there is text truncated to the
50 left, and in the last column when there is text truncated to the right.
51
52    The command `C-x <' (`scroll-left') scrolls the selected window to
53 the left by N columns with argument N.  With no argument, it scrolls by
54 almost the full width of the window (two columns less, to be precise).
55 `C-x >' (`scroll-right') scrolls similarly to the right.  The window
56 cannot be scrolled any farther to the right once it is displaying
57 normally (with each line starting at the window's left margin);
58 attempting to do so has no effect.
59
60 \1f
61 File: xemacs.info,  Node: Selective Display,  Next: Display Vars,  Prev: Display,  Up: Display
62
63 Selective Display
64 =================
65
66    XEmacs can hide lines indented more than a certain number of columns
67 (you specify how many columns).  This allows you  to get an overview of
68 a part of a program.
69
70    To hide lines, type `C-x $' (`set-selective-display') with a numeric
71 argument N.  (*Note Arguments::, for information on giving the
72 argument.)  Lines with at least N columns of indentation disappear from
73 the screen.  The only indication of their presence are three dots
74 (`...'), which appear at the end of each visible line that is followed
75 by one or more invisible ones.
76
77    The invisible lines are still present in the buffer, and most editing
78 commands see them as usual, so it is very easy to put point in the
79 middle of invisible text.  When this happens, the cursor appears at the
80 end of the previous line, after the three dots.  If point is at the end
81 of the visible line, before the newline that ends it, the cursor
82 appears before the three dots.
83
84    The commands `C-n' and `C-p' move across the invisible lines as if
85 they were not there.
86
87    To make everything visible again, type `C-x $' with no argument.
88
89 \1f
90 File: xemacs.info,  Node: Display Vars,  Prev: Selective Display,  Up: Display
91
92 Variables Controlling Display
93 =============================
94
95    This section contains information for customization only.  Beginning
96 users should skip it.
97
98    When you reenter XEmacs after suspending, XEmacs normally clears the
99 screen and redraws the entire display.  On some terminals with more than
100 one page of memory, it is possible to arrange the termcap entry so that
101 the `ti' and `te' strings (output to the terminal when XEmacs is
102 entered and exited, respectively) switch between pages of memory so as
103 to use one page for XEmacs and another page for other output.  In that
104 case, you might want to set the variable `no-redraw-on-reenter' to
105 non-`nil' so that XEmacs will assume, when resumed, that the screen
106 page it is using still contains what XEmacs last wrote there.
107
108    The variable `echo-keystrokes' controls the echoing of
109 multi-character keys; its value is the number of seconds of pause
110 required to cause echoing to start, or zero, meaning don't echo at all.
111 *Note Echo Area::.
112
113    If the variable `ctl-arrow' is `nil', control characters in the
114 buffer are displayed with octal escape sequences, all except newline and
115 tab.  If its value is `t', then control characters will be printed with
116 an up-arrow, for example `^A'.
117
118    If its value is not `t' and not `nil', then characters whose code is
119 greater than 160 (that is, the space character (32) with its high bit
120 set) will be assumed to be printable, and will be displayed without
121 alteration.  This is the default when running under X Windows, since
122 XEmacs assumes an ISO/8859-1 character set (also known as "Latin1").
123 The `ctl-arrow' variable may also be set to an integer, in which case
124 all characters whose codes are greater than or equal to that value will
125 be assumed to be printable.
126
127    Altering the value of `ctl-arrow' makes it local to the current
128 buffer; until that time, the default value is in effect.  *Note
129 Locals::.
130
131    Normally, a tab character in the buffer is displayed as whitespace
132 which extends to the next display tab stop position, and display tab
133 stops come at intervals equal to eight spaces.  The number of spaces
134 per tab is controlled by the variable `tab-width', which is made local
135 by changing it, just like `ctl-arrow'.  Note that how the tab character
136 in the buffer is displayed has nothing to do with the definition of
137 <TAB> as a command.
138
139    If you set the variable `selective-display-ellipses' to `nil', the
140 three dots at the end of a line that precedes invisible lines do not
141 appear.  There is no visible indication of the invisible lines.  This
142 variable becomes local automatically when set.
143
144 \1f
145 File: xemacs.info,  Node: Search,  Next: Fixit,  Prev: Display,  Up: Top
146
147 Searching and Replacement
148 *************************
149
150    Like other editors, Emacs has commands for searching for occurrences
151 of a string.  The principal search command is unusual in that it is
152 "incremental": it begins to search before you have finished typing the
153 search string.  There are also non-incremental search commands more like
154 those of other editors.
155
156    Besides the usual `replace-string' command that finds all
157 occurrences of one string and replaces them with another, Emacs has a
158 fancy replacement command called `query-replace' which asks
159 interactively which occurrences to replace.
160
161 * Menu:
162
163 * Incremental Search::     Search happens as you type the string.
164 * Non-Incremental Search:: Specify entire string and then search.
165 * Word Search::            Search for sequence of words.
166 * Regexp Search::          Search for match for a regexp.
167 * Regexps::                Syntax of regular expressions.
168 * Search Case::            To ignore case while searching, or not.
169 * Replace::                Search, and replace some or all matches.
170 * Other Repeating Search:: Operating on all matches for some regexp.
171
172 \1f
173 File: xemacs.info,  Node: Incremental Search,  Next: Non-Incremental Search,  Prev: Search,  Up: Search
174
175 Incremental Search
176 ==================
177
178    An incremental search begins searching as soon as you type the first
179 character of the search string.  As you type in the search string, Emacs
180 shows you where the string (as you have typed it so far) is found.
181 When you have typed enough characters to identify the place you want,
182 you can stop.  Depending on what you do next, you may or may not need to
183 terminate the search explicitly with a <RET>.
184
185 `C-s'
186      Incremental search forward (`isearch-forward').
187
188 `C-r'
189      Incremental search backward (`isearch-backward').
190
191    `C-s' starts an incremental search.  `C-s' reads characters from the
192 keyboard and positions the cursor at the first occurrence of the
193 characters that you have typed.  If you type `C-s' and then `F', the
194 cursor moves right after the first `F'.  Type an `O', and see the
195 cursor move to after the first `FO'.  After another `O', the cursor is
196 after the first `FOO' after the place where you started the search.
197 Meanwhile, the search string `FOO' has been echoed in the echo area.
198
199    The echo area display ends with three dots when actual searching is
200 going on.  When search is waiting for more input, the three dots are
201 removed.  (On slow terminals, the three dots are not displayed.)
202
203    If you make a mistake in typing the search string, you can erase
204 characters with <DEL>.  Each <DEL> cancels the last character of the
205 search string.  This does not happen until Emacs is ready to read
206 another input character; first it must either find, or fail to find,
207 the character you want to erase.  If you do not want to wait for this
208 to happen, use `C-g' as described below.
209
210    When you are satisfied with the place you have reached, you can type
211 <RET> (or <C-m>), which stops searching, leaving the cursor where the
212 search brought it.  Any command not specially meaningful in searches
213 also stops the search and is then executed.  Thus, typing `C-a' exits
214 the search and then moves to the beginning of the line.  <RET> is
215 necessary only if the next command you want to type is a printing
216 character, <DEL>, <ESC>, or another control character that is special
217 within searches (`C-q', `C-w', `C-r', `C-s', or `C-y').
218
219    Sometimes you search for `FOO' and find it, but were actually
220 looking for a different occurance of it.  To move to the next occurrence
221 of the search string, type another `C-s'.  Do this as often as
222 necessary.  If you overshoot, you can cancel some `C-s' characters with
223 <DEL>.
224
225    After you exit a search, you can search for the same string again by
226 typing just `C-s C-s': the first `C-s' is the key that invokes
227 incremental search, and the second `C-s' means "search again".
228
229    If the specified string is not found at all, the echo area displays
230 the text `Failing I-Search'.  The cursor is after the place where Emacs
231 found as much of your string as it could.  Thus, if you search for
232 `FOOT', and there is no `FOOT', the cursor may be after the `FOO' in
233 `FOOL'.  At this point there are several things you can do.  If you
234 mistyped the search string, correct it.  If you like the place you have
235 found, you can type <RET> or some other Emacs command to "accept what
236 the search offered".  Or you can type `C-g', which removes from the
237 search string the characters that could not be found (the `T' in
238 `FOOT'), leaving those that were found (the `FOO' in `FOOT').  A second
239 `C-g' at that point cancels the search entirely, returning point to
240 where it was when the search started.
241
242    If a search is failing and you ask to repeat it by typing another
243 `C-s', it starts again from the beginning of the buffer.  Repeating a
244 failing backward search with `C-r' starts again from the end.  This is
245 called "wrapping around".  `Wrapped' appears in the search prompt once
246 this has happened.
247
248    The `C-g' "quit" character does special things during searches; just
249 what it does depends on the status of the search.  If the search has
250 found what you specified and is waiting for input, `C-g' cancels the
251 entire search.  The cursor moves back to where you started the search.
252 If `C-g' is typed when there are characters in the search string that
253 have not been found--because Emacs is still searching for them, or
254 because it has failed to find them--then the search string characters
255 which have not been found are discarded from the search string.  The
256 search is now successful and waiting for more input, so a second `C-g'
257 cancels the entire search.
258
259    To search for a control character such as `C-s' or <DEL> or <ESC>,
260 you must quote it by typing `C-q' first.  This function of `C-q' is
261 analogous to its meaning as an Emacs command: it causes the following
262 character to be treated the way a graphic character would normally be
263 treated in the same context.
264
265    To search backwards, you can use `C-r' instead of `C-s' to start the
266 search; `C-r' is the key that runs the command (`isearch-backward') to
267 search backward.  You can also use `C-r' to change from searching
268 forward to searching backwards.  Do this if a search fails because the
269 place you started was too far down in the file.  Repeated `C-r' keeps
270 looking for more occurrences backwards.  `C-s' starts going forward
271 again.  You can cancel `C-r' in a search with <DEL>.
272
273    The characters `C-y' and `C-w' can be used in incremental search to
274 grab text from the buffer into the search string.  This makes it
275 convenient to search for another occurrence of text at point.  `C-w'
276 copies the word after point as part of the search string, advancing
277 point over that word.  Another `C-s' to repeat the search will then
278 search for a string including that word.  `C-y' is similar to `C-w' but
279 copies the rest of the current line into the search string.
280
281    The characters `M-p' and `M-n' can be used in an incremental search
282 to recall things which you have searched for in the past.  A list of
283 the last 16 things you have searched for is retained, and `M-p' and
284 `M-n' let you cycle through that ring.
285
286    The character `M-<TAB>' does completion on the elements in the
287 search history ring.  For example, if you know that you have recently
288 searched for the string `POTATOE', you could type `C-s P O M-<TAB>'.
289 If you had searched for other strings beginning with `PO' then you
290 would be shown a list of them, and would need to type more to select
291 one.
292
293    You can change any of the special characters in incremental search
294 via the normal keybinding mechanism: simply add a binding to the
295 `isearch-mode-map'.  For example, to make the character `C-b' mean
296 "search backwards" while in isearch-mode, do this:
297
298      (define-key isearch-mode-map "\C-b" 'isearch-repeat-backward)
299
300    These are the default bindings of isearch-mode:
301
302 `DEL'
303      Delete a character from the incremental search string
304      (`isearch-delete-char').
305
306 `RET'
307      Exit incremental search (`isearch-exit').
308
309 `C-q'
310      Quote special characters for incremental search
311      (`isearch-quote-char').
312
313 `C-s'
314      Repeat incremental search forward (`isearch-repeat-forward').
315
316 `C-r'
317      Repeat incremental search backward (`isearch-repeat-backward').
318
319 `C-y'
320      Pull rest of line from buffer into search string
321      (`isearch-yank-line').
322
323 `C-w'
324      Pull next word from buffer into search string
325      (`isearch-yank-word').
326
327 `C-g'
328      Cancels input back to what has been found successfully, or aborts
329      the isearch (`isearch-abort').
330
331 `M-p'
332      Recall the previous element in the isearch history ring
333      (`isearch-ring-retreat').
334
335 `M-n'
336      Recall the next element in the isearch history ring
337      (`isearch-ring-advance').
338
339 `M-<TAB>'
340      Do completion on the elements in the isearch history ring
341      (`isearch-complete').
342
343    Any other character which is normally inserted into a buffer when
344 typed is automatically added to the search string in isearch-mode.
345
346 Slow Terminal Incremental Search
347 --------------------------------
348
349    Incremental search on a slow terminal uses a modified style of
350 display that is designed to take less time.  Instead of redisplaying
351 the buffer at each place the search gets to, it creates a new
352 single-line window and uses that to display the line the search has
353 found.  The single-line window appears as soon as point gets outside of
354 the text that is already on the screen.
355
356    When the search is terminated, the single-line window is removed.
357 Only at this time the window in which the search was done is
358 redisplayed to show its new value of point.
359
360    The three dots at the end of the search string, normally used to
361 indicate that searching is going on, are not displayed in slow style
362 display.
363
364    The slow terminal style of display is used when the terminal baud
365 rate is less than or equal to the value of the variable
366 `search-slow-speed', initially 1200.
367
368    The number of lines to use in slow terminal search display is
369 controlled by the variable `search-slow-window-lines'.  Its normal
370 value is 1.
371
372 \1f
373 File: xemacs.info,  Node: Non-Incremental Search,  Next: Word Search,  Prev: Incremental Search,  Up: Search
374
375 Non-Incremental Search
376 ======================
377
378    Emacs also has conventional non-incremental search commands, which
379 require you type the entire search string before searching begins.
380
381 `C-s <RET> STRING <RET>'
382      Search for STRING.
383
384 `C-r <RET> STRING <RET>'
385      Search backward for STRING.
386
387    To do a non-incremental search, first type `C-s <RET>' (or `C-s
388 C-m').  This enters the minibuffer to read the search string.
389 Terminate the string with <RET> to start the search.  If the string is
390 not found, the search command gets an error.
391
392    By default, `C-s' invokes incremental search, but if you give it an
393 empty argument, which would otherwise be useless, it invokes
394 non-incremental search.  Therefore, `C-s <RET>' invokes non-incremental
395 search.  `C-r <RET>' also works this way.
396
397    Forward and backward non-incremental searches are implemented by the
398 commands `search-forward' and `search-backward'.  You can bind these
399 commands to keys.  The reason that incremental search is programmed to
400 invoke them as well is that `C-s <RET>' is the traditional sequence of
401 characters used in Emacs to invoke non-incremental search.
402
403    Non-incremental searches performed using `C-s <RET>' do not call
404 `search-forward' right away.  They first check if the next character is
405 `C-w', which requests a word search.  *Note Word Search::.
406
407 \1f
408 File: xemacs.info,  Node: Word Search,  Next: Regexp Search,  Prev: Non-Incremental Search,  Up: Search
409
410 Word Search
411 ===========
412
413    Word search looks for a sequence of words without regard to how the
414 words are separated.  More precisely, you type a string of many words,
415 using single spaces to separate them, and the string is found even if
416 there are multiple spaces, newlines or other punctuation between the
417 words.
418
419    Word search is useful in editing documents formatted by text
420 formatters.  If you edit while looking at the printed, formatted
421 version, you can't tell where the line breaks are in the source file.
422 Word search, allows you to search  without having to know the line
423 breaks.
424
425 `C-s <RET> C-w WORDS <RET>'
426      Search for WORDS, ignoring differences in punctuation.
427
428 `C-r <RET> C-w WORDS <RET>'
429      Search backward for WORDS, ignoring differences in punctuation.
430
431    Word search is a special case of non-incremental search.  It is
432 invoked with `C-s <RET> C-w' followed by the search string, which must
433 always be terminated with another <RET>.  Being non-incremental, this
434 search does not start until the argument is terminated.  It works by
435 constructing a regular expression and searching for that.  *Note Regexp
436 Search::.
437
438    You can do a backward word search with `C-r <RET> C-w'.
439
440    Forward and backward word searches are implemented by the commands
441 `word-search-forward' and `word-search-backward'.  You can bind these
442 commands to keys.  The reason that incremental search is programmed to
443 invoke them as well is that `C-s <RET> C-w' is the traditional Emacs
444 sequence of keys for word search.
445
446 \1f
447 File: xemacs.info,  Node: Regexp Search,  Next: Regexps,  Prev: Word Search,  Up: Search
448
449 Regular Expression Search
450 =========================
451
452    A "regular expression" ("regexp", for short) is a pattern that
453 denotes a set of strings, possibly an infinite set.  Searching for
454 matches for a regexp is a powerful operation that editors on Unix
455 systems have traditionally offered.  In XEmacs, you can search for the
456 next match for a regexp either incrementally or not.
457
458    Incremental search for a regexp is done by typing `M-C-s'
459 (`isearch-forward-regexp').  This command reads a search string
460 incrementally just like `C-s', but it treats the search string as a
461 regexp rather than looking for an exact match against the text in the
462 buffer.  Each time you add text to the search string, you make the
463 regexp longer, and the new regexp is searched for.  A reverse regexp
464 search command `isearch-backward-regexp' also exists, but no key runs
465 it.
466
467    All of the control characters that do special things within an
468 ordinary incremental search have the same functionality in incremental
469 regexp search.  Typing `C-s' or `C-r' immediately after starting a
470 search retrieves the last incremental search regexp used: incremental
471 regexp and non-regexp searches have independent defaults.
472
473    Non-incremental search for a regexp is done by the functions
474 `re-search-forward' and `re-search-backward'.  You can invoke them with
475 `M-x' or bind them to keys.  You can also call `re-search-forward' by
476 way of incremental regexp search with `M-C-s <RET>'.
477
478 \1f
479 File: xemacs.info,  Node: Regexps,  Next: Search Case,  Prev: Regexp Search,  Up: Search
480
481 Syntax of Regular Expressions
482 =============================
483
484    Regular expressions have a syntax in which a few characters are
485 special constructs and the rest are "ordinary".  An ordinary character
486 is a simple regular expression which matches that character and nothing
487 else.  The special characters are `$', `^', `.', `*', `+', `?', `[',
488 `]' and `\'; no new special characters will be defined.  Any other
489 character appearing in a regular expression is ordinary, unless a `\'
490 precedes it.
491
492    For example, `f' is not a special character, so it is ordinary, and
493 therefore `f' is a regular expression that matches the string `f' and
494 no other string.  (It does not match the string `ff'.)  Likewise, `o'
495 is a regular expression that matches only `o'.
496
497    Any two regular expressions A and B can be concatenated.  The result
498 is a regular expression which matches a string if A matches some amount
499 of the beginning of that string and B matches the rest of the string.
500
501    As a simple example, you can concatenate the regular expressions `f'
502 and `o' to get the regular expression `fo', which matches only the
503 string `fo'.  To do something nontrivial, you need to use one of the
504 following special characters:
505
506 `. (Period)'
507      is a special character that matches any single character except a
508      newline.  Using concatenation, you can make regular expressions
509      like `a.b', which matches any three-character string which begins
510      with `a' and ends with `b'.
511
512 `*'
513      is not a construct by itself; it is a suffix, which means the
514      preceding regular expression is to be repeated as many times as
515      possible.  In `fo*', the `*' applies to the `o', so `fo*' matches
516      one `f' followed by any number of `o's.  The case of zero `o's is
517      allowed: `fo*' does match `f'.
518
519      `*' always applies to the smallest possible preceding expression.
520      Thus, `fo*' has a repeating `o', not a repeating `fo'.
521
522      The matcher processes a `*' construct by immediately matching as
523      many repetitions as it can find.  Then it continues with the rest
524      of the pattern.  If that fails, backtracking occurs, discarding
525      some of the matches of the `*'-modified construct in case that
526      makes it possible to match the rest of the pattern.  For example,
527      matching `ca*ar' against the string `caaar', the `a*' first tries
528      to match all three `a's; but the rest of the pattern is `ar' and
529      there is only `r' left to match, so this try fails.  The next
530      alternative is for `a*' to match only two `a's.  With this choice,
531      the rest of the regexp matches successfully.
532
533 `+'
534      is a suffix character similar to `*' except that it requires that
535      the preceding expression be matched at least once.  For example,
536      `ca+r' will match the strings `car' and `caaaar' but not the
537      string `cr', whereas `ca*r' would match all three strings.
538
539 `?'
540      is a suffix character similar to `*' except that it can match the
541      preceding expression either once or not at all.  For example,
542      `ca?r' will match `car' or `cr'; nothing else.
543
544 `[ ... ]'
545      `[' begins a "character set", which is terminated by a `]'.  In
546      the simplest case, the characters between the two form the set.
547      Thus, `[ad]' matches either one `a' or one `d', and `[ad]*'
548      matches any string composed of just `a's and `d's (including the
549      empty string), from which it follows that `c[ad]*r' matches `cr',
550      `car', `cdr', `caddaar', etc.
551
552      You can include character ranges in a character set by writing two
553      characters with a `-' between them.  Thus, `[a-z]' matches any
554      lower-case letter.  Ranges may be intermixed freely with individual
555      characters, as in `[a-z$%.]', which matches any lower-case letter
556      or `$', `%', or period.
557
558      Note that inside a character set the usual special characters are
559      not special any more.  A completely different set of special
560      characters exists inside character sets: `]', `-', and `^'.
561
562      To include a `]' in a character set, you must make it the first
563      character.  For example, `[]a]' matches `]' or `a'.  To include a
564      `-', write `---', which is a range containing only `-'.  To
565      include `^', make it other than the first character in the set.
566
567 `[^ ... ]'
568      `[^' begins a "complement character set", which matches any
569      character except the ones specified.  Thus, `[^a-z0-9A-Z]' matches
570      all characters except letters and digits.
571
572      `^' is not special in a character set unless it is the first
573      character.  The character following the `^' is treated as if it
574      were first (`-' and `]' are not special there).
575
576      Note that a complement character set can match a newline, unless
577      newline is mentioned as one of the characters not to match.
578
579 `^'
580      is a special character that matches the empty string, but only if
581      at the beginning of a line in the text being matched.  Otherwise,
582      it fails to match anything.  Thus, `^foo' matches a `foo' that
583      occurs at the beginning of a line.
584
585 `$'
586      is similar to `^' but matches only at the end of a line.  Thus,
587      `xx*$' matches a string of one `x' or more at the end of a line.
588
589 `\'
590      does two things: it quotes the special characters (including `\'),
591      and it introduces additional special constructs.
592
593      Because `\' quotes special characters, `\$' is a regular
594      expression that matches only `$', and `\[' is a regular expression
595      that matches only `[', and so on.
596
597    Note: for historical compatibility, special characters are treated as
598 ordinary ones if they are in contexts where their special meanings make
599 no sense.  For example, `*foo' treats `*' as ordinary since there is no
600 preceding expression on which the `*' can act.  It is poor practice to
601 depend on this behavior; better to quote the special character anyway,
602 regardless of where is appears.
603
604    Usually, `\' followed by any character matches only that character.
605 However, there are several exceptions: characters which, when preceded
606 by `\', are special constructs.  Such characters are always ordinary
607 when encountered on their own.  Here is a table of `\' constructs.
608
609 `\|'
610      specifies an alternative.  Two regular expressions A and B with
611      `\|' in between form an expression that matches anything A or B
612      matches.
613
614      Thus, `foo\|bar' matches either `foo' or `bar' but no other string.
615
616      `\|' applies to the largest possible surrounding expressions.
617      Only a surrounding `\( ... \)' grouping can limit the grouping
618      power of `\|'.
619
620      Full backtracking capability exists to handle multiple uses of
621      `\|'.
622
623 `\( ... \)'
624      is a grouping construct that serves three purposes:
625
626        1. To enclose a set of `\|' alternatives for other operations.
627           Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.
628
629        2. To enclose a complicated expression for the postfix `*' to
630           operate on.  Thus, `ba\(na\)*' matches `bananana', etc., with
631           any (zero or more) number of `na' strings.
632
633        3. To mark a matched substring for future reference.
634
635
636      This last application is not a consequence of the idea of a
637      parenthetical grouping; it is a separate feature which happens to
638      be assigned as a second meaning to the same `\( ... \)' construct
639      because in practice there is no conflict between the two meanings.
640      Here is an explanation:
641
642 `\DIGIT'
643      after the end of a `\( ... \)' construct, the matcher remembers the
644      beginning and end of the text matched by that construct.  Then,
645      later on in the regular expression, you can use `\' followed by
646      DIGIT to mean "match the same text matched the DIGIT'th time by the
647      `\( ... \)' construct."
648
649      The strings matching the first nine `\( ... \)' constructs
650      appearing in a regular expression are assigned numbers 1 through 9
651      in order that the open-parentheses appear in the regular
652      expression.  `\1' through `\9' may be used to refer to the text
653      matched by the corresponding `\( ... \)' construct.
654
655      For example, `\(.*\)\1' matches any newline-free string that is
656      composed of two identical halves.  The `\(.*\)' matches the first
657      half, which may be anything, but the `\1' that follows must match
658      the same exact text.
659
660 `\`'
661      matches the empty string, provided it is at the beginning of the
662      buffer.
663
664 `\''
665      matches the empty string, provided it is at the end of the buffer.
666
667 `\b'
668      matches the empty string, provided it is at the beginning or end
669      of a word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
670      separate word.  `\bballs?\b' matches `ball' or `balls' as a
671      separate word.
672
673 `\B'
674      matches the empty string, provided it is not at the beginning or
675      end of a word.
676
677 `\<'
678      matches the empty string, provided it is at the beginning of a
679      word.
680
681 `\>'
682      matches the empty string, provided it is at the end of a word.
683
684 `\w'
685      matches any word-constituent character.  The editor syntax table
686      determines which characters these are.
687
688 `\W'
689      matches any character that is not a word-constituent.
690
691 `\sCODE'
692      matches any character whose syntax is CODE.  CODE is a character
693      which represents a syntax code: thus, `w' for word constituent,
694      `-' for whitespace, `(' for open-parenthesis, etc.  *Note Syntax::.
695
696 `\SCODE'
697      matches any character whose syntax is not CODE.
698
699    Here is a complicated regexp used by Emacs to recognize the end of a
700 sentence together with any whitespace that follows.  It is given in Lisp
701 syntax to enable you to distinguish the spaces from the tab characters.
702 In Lisp syntax, the string constant begins and ends with a
703 double-quote.  `\"' stands for a double-quote as part of the regexp,
704 `\\' for a backslash as part of the regexp, `\t' for a tab and `\n' for
705 a newline.
706
707      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
708
709 This regexp contains four parts: a character set matching period, `?'
710 or `!'; a character set matching close-brackets, quotes or parentheses,
711 repeated any number of times; an alternative in backslash-parentheses
712 that matches end-of-line, a tab or two spaces; and a character set
713 matching whitespace characters, repeated any number of times.
714
715 \1f
716 File: xemacs.info,  Node: Search Case,  Next: Replace,  Prev: Regexps,  Up: Search
717
718 Searching and Case
719 ==================
720
721    All searches in Emacs normally ignore the case of the text they are
722 searching through; if you specify searching for `FOO', `Foo' and `foo'
723 are also considered a match.  Regexps, and in particular character
724 sets, are included: `[aB]' matches `a' or `A' or `b' or `B'.
725
726    If you want a case-sensitive search, set the variable
727 `case-fold-search' to `nil'.  Then all letters must match exactly,
728 including case. `case-fold-search' is a per-buffer variable; altering
729 it affects only the current buffer, but there is a default value which
730 you can change as well.  *Note Locals::.  You can also use Case
731 Sensitive Search from the Options menu on your screen.
732
733 \1f
734 File: xemacs.info,  Node: Replace,  Next: Other Repeating Search,  Prev: Search Case,  Up: Search
735
736 Replacement Commands
737 ====================
738
739    Global search-and-replace operations are not needed as often in
740 Emacs as they are in other editors, but they are available.  In
741 addition to the simple `replace-string' command which is like that
742 found in most editors, there is a `query-replace' command which asks
743 you, for each occurrence of a pattern, whether to replace it.
744
745    The replace commands all replace one string (or regexp) with one
746 replacement string.  It is possible to perform several replacements in
747 parallel using the command `expand-region-abbrevs'.  *Note Expanding
748 Abbrevs::.
749
750 * Menu:
751
752 * Unconditional Replace::  Replacing all matches for a string.
753 * Regexp Replace::         Replacing all matches for a regexp.
754 * Replacement and Case::   How replacements preserve case of letters.
755 * Query Replace::          How to use querying.
756
757 \1f
758 File: xemacs.info,  Node: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace
759
760 Unconditional Replacement
761 -------------------------
762
763 `M-x replace-string <RET> STRING <RET> NEWSTRING <RET>'
764      Replace every occurrence of STRING with NEWSTRING.
765
766 `M-x replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
767      Replace every match for REGEXP with NEWSTRING.
768
769    To replace every instance of `foo' after point with `bar', use the
770 command `M-x replace-string' with the two arguments `foo' and `bar'.
771 Replacement occurs only after point: if you want to cover the whole
772 buffer you must go to the beginning first.  By default, all occurrences
773 up to the end of the buffer are replaced.  To limit replacement to part
774 of the buffer, narrow to that part of the buffer before doing the
775 replacement (*note Narrowing::).
776
777    When `replace-string' exits, point is left at the last occurrence
778 replaced.  The value of point when the `replace-string' command was
779 issued is remembered on the mark ring; `C-u C-<SPC>' moves back there.
780
781    A numeric argument restricts replacement to matches that are
782 surrounded by word boundaries.
783
784 \1f
785 File: xemacs.info,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace
786
787 Regexp Replacement
788 ------------------
789
790    `replace-string' replaces exact matches for a single string.  The
791 similar command `replace-regexp' replaces any match for a specified
792 pattern.
793
794    In `replace-regexp', the NEWSTRING need not be constant.  It can
795 refer to all or part of what is matched by the REGEXP.  `\&' in
796 NEWSTRING stands for the entire text being replaced.  `\D' in
797 NEWSTRING, where D is a digit, stands for whatever matched the D'th
798 parenthesized grouping in REGEXP.  For example,
799
800      M-x replace-regexp <RET> c[ad]+r <RET> \&-safe <RET>
801
802 would replace (for example) `cadr' with `cadr-safe' and `cddr' with
803 `cddr-safe'.
804
805      M-x replace-regexp <RET> \(c[ad]+r\)-safe <RET> \1 <RET>
806
807 would perform exactly the opposite replacements.  To include a `\' in
808 the text to replace with, you must give `\\'.
809
810 \1f
811 File: xemacs.info,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace
812
813 Replace Commands and Case
814 -------------------------
815
816    If the arguments to a replace command are in lower case, the command
817 preserves case when it makes a replacement.  Thus, the following
818 command:
819
820      M-x replace-string <RET> foo <RET> bar <RET>
821
822 replaces a lower-case `foo' with a lower case `bar', `FOO' with `BAR',
823 and `Foo' with `Bar'.  If upper-case letters are used in the second
824 argument, they remain upper-case every time that argument is inserted.
825 If upper-case letters are used in the first argument, the second
826 argument is always substituted exactly as given, with no case
827 conversion.  Likewise, if the variable `case-replace' is set to `nil',
828 replacement is done without case conversion.  If `case-fold-search' is
829 set to `nil', case is significant in matching occurrences of `foo' to
830 replace; also, case conversion of the replacement string is not done.
831
832 \1f
833 File: xemacs.info,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace
834
835 Query Replace
836 -------------
837
838 `M-% STRING <RET> NEWSTRING <RET>'
839 `M-x query-replace <RET> STRING <RET> NEWSTRING <RET>'
840      Replace some occurrences of STRING with NEWSTRING.
841
842 `M-x query-replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
843      Replace some matches for REGEXP with NEWSTRING.
844
845    If you want to change only some of the occurrences of `foo' to
846 `bar', not all of them, you can use `query-replace' instead of `M-%'.
847 This command finds occurrences of `foo' one by one, displays each
848 occurrence, and asks you whether to replace it.  A numeric argument to
849 `query-replace' tells it to consider only occurrences that are bounded
850 by word-delimiter characters.
851
852    Aside from querying, `query-replace' works just like
853 `replace-string', and `query-replace-regexp' works just like
854 `replace-regexp'.
855
856    The things you can type when you are shown an occurrence of STRING
857 or a match for REGEXP are:
858
859 `<SPC>'
860      to replace the occurrence with NEWSTRING.  This preserves case,
861      just like `replace-string', provided `case-replace' is non-`nil',
862      as it normally is.
863
864 `<DEL>'
865      to skip to the next occurrence without replacing this one.
866
867 `, (Comma)'
868      to replace this occurrence and display the result.  You are then
869      prompted for another input character.  However, since the
870      replacement has already been made, <DEL> and <SPC> are equivalent.
871      At this point, you can type `C-r' (see below) to alter the
872      replaced text.  To undo the replacement, you can type `C-x u'.
873      This exits the `query-replace'.  If you want to do further
874      replacement you must use `C-x ESC' to restart (*note Repetition::).
875
876 `<ESC>'
877      to exit without doing any more replacements.
878
879 `. (Period)'
880      to replace this occurrence and then exit.
881
882 `!'
883      to replace all remaining occurrences without asking again.
884
885 `^'
886      to go back to the location of the previous occurrence (or what
887      used to be an occurrence), in case you changed it by mistake.
888      This works by popping the mark ring.  Only one `^' in a row is
889      allowed, because only one previous replacement location is kept
890      during `query-replace'.
891
892 `C-r'
893      to enter a recursive editing level, in case the occurrence needs
894      to be edited rather than just replaced with NEWSTRING.  When you
895      are done, exit the recursive editing level with `C-M-c' and the
896      next occurrence will be displayed.  *Note Recursive Edit::.
897
898 `C-w'
899      to delete the occurrence, and then enter a recursive editing level
900      as in `C-r'.  Use the recursive edit to insert text to replace the
901      deleted occurrence of STRING.  When done, exit the recursive
902      editing level with `C-M-c' and the next occurrence will be
903      displayed.
904
905 `C-l'
906      to redisplay the screen and then give another answer.
907
908 `C-h'
909      to display a message summarizing these options, then give another
910      answer.
911
912    If you type any other character, Emacs exits the `query-replace', and
913 executes the character as a command.  To restart the `query-replace',
914 use `C-x <ESC>', which repeats the `query-replace' because it used the
915 minibuffer to read its arguments.  *Note C-x ESC: Repetition.
916
917 \1f
918 File: xemacs.info,  Node: Other Repeating Search,  Prev: Replace,  Up: Search
919
920 Other Search-and-Loop Commands
921 ==============================
922
923    Here are some other commands that find matches for a regular
924 expression.  They all operate from point to the end of the buffer.
925
926 `M-x occur'
927      Print each line that follows point and contains a match for the
928      specified regexp.  A numeric argument specifies the number of
929      context lines to print before and after each matching line; the
930      default is none.
931
932      The buffer `*Occur*' containing the output serves as a menu for
933      finding occurrences in their original context.  Find an occurrence
934      as listed in `*Occur*', position point there, and type `C-c C-c';
935      this switches to the buffer that was searched and moves point to
936      the original of the same occurrence.
937
938 `M-x list-matching-lines'
939      Synonym for `M-x occur'.
940
941 `M-x count-matches'
942      Print the number of matches following point for the specified
943      regexp.
944
945 `M-x delete-non-matching-lines'
946      Delete each line that follows point and does not contain a match
947      for the specified regexp.
948
949 `M-x delete-matching-lines'
950      Delete each line that follows point and contains a match for the
951      specified regexp.
952
953 \1f
954 File: xemacs.info,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top
955
956 Commands for Fixing Typos
957 *************************
958
959    This chapter describes commands that are especially useful when you
960 catch a mistake in your text just after you have made it, or when you
961 change your mind while composing text on line.
962
963 * Menu:
964
965 * Kill Errors:: Commands to kill a batch of recently entered text.
966 * Transpose::   Exchanging two characters, words, lines, lists...
967 * Fixing Case:: Correcting case of last word entered.
968 * Spelling::    Apply spelling checker to a word, or a whole file.
969
970 \1f
971 File: xemacs.info,  Node: Kill Errors,  Next: Transpose,  Prev: Fixit,  Up: Fixit
972
973 Killing Your Mistakes
974 =====================
975
976 `<DEL>'
977      Delete last character (`delete-backward-char').
978
979 `M-<DEL>'
980      Kill last word (`backward-kill-word').
981
982 `C-x <DEL>'
983      Kill to beginning of sentence (`backward-kill-sentence').
984
985    The <DEL> character (`delete-backward-char') is the most important
986 correction command.  When used among graphic (self-inserting)
987 characters, it can be thought of as canceling the last character typed.
988
989    When your mistake is longer than a couple of characters, it might be
990 more convenient to use `M-<DEL>' or `C-x <DEL>'.  `M-<DEL>' kills back
991 to the start of the last word, and `C-x <DEL>' kills back to the start
992 of the last sentence.  `C-x <DEL>' is particularly useful when you are
993 thinking of what to write as you type it, in case you change your mind
994 about phrasing.  `M-<DEL>' and `C-x <DEL>' save the killed text for
995 `C-y' and `M-y' to retrieve.  *Note Yanking::.
996
997    `M-<DEL>' is often useful even when you have typed only a few
998 characters wrong, if you know you are confused in your typing and aren't
999 sure exactly what you typed.  At such a time, you cannot correct with
1000 <DEL> except by looking at the screen to see what you did.  It requires
1001 less thought to kill the whole word and start over.
1002
1003 \1f
1004 File: xemacs.info,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
1005
1006 Transposing Text
1007 ================
1008
1009 `C-t'
1010      Transpose two characters (`transpose-chars').
1011
1012 `M-t'
1013      Transpose two words (`transpose-words').
1014
1015 `C-M-t'
1016      Transpose two balanced expressions (`transpose-sexps').
1017
1018 `C-x C-t'
1019      Transpose two lines (`transpose-lines').
1020
1021    The common error of transposing two adjacent characters can be fixed
1022 with the `C-t' command (`transpose-chars').  Normally, `C-t' transposes
1023 the two characters on either side of point.  When given at the end of a
1024 line, `C-t' transposes the last two characters on the line, rather than
1025 transposing the last character of the line with the newline, which
1026 would be useless.  If you catch a transposition error right away, you
1027 can fix it with just `C-t'.  If you catch the error later,  move the
1028 cursor back to between the two transposed characters.  If you
1029 transposed a space with the last character of the word before it, the
1030 word motion commands are a good way of getting there.  Otherwise, a
1031 reverse search (`C-r') is often the best way.  *Note Search::.
1032
1033    `Meta-t' (`transpose-words') transposes the word before point with
1034 the word after point.  It moves point forward over a word, dragging the
1035 word preceding or containing point forward as well.  The punctuation
1036 characters between the words do not move.  For example, `FOO, BAR'
1037 transposes into `BAR, FOO' rather than `BAR FOO,'.
1038
1039    `C-M-t' (`transpose-sexps') is a similar command for transposing two
1040 expressions (*note Lists::), and `C-x C-t' (`transpose-lines')
1041 exchanges lines.  It works like `M-t' but in determines the division of
1042 the text into syntactic units differently.
1043
1044    A numeric argument to a transpose command serves as a repeat count:
1045 it tells the transpose command to move the character (word, sexp, line)
1046 before or containing point across several other characters (words,
1047 sexps, lines).  For example, `C-u 3 C-t' moves the character before
1048 point forward across three other characters.  This is equivalent to
1049 repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
1050 backward across four words.  `C-u - C-M-t' would cancel the effect of
1051 plain `C-M-t'.
1052
1053    A numeric argument of zero transposes the character (word, sexp,
1054 line) ending after point with the one ending after the mark (otherwise a
1055 command with a repeat count of zero would do nothing).
1056
1057 \1f
1058 File: xemacs.info,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
1059
1060 Case Conversion
1061 ===============
1062
1063 `M-- M-l'
1064      Convert last word to lower case.  Note that `Meta--' is
1065      "Meta-minus."
1066
1067 `M-- M-u'
1068      Convert last word to all upper case.
1069
1070 `M-- M-c'
1071      Convert last word to lower case with capital initial.
1072
1073    A  common error is to type words in the wrong case.  Because of this,
1074 the word case-conversion commands `M-l', `M-u', and `M-c' do not move
1075 the cursor when used with a negative argument.  As soon as you see you
1076 have mistyped the last word, you can simply case-convert it and
1077 continue typing.  *Note Case::.
1078
1079 \1f
1080 File: xemacs.info,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
1081
1082 Checking and Correcting Spelling
1083 ================================
1084
1085 `M-$'
1086      Check and correct spelling of word (`spell-word').
1087
1088 `M-x spell-buffer'
1089      Check and correct spelling of each word in the buffer.
1090
1091 `M-x spell-region'
1092      Check and correct spelling of each word in the region.
1093
1094 `M-x spell-string'
1095      Check spelling of specified word.
1096
1097    To check the spelling of the word before point, and optionally
1098 correct it, use the command `M-$' (`spell-word').  This command runs an
1099 inferior process containing the `spell' program to see whether the word
1100 is correct English.  If it is not, it asks you to edit the word (in the
1101 minibuffer) into a corrected spelling, and then performs a
1102 `query-replace' to substitute the corrected spelling for the old one
1103 throughout the buffer.
1104
1105    If you exit the minibuffer without altering the original spelling, it
1106 means you do not want to do anything to that word.  In that case, the
1107 `query-replace' is not done.
1108
1109    `M-x spell-buffer' checks each word in the buffer the same way that
1110 `spell-word' does, doing a `query-replace' for every incorrect word if
1111 appropriate.
1112
1113    `M-x spell-region' is similar to `spell-buffer' but operates only on
1114 the region, not the entire buffer.
1115
1116    `M-x spell-string' reads a string as an argument and checks whether
1117 that is a correctly spelled English word.  It prints a message giving
1118 the answer in the echo area.
1119
1120 \1f
1121 File: xemacs.info,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
1122
1123 File Handling
1124 *************
1125
1126    The basic unit of stored data in Unix is the "file".  To edit a file,
1127 you must tell Emacs to examine the file and prepare a buffer containing
1128 a copy of the file's text.  This is called "visiting" the file.  Editing
1129 commands apply directly to text in the buffer; that is, to the copy
1130 inside Emacs.  Your changes appear in the file itself only when you
1131 "save" the buffer back into the file.
1132
1133    In addition to visiting and saving files, Emacs can delete, copy,
1134 rename, and append to files, and operate on file directories.
1135
1136 * Menu:
1137
1138 * File Names::       How to type and edit file name arguments.
1139 * Visiting::         Visiting a file prepares Emacs to edit the file.
1140 * Saving::           Saving makes your changes permanent.
1141 * Reverting::        Reverting cancels all the changes not saved.
1142 * Auto Save::        Auto Save periodically protects against loss of data.
1143 * Version Control::  Version control systems (RCS and SCCS).
1144 * ListDir::          Listing the contents of a file directory.
1145 * Comparing Files::  Finding where two files differ.
1146 * Dired::            ``Editing'' a directory to delete, rename, etc.
1147                      the files in it.
1148 * Misc File Ops::    Other things you can do on files.
1149