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