XEmacs 21.4.19 (Constant Variable).
[chise/xemacs-chise.git.1] / info / xemacs.info-2
1 This is ../info/xemacs.info, produced by makeinfo version 4.8 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: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace
34
35 12.7.1 Unconditional Replacement
36 --------------------------------
37
38 `M-x replace-string <RET> STRING <RET> NEWSTRING <RET>'
39      Replace every occurrence of STRING with NEWSTRING.
40
41 `M-x replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
42      Replace every match for REGEXP with NEWSTRING.
43
44    To replace every instance of `foo' after point with `bar', use the
45 command `M-x replace-string' with the two arguments `foo' and `bar'.
46 Replacement occurs only after point: if you want to cover the whole
47 buffer you must go to the beginning first.  By default, all occurrences
48 up to the end of the buffer are replaced.  To limit replacement to part
49 of the buffer, narrow to that part of the buffer before doing the
50 replacement (*note Narrowing::).
51
52    When `replace-string' exits, point is left at the last occurrence
53 replaced.  The value of point when the `replace-string' command was
54 issued is remembered on the mark ring; `C-u C-<SPC>' moves back there.
55
56    A numeric argument restricts replacement to matches that are
57 surrounded by word boundaries.
58
59 \1f
60 File: xemacs.info,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace
61
62 12.7.2 Regexp Replacement
63 -------------------------
64
65 `replace-string' replaces exact matches for a single string.  The
66 similar command `replace-regexp' replaces any match for a specified
67 pattern.
68
69    In `replace-regexp', the NEWSTRING need not be constant.  It can
70 refer to all or part of what is matched by the REGEXP.  `\&' in
71 NEWSTRING stands for the entire text being replaced.  `\D' in
72 NEWSTRING, where D is a digit, stands for whatever matched the D'th
73 parenthesized grouping in REGEXP.  For example,
74
75      M-x replace-regexp <RET> c[ad]+r <RET> \&-safe <RET>
76
77 would replace (for example) `cadr' with `cadr-safe' and `cddr' with
78 `cddr-safe'.
79
80      M-x replace-regexp <RET> \(c[ad]+r\)-safe <RET> \1 <RET>
81
82 would perform exactly the opposite replacements.  To include a `\' in
83 the text to replace with, you must give `\\'.
84
85 \1f
86 File: xemacs.info,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace
87
88 12.7.3 Replace Commands and Case
89 --------------------------------
90
91 If the arguments to a replace command are in lower case, the command
92 preserves case when it makes a replacement.  Thus, the following
93 command:
94
95      M-x replace-string <RET> foo <RET> bar <RET>
96
97 replaces a lower-case `foo' with a lower case `bar', `FOO' with `BAR',
98 and `Foo' with `Bar'.  If upper-case letters are used in the second
99 argument, they remain upper-case every time that argument is inserted.
100 If upper-case letters are used in the first argument, the second
101 argument is always substituted exactly as given, with no case
102 conversion.  Likewise, if the variable `case-replace' is set to `nil',
103 replacement is done without case conversion.  If `case-fold-search' is
104 set to `nil', case is significant in matching occurrences of `foo' to
105 replace; also, case conversion of the replacement string is not done.
106
107 \1f
108 File: xemacs.info,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace
109
110 12.7.4 Query Replace
111 --------------------
112
113 `M-% STRING <RET> NEWSTRING <RET>'
114 `M-x query-replace <RET> STRING <RET> NEWSTRING <RET>'
115      Replace some occurrences of STRING with NEWSTRING.
116
117 `M-x query-replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
118      Replace some matches for REGEXP with NEWSTRING.
119
120    If you want to change only some of the occurrences of `foo' to
121 `bar', not all of them, you can use `query-replace' instead of `M-%'.
122 This command finds occurrences of `foo' one by one, displays each
123 occurrence, and asks you whether to replace it.  A numeric argument to
124 `query-replace' tells it to consider only occurrences that are bounded
125 by word-delimiter characters.
126
127    Aside from querying, `query-replace' works just like
128 `replace-string', and `query-replace-regexp' works just like
129 `replace-regexp'.
130
131    The things you can type when you are shown an occurrence of STRING
132 or a match for REGEXP are:
133
134 `<SPC>'
135      to replace the occurrence with NEWSTRING.  This preserves case,
136      just like `replace-string', provided `case-replace' is non-`nil',
137      as it normally is.
138
139 `<DEL>'
140      to skip to the next occurrence without replacing this one.
141
142 `, (Comma)'
143      to replace this occurrence and display the result.  You are then
144      prompted for another input character.  However, since the
145      replacement has already been made, <DEL> and <SPC> are equivalent.
146      At this point, you can type `C-r' (see below) to alter the
147      replaced text.  To undo the replacement, you can type `C-x u'.
148      This exits the `query-replace'.  If you want to do further
149      replacement you must use `C-x <ESC> <ESC>' to restart (*note
150      Repetition::).
151
152 `<ESC>'
153      to exit without doing any more replacements.
154
155 `. (Period)'
156      to replace this occurrence and then exit.
157
158 `!'
159      to replace all remaining occurrences without asking again.
160
161 `^'
162      to go back to the location of the previous occurrence (or what
163      used to be an occurrence), in case you changed it by mistake.
164      This works by popping the mark ring.  Only one `^' in a row is
165      allowed, because only one previous replacement location is kept
166      during `query-replace'.
167
168 `C-r'
169      to enter a recursive editing level, in case the occurrence needs
170      to be edited rather than just replaced with NEWSTRING.  When you
171      are done, exit the recursive editing level with `C-M-c' and the
172      next occurrence will be displayed.  *Note Recursive Edit::.
173
174 `C-w'
175      to delete the occurrence, and then enter a recursive editing level
176      as in `C-r'.  Use the recursive edit to insert text to replace the
177      deleted occurrence of STRING.  When done, exit the recursive
178      editing level with `C-M-c' and the next occurrence will be
179      displayed.
180
181 `C-l'
182      to redisplay the screen and then give another answer.
183
184 `C-h'
185      to display a message summarizing these options, then give another
186      answer.
187
188    If you type any other character, Emacs exits the `query-replace', and
189 executes the character as a command.  To restart the `query-replace',
190 use `C-x <ESC> <ESC>', which repeats the `query-replace' because it
191 used the minibuffer to read its arguments.  *Note C-x ESC ESC:
192 Repetition.
193
194 \1f
195 File: xemacs.info,  Node: Other Repeating Search,  Prev: Replace,  Up: Search
196
197 12.8 Other Search-and-Loop Commands
198 ===================================
199
200 Here are some other commands that find matches for a regular expression.
201 They all operate from point to the end of the buffer.
202
203 `M-x occur'
204      Print each line that follows point and contains a match for the
205      specified regexp.  A numeric argument specifies the number of
206      context lines to print before and after each matching line; the
207      default is none.
208
209      The buffer `*Occur*' containing the output serves as a menu for
210      finding occurrences in their original context.  Find an occurrence
211      as listed in `*Occur*', position point there, and type `C-c C-c';
212      this switches to the buffer that was searched and moves point to
213      the original of the same occurrence.
214
215 `M-x list-matching-lines'
216      Synonym for `M-x occur'.
217
218 `M-x count-matches'
219      Print the number of matches following point for the specified
220      regexp.
221
222 `M-x delete-non-matching-lines'
223      Delete each line that follows point and does not contain a match
224      for the specified regexp.
225
226 `M-x delete-matching-lines'
227      Delete each line that follows point and contains a match for the
228      specified regexp.
229
230 \1f
231 File: xemacs.info,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top
232
233 13 Commands for Fixing Typos
234 ****************************
235
236 This chapter describes commands that are especially useful when you
237 catch a mistake in your text just after you have made it, or when you
238 change your mind while composing text on line.
239
240 * Menu:
241
242 * Kill Errors:: Commands to kill a batch of recently entered text.
243 * Transpose::   Exchanging two characters, words, lines, lists...
244 * Fixing Case:: Correcting case of last word entered.
245 * Spelling::    Apply spelling checker to a word, or a whole file.
246
247 \1f
248 File: xemacs.info,  Node: Kill Errors,  Next: Transpose,  Prev: Fixit,  Up: Fixit
249
250 13.1 Killing Your Mistakes
251 ==========================
252
253 `<DEL>'
254      Delete last character (`delete-backward-char').
255
256 `M-<DEL>'
257      Kill last word (`backward-kill-word').
258
259 `C-x <DEL>'
260      Kill to beginning of sentence (`backward-kill-sentence').
261
262    The <DEL> character (`delete-backward-char') is the most important
263 correction command.  When used among graphic (self-inserting)
264 characters, it can be thought of as canceling the last character typed.
265
266    When your mistake is longer than a couple of characters, it might be
267 more convenient to use `M-<DEL>' or `C-x <DEL>'.  `M-<DEL>' kills back
268 to the start of the last word, and `C-x <DEL>' kills back to the start
269 of the last sentence.  `C-x <DEL>' is particularly useful when you are
270 thinking of what to write as you type it, in case you change your mind
271 about phrasing.  `M-<DEL>' and `C-x <DEL>' save the killed text for
272 `C-y' and `M-y' to retrieve.  *Note Yanking::.
273
274    `M-<DEL>' is often useful even when you have typed only a few
275 characters wrong, if you know you are confused in your typing and aren't
276 sure exactly what you typed.  At such a time, you cannot correct with
277 <DEL> except by looking at the screen to see what you did.  It requires
278 less thought to kill the whole word and start over.
279
280 \1f
281 File: xemacs.info,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
282
283 13.2 Transposing Text
284 =====================
285
286 `C-t'
287      Transpose two characters (`transpose-chars').
288
289 `M-t'
290      Transpose two words (`transpose-words').
291
292 `C-M-t'
293      Transpose two balanced expressions (`transpose-sexps').
294
295 `C-x C-t'
296      Transpose two lines (`transpose-lines').
297
298    The common error of transposing two adjacent characters can be fixed
299 with the `C-t' command (`transpose-chars').  Normally, `C-t' transposes
300 the two characters on either side of point.  When given at the end of a
301 line, `C-t' transposes the last two characters on the line, rather than
302 transposing the last character of the line with the newline, which
303 would be useless.  If you catch a transposition error right away, you
304 can fix it with just `C-t'.  If you catch the error later,  move the
305 cursor back to between the two transposed characters.  If you
306 transposed a space with the last character of the word before it, the
307 word motion commands are a good way of getting there.  Otherwise, a
308 reverse search (`C-r') is often the best way.  *Note Search::.
309
310    `Meta-t' (`transpose-words') transposes the word before point with
311 the word after point.  It moves point forward over a word, dragging the
312 word preceding or containing point forward as well.  The punctuation
313 characters between the words do not move.  For example, `FOO, BAR'
314 transposes into `BAR, FOO' rather than `BAR FOO,'.
315
316    `C-M-t' (`transpose-sexps') is a similar command for transposing two
317 expressions (*note Lists::), and `C-x C-t' (`transpose-lines')
318 exchanges lines.  It works like `M-t' but in determines the division of
319 the text into syntactic units differently.
320
321    A numeric argument to a transpose command serves as a repeat count:
322 it tells the transpose command to move the character (word, sexp, line)
323 before or containing point across several other characters (words,
324 sexps, lines).  For example, `C-u 3 C-t' moves the character before
325 point forward across three other characters.  This is equivalent to
326 repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
327 backward across four words.  `C-u - C-M-t' would cancel the effect of
328 plain `C-M-t'.
329
330    A numeric argument of zero transposes the character (word, sexp,
331 line) ending after point with the one ending after the mark (otherwise a
332 command with a repeat count of zero would do nothing).
333
334 \1f
335 File: xemacs.info,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
336
337 13.3 Case Conversion
338 ====================
339
340 `M-- M-l'
341      Convert last word to lower case.  Note that `Meta--' is
342      "Meta-minus."
343
344 `M-- M-u'
345      Convert last word to all upper case.
346
347 `M-- M-c'
348      Convert last word to lower case with capital initial.
349
350    A  common error is to type words in the wrong case.  Because of this,
351 the word case-conversion commands `M-l', `M-u', and `M-c' do not move
352 the cursor when used with a negative argument.  As soon as you see you
353 have mistyped the last word, you can simply case-convert it and
354 continue typing.  *Note Case::.
355
356 \1f
357 File: xemacs.info,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
358
359 13.4 Checking and Correcting Spelling
360 =====================================
361
362 `M-$'
363      Check and correct spelling of word (`spell-word').
364
365 `M-x spell-buffer'
366      Check and correct spelling of each word in the buffer.
367
368 `M-x spell-region'
369      Check and correct spelling of each word in the region.
370
371 `M-x spell-string'
372      Check spelling of specified word.
373
374    To check the spelling of the word before point, and optionally
375 correct it, use the command `M-$' (`spell-word').  This command runs an
376 inferior process containing the `spell' program to see whether the word
377 is correct English.  If it is not, it asks you to edit the word (in the
378 minibuffer) into a corrected spelling, and then performs a
379 `query-replace' to substitute the corrected spelling for the old one
380 throughout the buffer.
381
382    If you exit the minibuffer without altering the original spelling, it
383 means you do not want to do anything to that word.  In that case, the
384 `query-replace' is not done.
385
386    `M-x spell-buffer' checks each word in the buffer the same way that
387 `spell-word' does, doing a `query-replace' for every incorrect word if
388 appropriate.
389
390    `M-x spell-region' is similar to `spell-buffer' but operates only on
391 the region, not the entire buffer.
392
393    `M-x spell-string' reads a string as an argument and checks whether
394 that is a correctly spelled English word.  It prints a message giving
395 the answer in the echo area.
396
397 \1f
398 File: xemacs.info,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
399
400 14 File Handling
401 ****************
402
403 The basic unit of stored data in Unix is the "file".  To edit a file,
404 you must tell Emacs to examine the file and prepare a buffer containing
405 a copy of the file's text.  This is called "visiting" the file.  Editing
406 commands apply directly to text in the buffer; that is, to the copy
407 inside Emacs.  Your changes appear in the file itself only when you
408 "save" the buffer back into the file.
409
410    Emacs is also able to handle "remote files" which are stored on
411 other hosts.  Not only is Emacs somewhat aware of the special issues
412 involved with network file systems, but it can also use FTP and ssh (or
413 rsh) to make local copies of the files, and refresh them on the remote
414 host automatically when you save the buffer.  The FTP interface is
415 provided by the standard `efs' package *Note EFS: (efs)Top.  The
416 ssh/rsh interface is provided by the optional `tramp' package *Note
417 TRAMP: (tramp)Top.  These packages attempt to implement all of the
418 operations described below, making remote file use transparent (except
419 for unavoidable network delays).
420
421    In addition to visiting and saving files, Emacs can delete, copy,
422 rename, and append to files, and operate on file directories.
423
424 * Menu:
425
426 * File Names::       How to type and edit file name arguments.
427 * Visiting::         Visiting a file prepares Emacs to edit the file.
428 * Saving::           Saving makes your changes permanent.
429 * Reverting::        Reverting cancels all the changes not saved.
430 * Auto Save::        Auto Save periodically protects against loss of data.
431 * Version Control::  Version control systems (RCS and SCCS).
432 * ListDir::          Listing the contents of a file directory.
433 * Comparing Files::  Finding where two files differ.
434 * Dired::            ``Editing'' a directory to delete, rename, etc.
435                      the files in it.
436 * Misc File Ops::    Other things you can do on files.
437
438 \1f
439 File: xemacs.info,  Node: File Names,  Next: Visiting,  Prev: Files,  Up: Files
440
441 14.1 File Names
442 ===============
443
444 Most Emacs commands that operate on a file require you to specify the
445 file name.  (Saving and reverting are exceptions; the buffer knows which
446 file name to use for them.)  File names are specified in the minibuffer
447 (*note Minibuffer::).  "Completion" is available, to make it easier to
448 specify long file names.  *Note Completion::.
449
450    There is always a "default file name" which is used if you enter an
451 empty argument by typing just <RET>.  Normally the default file name is
452 the name of the file visited in the current buffer; this makes it easy
453 to operate on that file with any of the Emacs file commands.
454
455    The syntax for accessing remote files unfortunately varies depending
456 on the method used.  The syntax for using FTP is
457 `/USER@REMOTE-HOST:PATH-ON-REMOTE-HOST'.  The syntax for using ssh is
458 `/[USER@REMOTE-HOST]PATH-ON-REMOTE-HOST'.
459
460    In both cases the `USER@' portion is optional (it defaults to your
461 local user name).  PATH-ON-REMOTE-HOST may use the `~' notation to
462 indicate USER's home directory on the remote host.  The default file
463 name will reflect the remote host information.
464
465    Each buffer has a default directory, normally the same as the
466 directory of the file visited in that buffer.  When Emacs reads a file
467 name, the default directory is used if you do not specify a directory.
468 If you specify a directory in a relative fashion, with a name that does
469 not start with a slash, it is interpreted with respect to the default
470 directory.  The default directory of the current buffer is kept in the
471 variable `default-directory', which has a separate value in every
472 buffer.  The value of the variable should end with a slash.
473
474    For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
475 the default directory is `/u/rms/gnu/'.  If you type just `foo', which
476 does not specify a directory, it is short for `/u/rms/gnu/foo'.
477 `../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
478 the filename `/u/rms/gnu/new/foo'.
479
480    When visiting a remote file via EFS or TRAMP, the remote directory
481 becomes the default directory (*note Visiting::) for that buffer, just
482 as a local directory would.
483
484    The variable `default-directory-alist' takes an alist of major modes
485 and their opinions on `default-directory' as a Lisp expression to
486 evaluate.  A resulting value of `nil' is ignored in favor of
487 `default-directory'.
488
489    You can create a new directory with the function `make-directory',
490 which takes as an argument a file name string. The current directory is
491 displayed in the minibuffer when the function is called; you can delete
492 the old directory name and supply a new directory name. For example, if
493 the current directory is `/u/rms/gnu', you can delete `gnu' and type
494 `oryx' and <RET> to create `/u/rms/oryx'.  Removing a directory is
495 similar to creating one.  To remove a directory, use
496 `remove-directory'; it takes one argument, a file name string.
497
498    The command `M-x pwd' prints the current buffer's default directory,
499 and the command `M-x cd' sets it (to a value read using the
500 minibuffer).  A buffer's default directory changes only when the `cd'
501 command is used.  A file-visiting buffer's default directory is
502 initialized to the directory of the file that is visited there.  If a
503 buffer is created with `C-x b', its default directory is copied from
504 that of the buffer that was current at the time.
505
506    The default directory name actually appears in the minibuffer when
507 the minibuffer becomes active to read a file name.  This serves two
508 purposes: it shows you what the default is, so that you can type a
509 relative file name and know with certainty what it will mean, and it
510 allows you to edit the default to specify a different directory.  To
511 inhibit the insertion of the default directory, set the variable
512 `insert-default-directory' to `nil'.
513
514    Note that it is legitimate to type an absolute file name after you
515 enter the minibuffer, ignoring the presence of the default directory
516 name.  The final minibuffer contents may look invalid, but that is not
517 so.  *Note Minibuffer File::.
518
519    `$' in a file name is used to substitute environment variables.  For
520 example, if you have used the shell command `setenv FOO rms/hacks' to
521 set up an environment variable named `FOO', then you can use
522 `/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
523 `/u/rms/hacks/test.c'.  The environment variable name consists of all
524 the alphanumeric characters after the `$'; alternatively, it may be
525 enclosed in braces after the `$'.  Note that the `setenv' command
526 affects Emacs only if done before Emacs is started.
527
528    To access a file with `$' in its name, type `$$'.  This pair is
529 converted to a single `$' at the same time variable substitution is
530 performed for single `$'.  The Lisp function that performs the
531 substitution is called `substitute-in-file-name'.  The substitution is
532 performed only on filenames read as such using the minibuffer.
533
534 \1f
535 File: xemacs.info,  Node: Visiting,  Next: Saving,  Prev: File Names,  Up: Files
536
537 14.2 Visiting Files
538 ===================
539
540 `C-x C-f'
541      Visit a file (`find-file').
542
543 `C-x C-v'
544      Visit a different file instead of the one visited last
545      (`find-alternate-file').
546
547 `C-x 4 C-f'
548      Visit a file, in another window (`find-file-other-window').  Don't
549      change this window.
550
551 `C-x 5 C-f'
552      Visit a file, in another frame (`find-file-other-frame').  Don't
553      change this window or frame.
554
555    "Visiting" a file means copying its contents into an Emacs buffer so
556 you can edit it.  Emacs creates a new buffer for each file you visit.
557 We say that the buffer is visiting the file that it was created to
558 hold.  Emacs constructs the buffer name from the file name by throwing
559 away the directory and keeping just the file name.  For example, a file
560 named `/usr/rms/emacs.tex' is displayed in a buffer named `emacs.tex'.
561 If a buffer with that name exists, a unique name is constructed by
562 appending `<2>', `<3>',and so on, using the lowest number that makes a
563 name that is not already in use.
564
565    Each window's mode line shows the name of the buffer that is being
566 displayed in that window, so you can always tell what buffer you are
567 editing.
568
569    The changes you make with Emacs are made in the Emacs buffer.  They
570 do not take effect in the file that you visit, or any other permanent
571 place, until you "save" the buffer.  Saving the buffer means that Emacs
572 writes the current contents of the buffer into its visited file.  *Note
573 Saving::.
574
575    If a buffer contains changes that have not been saved, the buffer is
576 said to be "modified".  This is important because it implies that some
577 changes will be lost if the buffer is not saved.  The mode line displays
578 two stars near the left margin if the buffer is modified.
579
580    To visit a file, use the command `C-x C-f' (`find-file').  Follow
581 the command with the name of the file you wish to visit, terminated by a
582 <RET>.  If you are using XEmacs under X, you can also use the Open...
583 command from the File menu bar item.
584
585    The file name is read using the minibuffer (*note Minibuffer::), with
586 defaulting and completion in the standard manner (*note File Names::).
587 While in the minibuffer, you can abort `C-x C-f' by typing `C-g'.
588
589    `C-x C-f' has completed successfully when text appears on the screen
590 and a new buffer name appears in the mode line.  If the specified file
591 does not exist and could not be created or cannot be read, an error
592 results.  The error message is printed in the echo area, and includes
593 the name of the file that Emacs was trying to visit.
594
595    If you visit a file that is already in Emacs, `C-x C-f' does not make
596 another copy.  It selects the existing buffer containing that file.
597 However, before doing so, it checks that the file itself has not changed
598 since you visited or saved it last.  If the file has changed, Emacs
599 prints a warning message.  *Note Simultaneous Editing: Interlocking.
600
601    You can switch to a specific file called out in the current buffer by
602 calling the function `find-this-file'. By providing a prefix argument,
603 this function calls `filename-at-point' and switches to a buffer
604 visiting the file FILENAME. It creates one if none already exists. You
605 can use this function to edit the file mentioned in the buffer you are
606 working in or to test if the file exists. You can do that by using the
607 minibuffer completion after snatching the all or part of the filename.
608
609    If the variable `find-file-use-truenames''s value is non-`nil', a
610 buffer's visited filename will always be traced back to the real file.
611 The filename will never be a symbolic link, and there will never be a
612 symbolic link anywhere in its directory path. In other words, the
613 `buffer-file-name' and `buffer-file-truename' will be equal.
614
615    If the variable `find-file-compare-truenames' value is non-`nil',
616 the `find-file' command will check the `buffer-file-truename' of all
617 visited files when deciding whether a given file is already in a
618 buffer, instead of just `buffer-file-name'.  If you attempt to visit
619 another file which is a symbolic link to a file that is already in a
620 buffer, the existing buffer will be found instead of a newly created
621 one.  This works if any component of the pathname (including a
622 non-terminal component) is a symbolic link as well, but doesn't work
623 with hard links (nothing does).
624
625    If you want to create a file, just visit it.  Emacs prints `(New
626 File)' in the echo area, but in other respects behaves as if you had
627 visited an existing empty file.  If you make any changes and save them,
628 the file is created.
629
630    If you visit a nonexistent file unintentionally (because you typed
631 the wrong file name), use the `C-x C-v' (`find-alternate-file') command
632 to visit the file you wanted.  `C-x C-v' is similar to `C-x C-f', but
633 it kills the current buffer (after first offering to save it if it is
634 modified).  `C-x C-v' is allowed even if the current buffer is not
635 visiting a file.
636
637    If the file you specify is actually a directory, Dired is called on
638 that directory (*note Dired::).  To inhibit this, set the variable
639 `find-file-run-dired' to `nil'; then it is an error to try to visit a
640 directory.
641
642    `C-x 4 f' (`find-file-other-window') is like `C-x C-f' except that
643 the buffer containing the specified file is selected in another window.
644 The window that was selected before `C-x 4 f' continues to show the
645 same buffer it was already showing.  If you use this command when only
646 one window is being displayed, that window is split in two, with one
647 window showing the same buffer as before, and the other one showing the
648 newly requested file.  *Note Windows::.
649
650    `C-x 5 C-f' (`find-file-other-frame') is like `C-x C-f' except that
651 it creates a new frame in which the file is displayed.
652
653    Use the function `find-this-file-other-window' to edit a file
654 mentioned in the buffer you are editing or to test if that file exists.
655 To do this, use the minibuffer completion after snatching the part or
656 all of the filename. By providing a prefix argument, the function calls
657 `filename-at-point' and switches you to a buffer visiting the file
658 FILENAME in another window. The function creates a buffer if none
659 already exists. This function is similar to `find-file-other-window'.
660
661    There are two hook variables that allow extensions to modify the
662 operation of visiting files.  Visiting a file that does not exist runs
663 the functions in the list `find-file-not-found-hooks'; the value of this
664 variable is expected to be a list of functions which are called one by
665 one until one of them returns non-`nil'.  Any visiting of a file,
666 whether extant or not, expects `find-file-hooks' to contain list of
667 functions and calls them all, one by one.  In both cases the functions
668 receive no arguments.  Visiting a nonexistent file runs the
669 `find-file-not-found-hooks' first.
670
671 \1f
672 File: xemacs.info,  Node: Saving,  Next: Reverting,  Prev: Visiting,  Up: Files
673
674 14.3 Saving Files
675 =================
676
677 "Saving" a buffer in Emacs means writing its contents back into the file
678 that was visited in the buffer.
679
680 `C-x C-s'
681      Save the current buffer in its visited file (`save-buffer').
682
683 `C-x s'
684      Save any or all buffers in their visited files
685      (`save-some-buffers').
686
687 `M-~'
688      Forget that the current buffer has been changed (`not-modified').
689
690 `C-x C-w'
691      Save the current buffer in a specified file, and record that file
692      as the one visited in the buffer (`write-file').
693
694 `M-x set-visited-file-name'
695      Change file the name under which the current buffer will be saved.
696
697    To save a file and make your changes permanent, type `C-x C-s'
698 (`save-buffer').  After saving is finished, `C-x C-s' prints a message
699 such as:
700
701      Wrote /u/rms/gnu/gnu.tasks
702
703 If the selected buffer is not modified (no changes have been made in it
704 since the buffer was created or last saved), Emacs does not save it
705 because it would have no effect.  Instead, `C-x C-s' prints a message
706 in the echo area saying:
707
708      (No changes need to be saved)
709
710    The command `C-x s' (`save-some-buffers') can save any or all
711 modified buffers.  First it asks, for each modified buffer, whether to
712 save it.  The questions should be answered with `y' or `n'.  `C-x C-c',
713 the key that kills Emacs, invokes `save-some-buffers' and therefore
714 asks the same questions.
715
716    If you have changed a buffer and do not want the changes to be saved,
717 you should take some action to prevent it.  Otherwise, you are liable to
718 save it by mistake each time you use `save-some-buffers' or a related
719 command.  One thing you can do is type `M-~' (`not-modified'), which
720 removes the indication that the buffer is modified.  If you do this,
721 none of the save commands will believe that the buffer needs to be
722 saved.  (`~' is often used as a mathematical symbol for `not'; thus
723 `Meta-~' is `not', metafied.)  You could also use
724 `set-visited-file-name' (see below) to mark the buffer as visiting a
725 different file name, not in use for anything important.
726
727    You can also undo all the changes made since the file was visited or
728 saved, by reading the text from the file again.  This is called
729 "reverting".  *Note Reverting::.  Alternatively, you can undo all the
730 changes by repeating the undo command `C-x u'; but this only works if
731 you have not made more changes than the undo mechanism can remember.
732
733    `M-x set-visited-file-name' alters the name of the file that the
734 current buffer is visiting.  It prompts you for the new file name in the
735 minibuffer.  You can also use `set-visited-file-name' on a buffer that
736 is not visiting a file.  The buffer's name is changed to correspond to
737 the file it is now visiting unless the new name is already used by a
738 different buffer; in that case, the buffer name is not changed.
739 `set-visited-file-name' does not save the buffer in the newly visited
740 file; it just alters the records inside Emacs so that it will save the
741 buffer in that file.  It also marks the buffer as "modified" so that
742 `C-x C-s' will save.
743
744    If you wish to mark a buffer as visiting a different file and save it
745 right away, use `C-x C-w' (`write-file').  It is precisely equivalent
746 to `set-visited-file-name' followed by `C-x C-s'.  `C-x C-s' used on a
747 buffer that is not visiting  a file has the same effect as `C-x C-w';
748 that is, it reads a file name, marks the buffer as visiting that file,
749 and saves it there.  The default file name in a buffer that is not
750 visiting a file is made by combining the buffer name with the buffer's
751 default directory.
752
753    If Emacs is about to save a file and sees that the date of the latest
754 version on disk does not match what Emacs last read or wrote, Emacs
755 notifies you of this fact, because it probably indicates a problem
756 caused by simultaneous editing and requires your immediate attention.
757 *Note Simultaneous Editing: Interlocking.
758
759    If the variable `require-final-newline' is non-`nil', Emacs puts a
760 newline at the end of any file that doesn't already end in one, every
761 time a file is saved or written.
762
763    Use the hook variable `write-file-hooks' to implement other ways to
764 write files, and specify things to be done before files are written.
765 The value of this variable should be a list of Lisp functions.  When a
766 file is to be written, the functions in the list are called, one by
767 one, with no arguments.  If one of them returns a non-`nil' value, Emacs
768 takes this to mean that the file has been written in some suitable
769 fashion; the rest of the functions are not called, and normal writing is
770 not done. Use the hook variable `after-save-hook' to list all the
771 functions to be called after writing out a buffer to a file.
772
773 * Menu:
774
775 * Backup::       How Emacs saves the old version of your file.
776 * Interlocking:: How Emacs protects against simultaneous editing
777                   of one file by two users.
778
779 \1f
780 File: xemacs.info,  Node: Backup,  Next: Interlocking,  Prev: Saving,  Up: Saving
781
782 14.3.1 Backup Files
783 -------------------
784
785 Because Unix does not provide version numbers in file names, rewriting a
786 file in Unix automatically destroys all record of what the file used to
787 contain.  Thus, saving a file from Emacs throws away the old contents of
788 the file--or it would, except that Emacs carefully copies the old
789 contents to another file, called the "backup" file, before actually
790 saving.  (Make sure that the variable `make-backup-files' is non-`nil'.
791 Backup files are not written if this variable is `nil').
792
793    At your option, Emacs can keep either a single backup file or a
794 series of numbered backup files for each file you edit.
795
796    Emacs makes a backup for a file only the first time a file is saved
797 from one buffer.  No matter how many times you save a file, its backup
798 file continues to contain the contents from before the file was visited.
799 Normally this means that the backup file contains the contents from
800 before the current editing session; however, if you kill the buffer and
801 then visit the file again, a new backup file is made by the next save.
802
803 * Menu:
804
805 * Names: Backup Names.          How backup files are named;
806                                 Choosing single or numbered backup files.
807 * Deletion: Backup Deletion.    Emacs deletes excess numbered backups.
808 * Copying: Backup Copying.      Backups can be made by copying or renaming.
809
810 \1f
811 File: xemacs.info,  Node: Backup Names,  Next: Backup Deletion,  Prev: Backup,  Up: Backup
812
813 14.3.1.1 Single or Numbered Backups
814 ...................................
815
816 If you choose to have a single backup file (the default), the backup
817 file's name is constructed by appending `~' to the file name being
818 edited; thus, the backup file for `eval.c' is `eval.c~'.
819
820    If you choose to have a series of numbered backup files, backup file
821 names are made by appending `.~', the number, and another `~' to the
822 original file name.  Thus, the backup files of `eval.c' would be called
823 `eval.c.~1~', `eval.c.~2~', and so on, through names like
824 `eval.c.~259~' and beyond.
825
826    If protection stops you from writing backup files under the usual
827 names, the backup file is written as `%backup%~' in your home directory.
828 Only one such file can exist, so only the most recently made backup is
829 available.
830
831    The choice of single backup or numbered backups is controlled by the
832 variable `version-control'.  Its possible values are:
833
834 `t'
835      Make numbered backups.
836
837 `nil'
838      Make numbered backups for files that have numbered backups already.
839      Otherwise, make single backups.
840
841 `never'
842      Never make numbered backups; always make single backups.
843
844 `version-control' may be set locally in an individual buffer to control
845 the making of backups for that buffer's file.  For example, Rmail mode
846 locally sets `version-control' to `never' to make sure that there is
847 only one backup for an Rmail file.  *Note Locals::.
848
849 \1f
850 File: xemacs.info,  Node: Backup Deletion,  Next: Backup Copying,  Prev: Backup Names,  Up: Backup
851
852 14.3.1.2 Automatic Deletion of Backups
853 ......................................
854
855 To prevent unlimited consumption of disk space, Emacs can delete
856 numbered backup versions automatically.  Generally Emacs keeps the
857 first few backups and the latest few backups, deleting any in between.
858 This happens every time a new backup is made.  The two variables that
859 control the deletion are `kept-old-versions' and `kept-new-versions'.
860 Their values are, respectively the number of oldest (lowest-numbered)
861 backups to keep and the number of newest (highest-numbered) ones to
862 keep, each time a new backup is made.  The values are used just after a
863 new backup version is made; that newly made backup is included in the
864 count in `kept-new-versions'.  By default, both variables are 2.
865
866    If `delete-old-versions' is non-`nil',  excess middle versions are
867 deleted without notification.  If it is `nil', the default, you are
868 asked whether the excess middle versions should really be deleted.
869
870    You can also use Dired's `.' (Period) command to delete old versions.
871 *Note Dired::.
872
873 \1f
874 File: xemacs.info,  Node: Backup Copying,  Prev: Backup Deletion,  Up: Backup
875
876 14.3.1.3 Copying vs. Renaming
877 .............................
878
879 You can make backup files by copying the old file or by renaming it.
880 This makes a difference when the old file has multiple names.  If you
881 rename the old file into the backup file, the alternate names become
882 names for the backup file.  If you copy the old file instead, the
883 alternate names remain names for the file that you are editing, and the
884 contents accessed by those names will be the new contents.
885
886    How you make a backup file may also affect the file's owner and
887 group.  If you use copying, they do not change.  If renaming is used,
888 you become the file's owner, and the file's group becomes the default
889 (different operating systems have different defaults for the group).
890
891    Having the owner change is usually a good idea, because then the
892 owner is always the person who last edited the file.  Occasionally
893 there is a file whose owner should not change.  Since most files should
894 change owners, it is a good idea to use local variable lists to set
895 `backup-by-copying-when-mismatch' for the special cases where the owner
896 should not change (*note File Variables::).
897
898    Three variables control the choice of renaming or copying.
899 Normally, renaming is done.  If the variable `backup-by-copying' is
900 non-`nil', copying is used.  Otherwise, if the variable
901 `backup-by-copying-when-linked' is non-`nil', copying is done for files
902 that have multiple names, but renaming may still be done when the file
903 being edited has only one name.  If the variable
904 `backup-by-copying-when-mismatch' is non-`nil', copying is done if
905 renaming would cause the file's owner or group to change.
906
907 \1f
908 File: xemacs.info,  Node: Interlocking,  Prev: Backup,  Up: Saving
909
910 14.3.2 Protection Against Simultaneous Editing
911 ----------------------------------------------
912
913 Simultaneous editing occurs when two users visit the same file, both
914 make changes, and both save their changes.  If no one was informed that
915 this was happening, and you saved first, you would later find that your
916 changes were lost.  On some systems, Emacs notices immediately when the
917 second user starts to change a file already being edited, and issues a
918 warning.  When this is not possible, or if the second user has started
919 to change the file despite the warning, Emacs checks when the file is
920 saved, and issues a second warning when a user is about to overwrite a
921 file containing another user's changes.  If you are the user editing the
922 file, you can take corrective action at this point and prevent actual
923 loss of work.
924
925    When you make the first modification in an Emacs buffer that is
926 visiting a file, Emacs records that you have locked the file.  (It does
927 this by writing another file in a directory reserved for this purpose.)
928 The lock is removed when you save the changes.  The idea is that the
929 file is locked whenever the buffer is modified.  If you begin to modify
930 the buffer while the visited file is locked by someone else, this
931 constitutes a collision, and Emacs asks you what to do.  It does this
932 by calling the Lisp function `ask-user-about-lock', which you can
933 redefine to customize what it does.  The standard definition of this
934 function asks you a question and accepts three possible answers:
935
936 `s'
937      Steal the lock.  Whoever was already changing the file loses the
938      lock, and you get the lock.
939
940 `p'
941      Proceed.  Go ahead and edit the file despite its being locked by
942      someone else.
943
944 `q'
945      Quit.  This causes an error (`file-locked') and the modification
946      you were trying to make in the buffer does not actually take place.
947
948    Note that locking works on the basis of a file name; if a file has
949 multiple names, Emacs does not realize that the two names are the same
950 file and cannot prevent two users from editing it simultaneously under
951 different names.  However, basing locking on names means that Emacs can
952 interlock the editing of new files that do not really exist until they
953 are saved.
954
955    Some systems are not configured to allow Emacs to make locks.  On
956 these systems, Emacs cannot detect trouble in advance, but it can still
957 detect it in time to prevent you from overwriting someone else's
958 changes.
959
960    Every time Emacs saves a buffer, it first checks the
961 last-modification date of the existing file on disk to see that it has
962 not changed since the file was last visited or saved.  If the date does
963 not match, it implies that changes were made in the file in some other
964 way, and these changes are about to be lost if Emacs actually does
965 save.  To prevent this, Emacs prints a warning message and asks for
966 confirmation before saving.  Occasionally you will know why the file
967 was changed and know that it does not matter; then you can answer `yes'
968 and proceed.  Otherwise, you should cancel the save with `C-g' and
969 investigate the situation.
970
971    The first thing you should do when notified that simultaneous editing
972 has already taken place is to list the directory with `C-u C-x C-d'
973 (*note Directory Listing: ListDir.).  This will show the file's current
974 author.  You should attempt to contact that person and ask him not to
975 continue editing.  Often the next step is to save the contents of your
976 Emacs buffer under a different name, and use `diff' to compare the two
977 files.
978
979    Simultaneous editing checks are also made when you visit a file that
980 is already visited with `C-x C-f' and when you start to modify a file.
981 This is not strictly necessary, but it is useful to find out about such
982 a problem as early as possible, when corrective action takes less work.
983
984    Another way to protect your file is to set the read, write, and
985 executable permissions for the file. Use the function
986 `set-default-file-modes' to set the UNIX `umask' value to the NMASK
987 argument. The `umask' value is the default protection mode for new
988 files.
989
990 \1f
991 File: xemacs.info,  Node: Reverting,  Next: Auto Save,  Prev: Saving,  Up: Files
992
993 14.4 Reverting a Buffer
994 =======================
995
996 If you have made extensive changes to a file and then change your mind
997 about them, you can get rid of all changes by reading in the previous
998 version of the file.  To do this, use `M-x revert-buffer', which
999 operates on the current buffer.  Since reverting a buffer can result in
1000 very extensive changes, you must confirm it with `yes'.
1001
1002    You may request that `revert-buffer' check for an auto-save file
1003 that is more recent than the visited file by providing a prefix
1004 argument.  If a recent auto-save file exists, `revert-buffer' offers to
1005 read the auto-save file instead of the visited file (*note Auto
1006 Save::).  Emacs asks you about the auto-save file before the request
1007 for confirmation of the `revert-buffer' operation, and demands `y' or
1008 `n' as an answer.  If you have started to type `yes' to confirm the
1009 revert operation, the `y' will answer the question about using the
1010 auto-save file, but the `es' will not be valid confirmation for the
1011 reversion.  This gives you a chance to cancel the operation with `C-g'
1012 and try again with the answers you really intend.
1013
1014    `revert-buffer' preserves the value of point (in characters from the
1015 beginning of the file).  If the file was edited only slightly, you will
1016 be at approximately the same piece of text after reverting as before.
1017 If you have made more extensive changes, after reversion point may be
1018 in a totally different context than your last edits before reversion.
1019
1020    A buffer reverted from its visited file is marked "not modified"
1021 until you make a change.  The buffer's modes will also be recalculated,
1022 by `normal-mode'.
1023
1024    Some kinds of buffers whose contents reflect data bases other than
1025 files, such as Dired buffers, can also be reverted.  For them,
1026 reverting means refreshing their contents from the appropriate data.
1027 Buffers created randomly with `C-x b' cannot be reverted;
1028 `revert-buffer' reports an error when asked to do so.
1029
1030 \1f
1031 File: xemacs.info,  Node: Auto Save,  Next: Version Control,  Prev: Reverting,  Up: Files
1032
1033 14.5 Auto-Saving: Protection Against Disasters
1034 ==============================================
1035
1036 Emacs saves all the visited files from time to time (based on counting
1037 your keystrokes) without being asked.  This is called "auto-saving".
1038 It prevents you from losing more than a limited amount of work if the
1039 system crashes.
1040
1041    When Emacs determines it is time for auto-saving, each buffer is
1042 considered and is auto-saved if auto-saving is turned on for it and it
1043 has changed since the last time it was auto-saved.  If any auto-saving
1044 is done, the message `Auto-saving...' is displayed in the echo area
1045 until auto-saving is finished.  Errors occurring during auto-saving are
1046 caught so that they do not interfere with the execution of commands you
1047 have been typing.
1048
1049 * Menu:
1050
1051 * Files: Auto Save Files.
1052 * Control: Auto Save Control.
1053 * Recover::             Recovering text from auto-save files.
1054
1055 \1f
1056 File: xemacs.info,  Node: Auto Save Files,  Next: Auto Save Control,  Prev: Auto Save,  Up: Auto Save
1057
1058 14.5.1 Auto-Save Files
1059 ----------------------
1060
1061 Auto-saving does not normally write to the files you visited, because
1062 it can be undesirable to save a program that is in an inconsistent
1063 state when you have made only half of a planned change.  Instead,
1064 auto-saving is done in a different file called the "auto-save file",
1065 and the visited file is changed only when you save explicitly, for
1066 example, with `C-x C-s'.
1067
1068    Normally, the name of the auto-save file is generated by appending
1069 `#' to the front and back of the visited file name.  Thus, a buffer
1070 visiting file `foo.c' would be auto-saved in a file `#foo.c#'.  Most
1071 buffers that are not visiting files are auto-saved only if you request
1072 it explicitly; when they are auto-saved, the auto-save file name is
1073 generated by appending `#%' to the front and `#' to the back of buffer
1074 name.  For example, the `*mail*' buffer in which you compose messages
1075 to be sent is auto-saved in a file named `#%*mail*#'.  Names of
1076 auto-save files are generated this way unless you customize the
1077 functions `make-auto-save-file-name' and `auto-save-file-name-p' to do
1078 something different.  The file name to be used for auto-saving a buffer
1079 is calculated at the time auto-saving is turned on in that buffer.
1080
1081    If you want auto-saving to be done in the visited file, set the
1082 variable `auto-save-visited-file-name' to be non-`nil'.  In this mode,
1083 there is really no difference between auto-saving and explicit saving.
1084
1085    Emacs deletes a buffer's auto-save file when you explicitly save the
1086 buffer.  To inhibit the deletion, set the variable
1087 `delete-auto-save-files' to `nil'.  Changing the visited file name with
1088 `C-x C-w' or `set-visited-file-name' renames any auto-save file to
1089 correspond to the new visited name.
1090
1091 \1f
1092 File: xemacs.info,  Node: Auto Save Control,  Next: Recover,  Prev: Auto Save Files,  Up: Auto Save
1093
1094 14.5.2 Controlling Auto-Saving
1095 ------------------------------
1096
1097 Each time you visit a file, auto-saving is turned on for that file's
1098 buffer if the variable `auto-save-default' is non-`nil' (but not in
1099 batch mode; *note Entering Emacs::).  The default for this variable is
1100 `t', so Emacs auto-saves buffers that visit files by default.  You can
1101 use the command `M-x auto-save-mode' to turn auto-saving for a buffer
1102 on or off.  Like other minor mode commands, `M-x auto-save-mode' turns
1103 auto-saving on with a positive argument, off with a zero or negative
1104 argument; with no argument, it toggles.
1105
1106    Emacs performs auto-saving periodically based on counting how many
1107 characters you have typed since the last time auto-saving happened.  The
1108 variable `auto-save-interval' specifies the number of characters
1109 between auto-saves.  By default, it is 300.  Emacs also auto-saves
1110 whenever you call the function `do-auto-save'.
1111
1112    Emacs also does auto-saving whenever it gets a fatal error.  This
1113 includes killing the Emacs job with a shell command such as `kill
1114 -emacs', or disconnecting a phone line or network connection.
1115
1116    You can set the number of seconds of idle time before an auto-save is
1117 done. Setting the value of the variable `auto-save-timeout' to zero or
1118 `nil' will  disable auto-saving due to idleness.
1119
1120    The actual amount of idle time between auto-saves is logarithmically
1121 related to the size of the current buffer.  This variable is the number
1122 of seconds after which an auto-save will happen when the current buffer
1123 is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3
1124 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k
1125 buffer.
1126
1127    For this variable to have any effect, you must do `(require 'timer)'.
1128
1129 \1f
1130 File: xemacs.info,  Node: Recover,  Prev: Auto Save Control,  Up: Auto Save
1131
1132 14.5.3 Recovering Data from Auto-Saves
1133 --------------------------------------
1134
1135 If you want to use the contents of an auto-save file to recover from a
1136 loss of data, use the command `M-x recover-file <RET> FILE <RET>'.
1137 Emacs visits FILE and then (after your confirmation) restores the
1138 contents from the auto-save file `#FILE#'.  You can then save the file
1139 with `C-x C-s' to put the recovered text into FILE itself.  For
1140 example, to recover file `foo.c' from its auto-save file `#foo.c#', do:
1141
1142      M-x recover-file <RET> foo.c <RET>
1143      C-x C-s
1144
1145    Before asking for confirmation, `M-x recover-file' displays a
1146 directory listing describing the specified file and the auto-save file,
1147 so you can compare their sizes and dates.  If the auto-save file is
1148 older, `M-x recover-file' does not offer to read it.
1149
1150    Auto-saving is disabled by `M-x recover-file' because using this
1151 command implies that the auto-save file contains valuable data from a
1152 past session.  If you save the data in the visited file and then go on
1153 to make new changes, turn auto-saving back on with `M-x auto-save-mode'.
1154
1155 \1f
1156 File: xemacs.info,  Node: Version Control,  Next: ListDir,  Prev: Auto Save,  Up: Files
1157
1158 14.6 Version Control
1159 ====================
1160
1161 "Version control systems" are packages that can record multiple
1162 versions of a source file, usually storing the unchanged parts of the
1163 file just once.  Version control systems also record history information
1164 such as the creation time of each version, who created it, and a
1165 description of what was changed in that version.
1166
1167    The GNU project recommends the version control system known as RCS,
1168 which is free software and available from the Free Software Foundation.
1169 Emacs supports use of either RCS or SCCS (a proprietary, but widely
1170 used, version control system that is not quite as powerful as RCS)
1171 through a facility called VC.  The same Emacs commands work with either
1172 RCS or SCCS, so you hardly have to know which one of them you are using.
1173
1174 * Menu:
1175
1176 * Concepts of VC::              Basic version control information;
1177                                   checking files in and out.
1178 * Editing with VC::             Commands for editing a file maintained
1179                                   with version control.
1180 * Variables for Check-in/out::  Variables that affect the commands used
1181                                   to check files in or out.
1182 * Log Entries::                 Logging your changes.
1183 * Change Logs and VC::          Generating a change log file from log
1184                                   entries.
1185 * Old Versions::                Examining and comparing old versions.
1186 * VC Status::                   Commands to view the VC status of files and
1187                                   look at log entries.
1188 * Renaming and VC::             A command to rename both the source and
1189                                   master file correctly.
1190 * Snapshots::                   How to make and use snapshots, a set of
1191                                   file versions that can be treated as a unit.
1192 * Version Headers::             Inserting version control headers into
1193                                   working files.
1194
1195 \1f
1196 File: xemacs.info,  Node: Concepts of VC,  Next: Editing with VC,  Prev: Version Control,  Up: Version Control
1197
1198 14.6.1 Concepts of Version Control
1199 ----------------------------------
1200
1201 When a file is under version control, we also say that it is
1202 "registered" in the version control system.  Each registered file has a
1203 corresponding "master file" which represents the file's present state
1204 plus its change history, so that you can reconstruct from it either the
1205 current version or any specified earlier version.  Usually the master
1206 file also records a "log entry" for each version describing what was
1207 changed in that version.
1208
1209    The file that is maintained under version control is sometimes called
1210 the "work file" corresponding to its master file.
1211
1212    To examine a file, you "check it out".  This extracts a version of
1213 the source file (typically, the most recent) from the master file.  If
1214 you want to edit the file, you must check it out "locked".  Only one
1215 user can do this at a time for any given source file.  (This kind of
1216 locking is completely unrelated to the locking that Emacs uses to
1217 detect simultaneous editing of a file.)
1218
1219    When you are done with your editing, you must "check in" the new
1220 version.  This records the new version in the master file, and unlocks
1221 the source file so that other people can lock it and thus modify it.
1222
1223    Checkin and checkout are the basic operations of version control.
1224 You can do both of them with a single Emacs command: `C-x C-q'
1225 (`vc-toggle-read-only').
1226
1227    A "snapshot" is a coherent collection of versions of the various
1228 files that make up a program.  *Note Snapshots::.
1229
1230 \1f
1231 File: xemacs.info,  Node: Editing with VC,  Next: Variables for Check-in/out,  Prev: Concepts of VC,  Up: Version Control
1232
1233 14.6.2 Editing with Version Control
1234 -----------------------------------
1235
1236 When you visit a file that is maintained using version control, the
1237 mode line displays `RCS' or `SCCS' to inform you that version control
1238 is in use, and also (in case you care) which low-level system the file
1239 is actually stored in.  Normally, such a source file is read-only, and
1240 the mode line indicates this with `%%'.  With RCS, the mode line also
1241 indicates the number of the head version, which is normally also the
1242 version you are looking at.
1243
1244    These are the commands for editing a file maintained with version
1245 control:
1246
1247 `C-x C-q'
1248      Check the visited file in or out.
1249
1250 `C-x v u'
1251      Revert the buffer and the file to the last checked in version.
1252
1253 `C-x v c'
1254      Remove the last-entered change from the master for the visited
1255      file.  This undoes your last check-in.
1256
1257 `C-x v i'
1258      Register the visited file in version control.
1259
1260 (`C-x v' is the prefix key for version control commands; all of these
1261 commands except for `C-x C-q' start with `C-x v'.)
1262
1263    When you want to modify a file maintained with version control, type
1264 `C-x C-q' (`vc-toggle-read-only').  This "checks out" the file, and
1265 tells RCS or SCCS to lock the file.  This means making the file
1266 writable for you (but not for anyone else).
1267
1268    When you are finished editing the file, type `C-x C-q' again.  When
1269 used on a file that is checked out, this command checks the file in.
1270 But check-in does not start immediately; first, you must enter the "log
1271 entry"--a description of the changes in the new version.  `C-x C-q'
1272 pops up a buffer for you to enter this in.  When you are finished
1273 typing in the log entry, type `C-c C-c' to terminate it; this is when
1274 actual check-in takes place.
1275
1276    Once you have checked in your changes, the file is unlocked, so that
1277 other users can lock it and modify it.
1278
1279    Emacs does not save backup files for source files that are maintained
1280 with version control.  If you want to make backup files despite version
1281 control, set the variable `vc-make-backup-files' to a non-`nil' value.
1282
1283    Normally the work file exists all the time, whether it is locked or
1284 not.  If you set `vc-keep-workfiles' to `nil', then checking in a new
1285 version with `C-x C-q' deletes the work file; but any attempt to visit
1286 the file with Emacs creates it again.
1287
1288    It is not impossible to lock a file that someone else has locked.  If
1289 you try to check out a file that is locked, `C-x C-q' asks you whether
1290 you want to "steal the lock."  If you say yes, the file becomes locked
1291 by you, but a message is sent to the person who had formerly locked the
1292 file, to inform him of what has happened.  The mode line indicates that
1293 a file is locked by someone else by displaying the login name of that
1294 person, before the version number.
1295
1296    If you want to discard your current set of changes and revert to the
1297 last version checked in, use `C-x v u' (`vc-revert-buffer').  This
1298 cancels your last check-out, leaving the file unlocked.  If you want to
1299 make a different set of changes, you must first check the file out
1300 again.  `C-x v u' requires confirmation, unless it sees that you
1301 haven't made any changes since the last checked-in version.
1302
1303    `C-x v u' is also the command to use if you lock a file and then
1304 don't actually change it.
1305
1306    You can cancel a change after checking it in, with `C-x v c'
1307 (`vc-cancel-version').  This command discards all record of the most
1308 recent checked in version, so be careful about using it.  It requires
1309 confirmation with `yes'.  By default, `C-x v c' reverts your workfile
1310 and buffer to the previous version (the one that precedes the version
1311 that is deleted), but you can prevent the reversion by giving the
1312 command a prefix argument.  Then the buffer does not change.
1313
1314    This command with a prefix argument is useful when you have checked
1315 in a change and then discover a trivial error in it; you can cancel the
1316 erroneous check-in, fix the error, and repeat the check-in.
1317
1318    Be careful when invoking `C-x v c', as it is easy to throw away a
1319 lot of work with it.  To help you be careful, this command always
1320 requires confirmation with `yes'.
1321
1322    You can register the visited file for version control using
1323 `C-x v i' (`vc-register').  If the variable `vc-default-back-end' is
1324 non-`nil', it specifies which version control system to use; otherwise,
1325 this uses RCS if it is installed on your system and SCCS if not.  After
1326 `C-x v i', the file is unlocked and read-only.  Type `C-x C-q' if you
1327 wish to edit it.
1328
1329    By default, the initial version number is 1.1.  If you want to use a
1330 different number, give `C-x v i' a prefix argument; then it reads the
1331 initial version number using the minibuffer.
1332
1333    If `vc-initial-comment' is non-`nil', `C-x v i' reads an initial
1334 comment (much like a log entry) to describe the purpose of this source
1335 file.
1336
1337    To specify the version number for a subsequent checkin, use the
1338 command `C-u C-x v v'.  `C-x v v' (`vc-next-action') is the command
1339 that `C-x C-q' uses to do the "real work" when the visited file uses
1340 version control.  When used for checkin, and given a prefix argument,
1341 it reads the version number with the minibuffer.
1342
1343 \1f
1344 File: xemacs.info,  Node: Variables for Check-in/out,  Next: Log Entries,  Prev: Editing with VC,  Up: Version Control
1345
1346 14.6.3 Variables Affecting Check-in and Check-out
1347 -------------------------------------------------
1348
1349 If `vc-suppress-confirm' is non-`nil', then `C-x C-q' and `C-x v i' can
1350 save the current buffer without asking, and `C-x v u' also operates
1351 without asking for confirmation.  (This variable does not affect `C-x v
1352 c'; that is so drastic that it should always ask for confirmation.)
1353
1354    VC mode does much of its work by running the shell commands for RCS
1355 and SCCS.  If `vc-command-messages' is non-`nil', VC displays messages
1356 to indicate which shell commands it runs, and additional messages when
1357 the commands finish.
1358
1359    Normally, VC assumes that it can deduce the locked/unlocked state of
1360 files by looking at the file permissions of the work file; this is
1361 fast.  However, if the `RCS' or `SCCS' subdirectory is actually a
1362 symbolic link, then VC does not trust the file permissions to reflect
1363 this status.
1364
1365    You can specify the criterion for whether to trust the file
1366 permissions by setting the variable `vc-mistrust-permissions'.  Its
1367 value may be `t' (always mistrust the file permissions and check the
1368 master file), `nil' (always trust the file permissions), or a function
1369 of one argument which makes the decision.  The argument is the directory
1370 name of the `RCS' or `SCCS' subdirectory.  A non-`nil' value from the
1371 function says to mistrust the file permissions.
1372
1373    If you find that the file permissions of work files are changed
1374 erroneously, set `vc-mistrust-permissions' to `t'.  Then VC always
1375 checks the master file to determine the file's status.
1376
1377    You can specify additional directories to search for version control
1378 programs by setting the variable `vc-path'.  These directories are
1379 searched before the usual search path.  The proper result usually
1380 happens automatically.
1381
1382 \1f
1383 File: xemacs.info,  Node: Log Entries,  Next: Change Logs and VC,  Prev: Variables for Check-in/out,  Up: Version Control
1384
1385 14.6.4 Log Entries
1386 ------------------
1387
1388 When you're editing an initial comment or log entry for inclusion in a
1389 master file, finish your entry by typing `C-c C-c'.
1390
1391 `C-c C-c'
1392      Finish the comment edit normally (`vc-finish-logentry').  This
1393      finishes check-in.
1394
1395    To abort check-in, just don't type `C-c C-c' in that buffer.  You
1396 can switch buffers and do other editing.  As long as you don't try to
1397 check in another file, the entry you were editing remains in its
1398 buffer, and you can go back to that buffer at any time to complete the
1399 check-in.
1400
1401    If you change several source files for the same reason, it is often
1402 convenient to specify the same log entry for many of the files.  To do
1403 this, use the history of previous log entries.  The commands `M-n',
1404 `M-p', `M-s' and `M-r' for doing this work just like the minibuffer
1405 history commands (except that these versions are used outside the
1406 minibuffer).
1407
1408    Each time you check in a file, the log entry buffer is put into VC
1409 Log mode, which involves running two hooks: `text-mode-hook' and
1410 `vc-log-mode-hook'.
1411
1412 \1f
1413 File: xemacs.info,  Node: Change Logs and VC,  Next: Old Versions,  Prev: Log Entries,  Up: Version Control
1414
1415 14.6.5 Change Logs and VC
1416 -------------------------
1417
1418 If you use RCS for a program and also maintain a change log file for it
1419 (*note Change Log::), you can generate change log entries automatically
1420 from the version control log entries:
1421
1422 `C-x v a'
1423      Visit the current directory's change log file and create new
1424      entries for versions checked in since the most recent entry in the
1425      change log file (`vc-update-change-log').
1426
1427      This command works with RCS only; it does not work with SCCS.
1428
1429    For example, suppose the first line of `ChangeLog' is dated 10 April
1430 1992, and that the only check-in since then was by Nathaniel Bowditch
1431 to `rcs2log' on 8 May 1992 with log text `Ignore log messages that
1432 start with `#'.'.  Then `C-x v a' visits `ChangeLog' and inserts text
1433 like this:
1434
1435      Fri May  8 21:45:00 1992  Nathaniel Bowditch  (nat@apn.org)
1436
1437              * rcs2log: Ignore log messages that start with `#'.
1438
1439 You can then edit the new change log entry further as you wish.
1440
1441    Normally, the log entry for file `foo' is displayed as `* foo: TEXT
1442 OF LOG ENTRY'.  The `:' after `foo' is omitted if the text of the log
1443 entry starts with `(FUNCTIONNAME): '.  For example, if the log entry
1444 for `vc.el' is `(vc-do-command): Check call-process status.', then the
1445 text in `ChangeLog' looks like this:
1446
1447      Wed May  6 10:53:00 1992  Nathaniel Bowditch  (nat@apn.org)
1448
1449              * vc.el (vc-do-command): Check call-process status.
1450
1451    When `C-x v a' adds several change log entries at once, it groups
1452 related log entries together if they all are checked in by the same
1453 author at nearly the same time.  If the log entries for several such
1454 files all have the same text, it coalesces them into a single entry.
1455 For example, suppose the most recent checkins have the following log
1456 entries:
1457
1458 For `vc.texinfo':
1459      Fix expansion typos.
1460 For `vc.el':
1461      Don't call expand-file-name.
1462 For `vc-hooks.el':
1463      Don't call expand-file-name.
1464
1465    They appear like this in `ChangeLog':
1466
1467      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  (nat@apn.org)
1468
1469              * vc.texinfo: Fix expansion typos.
1470
1471              * vc.el, vc-hooks.el: Don't call expand-file-name.
1472
1473    Normally, `C-x v a' separates log entries by a blank line, but you
1474 can mark several related log entries to be clumped together (without an
1475 intervening blank line) by starting the text of each related log entry
1476 with a label of the form `{CLUMPNAME} '.  The label itself is not
1477 copied to `ChangeLog'.  For example, suppose the log entries are:
1478
1479 For `vc.texinfo':
1480      {expand} Fix expansion typos.
1481 For `vc.el':
1482      {expand} Don't call expand-file-name.
1483 For `vc-hooks.el':
1484      {expand} Don't call expand-file-name.
1485
1486 Then the text in `ChangeLog' looks like this:
1487
1488      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  (nat@apn.org)
1489
1490              * vc.texinfo: Fix expansion typos.
1491              * vc.el, vc-hooks.el: Don't call expand-file-name.
1492
1493    A log entry whose text begins with `#' is not copied to `ChangeLog'.
1494 For example, if you merely fix some misspellings in comments, you can
1495 log the change with an entry beginning with `#' to avoid putting such
1496 trivia into `ChangeLog'.
1497
1498 \1f
1499 File: xemacs.info,  Node: Old Versions,  Next: VC Status,  Prev: Change Logs and VC,  Up: Version Control
1500
1501 14.6.6 Examining And Comparing Old Versions
1502 -------------------------------------------
1503
1504 `C-x v ~ VERSION <RET>'
1505      Examine version VERSION of the visited file, in a buffer of its
1506      own (`vc-version-other-window').
1507
1508 `C-x v ='
1509      Compare the current buffer contents with the latest checked-in
1510      version of the file.
1511
1512 `C-u C-x v = FILE <RET> OLDVERS <RET> NEWVERS <RET>'
1513      Compare the specified two versions of FILE.
1514
1515    You can examine any version of a file by first visiting it, and then
1516 using `C-x v ~ VERSION <RET>' (`vc-version-other-window').  This puts
1517 the text of version VERSION in a file named `FILENAME.~VERSION~', then
1518 visits it in a separate window.
1519
1520    To compare two versions of a file, use the command `C-x v ='
1521 (`vc-diff').
1522
1523    Plain `C-x v =' compares the current buffer contents (saving them in
1524 the file if necessary) with the last checked-in version of the file.
1525 With a prefix argument, `C-x v =' reads a file name and two version
1526 numbers, then compares those versions of the specified file.
1527
1528    If you supply a directory name instead of the name of a work file,
1529 this command compares the two specified versions of all registered files
1530 in that directory and its subdirectories.  You can also specify a
1531 snapshot name (*note Snapshots::) instead of one or both version
1532 numbers.
1533
1534    You can specify a checked-in version by its number; you can specify
1535 the most recent checked-in version with an empty version number.
1536
1537    This command works by running the `vcdiff' utility, getting the
1538 options from the variable `diff-switches'.  It displays the output in a
1539 special buffer in another window.  Unlike the `M-x diff' command, `C-x
1540 v =' does not try to find the changes in the old and new versions.
1541 This is because one or both versions normally do not exist as files.
1542 They exist only in the records of the master file.  *Note Comparing
1543 Files::, for more information about `M-x diff'.
1544
1545 \1f
1546 File: xemacs.info,  Node: VC Status,  Next: Renaming and VC,  Prev: Old Versions,  Up: Version Control
1547
1548 14.6.7 VC Status Commands
1549 -------------------------
1550
1551 To view the detailed version control status and history of a file, type
1552 `C-x v l' (`vc-print-log').  It displays the history of changes to the
1553 current file, including the text of the log entries.  The output
1554 appears in a separate window.
1555
1556    When you are working on a large program, it's often useful to find
1557 all the files that are currently locked, or all the files maintained in
1558 version control at all.  You can use `C-x v d' (`vc-directory') to show
1559 all the locked files in or beneath the current directory.  This
1560 includes all files that are locked by any user.  `C-u C-x v d' lists
1561 all files in or beneath the current directory that are maintained with
1562 version control.
1563
1564    The list of files is displayed as a buffer that uses an augmented
1565 Dired mode.  The names of the users locking various files are shown (in
1566 parentheses) in place of the owner and group.  All the normal Dired
1567 commands work in this buffer.  Most interactive VC commands work also,
1568 and apply to the file name on the current line.
1569
1570    The `C-x v v' command (`vc-next-action'), when used in the augmented
1571 Dired buffer, operates on all the marked files (or the file on the
1572 current line).  If it operates on more than one file, it handles each
1573 file according to its current state; thus, it may check out one file
1574 and check in another (because it is already checked out).  If it has to
1575 check in any files, it reads a single log entry, then uses that text
1576 for all the files being checked in.  This can be convenient for
1577 registering or checking in several files at once, as part of the same
1578 change.
1579
1580 \1f
1581 File: xemacs.info,  Node: Renaming and VC,  Next: Snapshots,  Prev: VC Status,  Up: Version Control
1582
1583 14.6.8 Renaming VC Work Files and Master Files
1584 ----------------------------------------------
1585
1586 When you rename a registered file, you must also rename its master file
1587 correspondingly to get proper results.  Use `vc-rename-file' to rename
1588 the source file as you specify, and rename its master file accordingly.
1589 It also updates any snapshots (*note Snapshots::) that mention the
1590 file, so that they use the new name; despite this, the snapshot thus
1591 modified may not completely work (*note Snapshot Caveats::).
1592
1593    You cannot use `vc-rename-file' on a file that is locked by someone
1594 else.
1595
1596 \1f
1597 File: xemacs.info,  Node: Snapshots,  Next: Version Headers,  Prev: Renaming and VC,  Up: Version Control
1598
1599 14.6.9 Snapshots
1600 ----------------
1601
1602 A "snapshot" is a named set of file versions (one for each registered
1603 file) that you can treat as a unit.  One important kind of snapshot is
1604 a "release", a (theoretically) stable version of the system that is
1605 ready for distribution to users.
1606
1607 * Menu:
1608
1609 * Making Snapshots::            The snapshot facilities.
1610 * Snapshot Caveats::            Things to be careful of when using snapshots.
1611
1612 \1f
1613 File: xemacs.info,  Node: Making Snapshots,  Next: Snapshot Caveats,  Prev: Snapshots,  Up: Snapshots
1614
1615 14.6.9.1 Making and Using Snapshots
1616 ...................................
1617
1618 There are two basic commands for snapshots; one makes a snapshot with a
1619 given name, the other retrieves a named snapshot.
1620
1621 `C-x v s NAME <RET>'
1622      Define the last saved versions of every registered file in or
1623      under the current directory as a snapshot named NAME
1624      (`vc-create-snapshot').
1625
1626 `C-x v r NAME <RET>'
1627      Check out all registered files at or below the current directory
1628      level using whatever versions correspond to the snapshot NAME
1629      (`vc-retrieve-snapshot').
1630
1631      This command reports an error if any files are locked at or below
1632      the current directory, without changing anything; this is to avoid
1633      overwriting work in progress.
1634
1635    A snapshot uses a very small amount of resources--just enough to
1636 record the list of file names and which version belongs to the
1637 snapshot.  Thus, you need not hesitate to create snapshots whenever
1638 they are useful.
1639
1640    You can give a snapshot name as an argument to `C-x v =' or `C-x v
1641 ~' (*note Old Versions::).  Thus, you can use it to compare a snapshot
1642 against the current files, or two snapshots against each other, or a
1643 snapshot against a named version.
1644
1645 \1f
1646 File: xemacs.info,  Node: Snapshot Caveats,  Prev: Making Snapshots,  Up: Snapshots
1647
1648 14.6.9.2 Snapshot Caveats
1649 .........................
1650
1651 VC's snapshot facilities are modeled on RCS's named-configuration
1652 support.  They use RCS's native facilities for this, so under VC
1653 snapshots made using RCS are visible even when you bypass VC.
1654
1655    For SCCS, VC implements snapshots itself.  The files it uses contain
1656 name/file/version-number triples.  These snapshots are visible only
1657 through VC.
1658
1659    A snapshot is a set of checked-in versions.  So make sure that all
1660 the files are checked in and not locked when you make a snapshot.
1661
1662    File renaming and deletion can create some difficulties with
1663 snapshots.  This is not a VC-specific problem, but a general design
1664 issue in version control systems that no one has solved very well yet.
1665
1666    If you rename a registered file, you need to rename its master along
1667 with it (the command `vc-rename-file' does this automatically).  If you
1668 are using SCCS, you must also update the records of the snapshot, to
1669 mention the file by its new name (`vc-rename-file' does this, too).  An
1670 old snapshot that refers to a master file that no longer exists under
1671 the recorded name is invalid; VC can no longer retrieve it.  It would
1672 be beyond the scope of this manual to explain enough about RCS and SCCS
1673 to explain how to update the snapshots by hand.
1674
1675    Using `vc-rename-file' makes the snapshot remain valid for
1676 retrieval, but it does not solve all problems.  For example, some of the
1677 files in the program probably refer to others by name.  At the very
1678 least, the makefile probably mentions the file that you renamed.  If you
1679 retrieve an old snapshot, the renamed file is retrieved under its new
1680 name, which is not the name that the makefile expects.  So the program
1681 won't really work as retrieved.
1682
1683 \1f
1684 File: xemacs.info,  Node: Version Headers,  Prev: Snapshots,  Up: Version Control
1685
1686 14.6.10 Inserting Version Control Headers
1687 -----------------------------------------
1688
1689 Sometimes it is convenient to put version identification strings
1690 directly into working files.  Certain special strings called "version
1691 headers" are replaced in each successive version by the number of that
1692 version.
1693
1694    You can use the `C-x v h' command (`vc-insert-headers') to insert a
1695 suitable header string.
1696
1697 `C-x v h'
1698      Insert headers in a file for use with your version-control system.
1699
1700    The default header string is `\$Id\$' for RCS and `\%W\%' for SCCS.
1701 (The actual strings inserted do not have the backslashes in them.  They
1702 were placed in the Info source file so that the strings don't get
1703 interpreted as version-control headers when the Info source files are
1704 maintained under version control.) You can specify other headers to
1705 insert by setting the variable `vc-header-alist'.  Its value is a list
1706 of elements of the form `(PROGRAM . STRING)' where PROGRAM is `RCS' or
1707 `SCCS' and STRING is the string to use.
1708
1709    Instead of a single string, you can specify a list of strings; then
1710 each string in the list is inserted as a separate header on a line of
1711 its own.
1712
1713    It is often necessary to use "superfluous" backslashes when writing
1714 the strings that you put in this variable.  This is to prevent the
1715 string in the constant from being interpreted as a header itself if the
1716 Emacs Lisp file containing it is maintained with version control.
1717
1718    Each header is inserted surrounded by tabs, inside comment
1719 delimiters, on a new line at the start of the buffer.  Normally the
1720 ordinary comment start and comment end strings of the current mode are
1721 used, but for certain modes, there are special comment delimiters for
1722 this purpose; the variable `vc-comment-alist' specifies them.  Each
1723 element of this list has the form `(MODE STARTER ENDER)'.
1724
1725    The variable `vc-static-header-alist' specifies further strings to
1726 add based on the name of the buffer.  Its value should be a list of
1727 elements of the form `(REGEXP . FORMAT)'.  Whenever REGEXP matches the
1728 buffer name, FORMAT is inserted as part of the header.  A header line
1729 is inserted for each element that matches the buffer name, and for each
1730 string specified by `vc-header-alist'.  The header line is made by
1731 processing the string from `vc-header-alist' with the format taken from
1732 the element.  The default value for `vc-static-header-alist' is:
1733
1734      (("\\.c$" .
1735        "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
1736      #endif /* lint */\n"))
1737
1738 which specifies insertion of a string of this form:
1739
1740
1741      #ifndef lint
1742      static char vcid[] = "STRING";
1743      #endif /* lint */
1744
1745 \1f
1746 File: xemacs.info,  Node: ListDir,  Next: Comparing Files,  Prev: Version Control,  Up: Files
1747
1748 14.7 Listing a File Directory
1749 =============================
1750
1751 Files are organized by Unix into "directories".  A "directory listing"
1752 is a list of all the files in a directory.  Emacs provides directory
1753 listings in brief format (file names only) and verbose format (sizes,
1754 dates, and authors included).
1755
1756 `C-x C-d DIR-OR-PATTERN'
1757      Print a brief directory listing (`list-directory').
1758
1759 `C-u C-x C-d DIR-OR-PATTERN'
1760      Print a verbose directory listing.
1761
1762    To print a directory listing, use `C-x C-d' (`list-directory').
1763 This command prompts in the minibuffer for a file name which is either
1764 a  directory to be listed or pattern containing wildcards for the files
1765 to be listed.  For example,
1766
1767      C-x C-d /u2/emacs/etc <RET>
1768
1769 lists all the files in directory `/u2/emacs/etc'.  An example of
1770 specifying a file name pattern is:
1771
1772      C-x C-d /u2/emacs/src/*.c <RET>
1773
1774    Normally, `C-x C-d' prints a brief directory listing containing just
1775 file names.  A numeric argument (regardless of value) tells it to print
1776 a verbose listing (like `ls -l').
1777
1778    Emacs obtains the text of a directory listing by running `ls' in an
1779 inferior process.  Two Emacs variables control the switches passed to
1780 `ls': `list-directory-brief-switches' is a string giving the switches
1781 to use in brief listings (`"-CF"' by default).
1782 `list-directory-verbose-switches' is a string giving the switches to
1783 use in a verbose listing (`"-l"' by default).
1784
1785    The variable `directory-abbrev-alist' is an alist of abbreviations
1786 for file directories.  The list consists of elements of the form `(FROM
1787 .  TO)', each meaning to replace `FROM' with `TO' when it appears in a
1788 directory name.  This replacement is done when setting up the default
1789 directory of a newly visited file.  Every `FROM' string should start
1790 with ``^''.
1791
1792    Use this feature when you have directories which you normally refer
1793 to via absolute symbolic links.  Make `TO' the name of the link, and
1794 `FROM' the name it is linked to.
1795
1796 \1f
1797 File: xemacs.info,  Node: Comparing Files,  Next: Dired,  Prev: ListDir,  Up: Files
1798
1799 14.8 Comparing Files
1800 ====================
1801
1802 The command `M-x diff' compares two files, displaying the differences
1803 in an Emacs buffer named `*Diff*'.  It works by running the `diff'
1804 program, using options taken from the variable `diff-switches', whose
1805 value should be a string.
1806
1807    The buffer `*Diff*' has Compilation mode as its major mode, so you
1808 can use `C-x `' to visit successive changed locations in the two source
1809 files.  You can also move to a particular hunk of changes and type `C-c
1810 C-c' to find the corresponding source location.  You can also use the
1811 other special commands of Compilation mode: <SPC> and <DEL> for
1812 scrolling, and `M-p' and `M-n' for cursor motion.  *Note Compilation::.
1813
1814    The command `M-x diff-backup' compares a specified file with its most
1815 recent backup.  If you specify the name of a backup file, `diff-backup'
1816 compares it with the source file that it is a backup of.
1817
1818    The command `M-x compare-windows' compares the text in the current
1819 window with that in the next window.  Comparison starts at point in each
1820 window.  Point moves forward in each window, a character at a time in
1821 each window, until the next characters in the two windows are
1822 different.  Then the command is finished.  For more information about
1823 windows in Emacs, *Note Windows::.
1824
1825    With a numeric argument, `compare-windows' ignores changes in
1826 whitespace.  If the variable `compare-ignore-case' is non-`nil', it
1827 ignores differences in case as well.
1828
1829 \1f
1830 File: xemacs.info,  Node: Dired,  Next: Misc File Ops,  Prev: Comparing Files,  Up: Files
1831
1832 14.9 Dired, the Directory Editor
1833 ================================
1834
1835 Dired makes it easy to delete or visit many of the files in a single
1836 directory at once.  It creates an Emacs buffer containing a listing of
1837 the directory.  You can use the normal Emacs commands to move around in
1838 this buffer and special Dired commands to operate on the files.
1839
1840 * Menu:
1841
1842 * Enter: Dired Enter.         How to invoke Dired.
1843 * Edit: Dired Edit.           Editing the Dired buffer.
1844 * Deletion: Dired Deletion.   Deleting files with Dired.
1845 * Immed: Dired Immed.         Other file operations through Dired.
1846
1847 \1f
1848 File: xemacs.info,  Node: Dired Enter,  Next: Dired Edit,  Prev: Dired,  Up: Dired
1849
1850 14.9.1 Entering Dired
1851 ---------------------
1852
1853 To invoke dired, type `C-x d' or `M-x dired'.  The command reads a
1854 directory name or wildcard file name pattern as a minibuffer argument
1855 just like the `list-directory' command, `C-x C-d'.  Where `dired'
1856 differs from `list-directory' is in naming the buffer after the
1857 directory name or the wildcard pattern used for the listing, and putting
1858 the buffer into Dired mode so that the special commands of Dired are
1859 available in it.  The variable `dired-listing-switches' is a string
1860 used as an argument to `ls' in making the directory; this string must
1861 contain `-l'.
1862
1863    To display the Dired buffer in another window rather than in the
1864 selected window, use `C-x 4 d' (`dired-other-window)' instead of `C-x
1865 d'.
1866
1867 \1f
1868 File: xemacs.info,  Node: Dired Edit,  Next: Dired Deletion,  Prev: Dired Enter,  Up: Dired
1869
1870 14.9.2 Editing in Dired
1871 -----------------------
1872
1873 Once the Dired buffer exists, you can switch freely between it and other
1874 Emacs buffers.  Whenever the Dired buffer is selected, certain special
1875 commands are provided that operate on files that are listed.  The Dired
1876 buffer is "read-only", and inserting text in it is not useful, so
1877 ordinary printing characters such as `d' and `x' are used for Dired
1878 commands.  Most Dired commands operate on the file described by the line
1879 that point is on.  Some commands perform operations immediately; others
1880 "flag" a file to be operated on later.
1881
1882    Most Dired commands that operate on the current line's file also
1883 treat a numeric argument as a repeat count, meaning to act on the files
1884 of the next few lines.  A negative argument means to operate on the
1885 files of the preceding lines, and leave point on the first of those
1886 lines.
1887
1888    All the usual Emacs cursor motion commands are available in Dired
1889 buffers.  Some special purpose commands are also provided.  The keys
1890 `C-n' and `C-p' are redefined so that they try to position the cursor
1891 at the beginning of the filename on the line, rather than at the
1892 beginning of the line.
1893
1894    For extra convenience, <SPC> and `n' in Dired are equivalent to
1895 `C-n'.  `p' is equivalent to `C-p'.  Moving by lines is done so often
1896 in Dired that it deserves to be easy to type.  <DEL> (move up and
1897 unflag) is often useful simply for moving up.
1898
1899    The `g' command in Dired runs `revert-buffer' to reinitialize the
1900 buffer from the actual disk directory and show any changes made in the
1901 directory by programs other than Dired.  All deletion flags in the Dired
1902 buffer are lost when this is done.
1903
1904 \1f
1905 File: xemacs.info,  Node: Dired Deletion,  Next: Dired Immed,  Prev: Dired Edit,  Up: Dired
1906
1907 14.9.3 Deleting Files With Dired
1908 --------------------------------
1909
1910 The primary use of Dired is to flag files for deletion and then delete
1911 them.
1912
1913 `d'
1914      Flag this file for deletion.
1915
1916 `u'
1917      Remove deletion-flag on this line.
1918
1919 `<DEL>'
1920      Remove deletion-flag on previous line, moving point to that line.
1921
1922 `x'
1923      Delete the files that are flagged for deletion.
1924
1925 `#'
1926      Flag all auto-save files (files whose names start and end with `#')
1927      for deletion (*note Auto Save::).
1928
1929 `~'
1930      Flag all backup files (files whose names end with `~') for deletion
1931      (*note Backup::).
1932
1933 `. (Period)'
1934      Flag excess numeric backup files for deletion.  The oldest and
1935      newest few backup files of any one file are exempt; the middle
1936      ones are flagged.
1937
1938    You can flag a file for deletion by moving to the line describing the
1939 file and typing `d' or `C-d'.  The deletion flag is visible as a `D' at
1940 the beginning of the line.  Point is moved to the beginning of the next
1941 line, so that repeated `d' commands flag successive files.
1942
1943    The files are flagged for deletion rather than deleted immediately to
1944 avoid the danger of deleting a file accidentally.  Until you direct
1945 Dired to delete the flagged files, you can remove deletion flags using
1946 the commands `u' and <DEL>.  `u' works just like `d', but removes flags
1947 rather than making flags.  <DEL> moves upward, removing flags; it is
1948 like `u' with numeric argument automatically negated.
1949
1950    To delete the flagged files, type `x'.  This command first displays a
1951 list of all the file names flagged for deletion, and requests
1952 confirmation with `yes'.  Once you confirm, all the flagged files are
1953 deleted, and their lines are deleted from the text of the Dired buffer.
1954 The shortened Dired buffer remains selected.  If you answer `no' or
1955 quit with `C-g', you return immediately to Dired, with the deletion
1956 flags still present and no files actually deleted.
1957
1958    The `#', `~', and `.' commands flag many files for deletion, based
1959 on their names.  These commands are useful precisely because they do
1960 not actually delete any files; you can remove the deletion flags from
1961 any flagged files that you really wish to keep.
1962
1963    `#' flags for deletion all files that appear to have been made by
1964 auto-saving (that is, files whose names begin and end with `#').  `~'
1965 flags for deletion all files that appear to have been made as backups
1966 for files that were edited (that is, files whose names end with `~').
1967
1968    `.' (Period) flags just some of the backup files for deletion: only
1969 numeric backups that are not among the oldest few nor the newest few
1970 backups of any one file.  Normally `dired-kept-versions' (not
1971 `kept-new-versions'; that applies only when saving) specifies the
1972 number of newest versions of each file to keep, and `kept-old-versions'
1973 specifies the number of oldest versions to keep.  Period with a
1974 positive numeric argument, as in `C-u 3 .', specifies the number of
1975 newest versions to keep, overriding `dired-kept-versions'.  A negative
1976 numeric argument overrides `kept-old-versions', using minus the value
1977 of the argument to specify the number of oldest versions of each file
1978 to keep.
1979
1980 \1f
1981 File: xemacs.info,  Node: Dired Immed,  Prev: Dired Deletion,  Up: Dired
1982
1983 14.9.4 Immediate File Operations in Dired
1984 -----------------------------------------
1985
1986 Some file operations in Dired take place immediately when they are
1987 requested.
1988
1989 `C'
1990      Copies the file described on the current line.  You must supply a
1991      file name to copy to, using the minibuffer.
1992
1993 `f'
1994      Visits the file described on the current line.  It is just like
1995      typing `C-x C-f' and supplying that file name.  If the file on
1996      this line is a subdirectory, `f' actually causes Dired to be
1997      invoked on that subdirectory.  *Note Visiting::.
1998
1999 `o'
2000      Like `f', but uses another window to display the file's buffer.
2001      The Dired buffer remains visible in the first window.  This is
2002      like using `C-x 4 C-f' to visit the file.  *Note Windows::.
2003
2004 `R'
2005      Renames the file described on the current line.  You must supply a
2006      file name to rename to, using the minibuffer.
2007
2008 `v'
2009      Views the file described on this line using `M-x view-file'.
2010      Viewing a file is like visiting it, but is slanted toward moving
2011      around in the file conveniently and does not allow changing the
2012      file.  *Note View File: Misc File Ops.  Viewing a file that is a
2013      directory runs Dired on that directory.
2014
2015 \1f
2016 File: xemacs.info,  Node: Misc File Ops,  Prev: Dired,  Up: Files
2017
2018 14.10 Miscellaneous File Operations
2019 ===================================
2020
2021 Emacs has commands for performing many other operations on files.  All
2022 operate on one file; they do not accept wildcard file names.
2023
2024    You can use the command `M-x add-name-to-file' to add a name to an
2025 existing file without removing the old name.  The new name must belong
2026 on the file system that the file is on.
2027
2028    `M-x append-to-file' adds the text of the region to the end of the
2029 specified file.
2030
2031    `M-x copy-file' reads the file OLD and writes a new file named NEW
2032 with the same contents.  Confirmation is required if a file named NEW
2033 already exists, because copying overwrites the old contents of the file
2034 NEW.
2035
2036    `M-x delete-file' deletes a specified file, like the `rm' command in
2037 the shell.  If you are deleting many files in one directory, it may be
2038 more convenient to use Dired (*note Dired::).
2039
2040    `M-x insert-file' inserts a copy of the contents of a specified file
2041 into the current buffer at point, leaving point unchanged before the
2042 contents and the mark after them.  *Note Mark::.
2043
2044    `M-x make-symbolic-link' reads two file names OLD and LINKNAME, and
2045 then creates a symbolic link named LINKNAME and pointing at OLD.
2046 Future attempts to open file LINKNAME will then refer to the file named
2047 OLD at the time the opening is done, or will result in an error if the
2048 name OLD is not in use at that time.  Confirmation is required if you
2049 create the link while LINKNAME is in use.  Note that not all systems
2050 support symbolic links.
2051
2052    `M-x rename-file' reads two file names OLD and NEW using the
2053 minibuffer, then renames file OLD as NEW.  If a file named NEW already
2054 exists, you must confirm with `yes' or renaming is not done; this is
2055 because renaming causes the previous meaning of the name NEW to be
2056 lost.  If OLD and NEW are on different file systems, the file OLD is
2057 copied and deleted.
2058
2059    `M-x view-file' allows you to scan or read a file by sequential
2060 screenfuls.  It reads a file name argument using the minibuffer.  After
2061 reading the file into an Emacs buffer, `view-file' reads and displays
2062 one windowful.  You can then type <SPC> to scroll forward one window,
2063 or <DEL> to scroll backward.  Various other commands are provided for
2064 moving around in the file, but none for changing it; type `C-h' while
2065 viewing a file for a list of them.  Most commands are the default Emacs
2066 cursor motion commands.  To exit from viewing, type `C-c'.
2067
2068 \1f
2069 File: xemacs.info,  Node: Buffers,  Next: Windows,  Prev: Files,  Up: Top
2070
2071 15 Using Multiple Buffers
2072 *************************
2073
2074 Text you are editing in Emacs resides in an object called a "buffer".
2075 Each time you visit a file, Emacs creates a buffer to hold the file's
2076 text.  Each time you invoke Dired, Emacs creates a buffer to hold the
2077 directory listing.  If you send a message with `C-x m', a buffer named
2078 `*mail*' is used to hold the text of the message.  When you ask for a
2079 command's documentation, it appears in a buffer called `*Help*'.
2080
2081    At any time, one and only one buffer is "selected".  It is also
2082 called the "current buffer".  Saying a command operates on "the buffer"
2083 really means that the command operates on the selected buffer, as most
2084 commands do.
2085
2086    When Emacs creates multiple windows, each window has a chosen buffer
2087 which is displayed there, but at any time only one of the windows is
2088 selected and its chosen buffer is the selected buffer.  Each window's
2089 mode line displays the name of the buffer the window is displaying
2090 (*note Windows::).
2091
2092    Each buffer has a name which can be of any length but is
2093 case-sensitive.  You can select a buffer using its name.  Most buffers
2094 are created when you visit files; their names are derived from the
2095 files' names.  You can also create an empty buffer with any name you
2096 want.  A newly started Emacs has a buffer named `*scratch*' which you
2097 can use for evaluating Lisp expressions in Emacs.
2098
2099    Each buffer records what file it is visiting, whether it is
2100 modified, and what major mode and minor modes are in effect in it
2101 (*note Major Modes::).  Any Emacs variable can be made "local to" a
2102 particular buffer, meaning its value in that buffer can be different
2103 from the value in other buffers.  *Note Locals::.
2104
2105 * Menu:
2106
2107 * Select Buffer::   Creating a new buffer or reselecting an old one.
2108 * List Buffers::    Getting a list of buffers that exist.
2109 * Misc Buffer::     Renaming; changing read-onliness; copying text.
2110 * Kill Buffer::     Killing buffers you no longer need.
2111 * Several Buffers:: How to go through the list of all buffers
2112                      and operate variously on several of them.
2113
2114 \1f
2115 File: xemacs.info,  Node: Select Buffer,  Next: List Buffers,  Prev: Buffers,  Up: Buffers
2116
2117 15.1 Creating and Selecting Buffers
2118 ===================================
2119
2120 `C-x b BUFFER <RET>'
2121      Select or create a buffer named BUFFER (`switch-to-buffer').
2122
2123 `C-x 4 b BUFFER <RET>'
2124      Similar, but select a buffer named BUFFER in another window
2125      (`switch-to-buffer-other-window').
2126
2127 `M-x switch-to-other-buffer N'
2128      Switch to the previous buffer.
2129
2130    To select a buffer named BUFNAME, type `C-x b BUFNAME <RET>'.  This
2131 is the command `switch-to-buffer' with argument BUFNAME.  You can use
2132 completion on an abbreviation for the buffer name you want (*note
2133 Completion::).  An empty argument to `C-x b' specifies the most
2134 recently selected buffer that is not displayed in any window.
2135
2136    Most buffers are created when you visit files, or use Emacs commands
2137 that display text.  You can also create a buffer explicitly by typing
2138 `C-x b BUFNAME <RET>', which creates a new, empty buffer that is not
2139 visiting any file, and selects it for editing.  The new buffer's major
2140 mode is determined by the value of `default-major-mode' (*note Major
2141 Modes::).  Buffers not visiting files are usually used for making notes
2142 to yourself.  If you try to save one, you are asked for the file name
2143 to use.
2144
2145    The function `switch-to-buffer-other-frame' is similar to
2146 `switch-to-buffer' except that it creates a new frame in which to
2147 display the selected buffer.
2148
2149    Use `M-x switch-to-other-buffer' to visit the previous buffer. If
2150 you supply a positive integer N, the Nth most recent buffer is
2151 displayed. If you supply an argument of 0, the current buffer is moved
2152 to the bottom of the buffer stack.
2153
2154    Note that you can also use `C-x C-f' and any other command for
2155 visiting a file to switch buffers.  *Note Visiting::.
2156
2157 \1f
2158 File: xemacs.info,  Node: List Buffers,  Next: Misc Buffer,  Prev: Select Buffer,  Up: Buffers
2159
2160 15.2 Listing Existing Buffers
2161 =============================
2162
2163 `C-x C-b'
2164      List the existing buffers (`list-buffers').
2165
2166    To print a list of all existing buffers, type `C-x C-b'.  Each line
2167 in the list shows one buffer's name, major mode, and visited file.  A
2168 `*' at the beginning of a line indicates the buffer has been
2169 "modified".  If several buffers are modified, it may be time to save
2170 some with `C-x s' (*note Saving::).  A `%' indicates a read-only
2171 buffer.  A `.' marks the selected buffer.  Here is an example of a
2172 buffer list:
2173
2174       MR Buffer         Size  Mode           File
2175       -- ------         ----  ----           ----
2176      .*  emacs.tex      383402 Texinfo       /u2/emacs/man/emacs.tex
2177          *Help*         1287  Fundamental
2178          files.el       23076 Emacs-Lisp     /u2/emacs/lisp/files.el
2179        % RMAIL          64042 RMAIL          /u/rms/RMAIL
2180       *% man            747   Dired          /u2/emacs/man/
2181          net.emacs      343885 Fundamental   /u/rms/net.emacs
2182          fileio.c       27691 C              /u2/emacs/src/fileio.c
2183          NEWS           67340 Text           /u2/emacs/etc/NEWS
2184          *scratch*      0     Lisp Interaction
2185
2186 Note that the buffer `*Help*' was made by a help request; it is not
2187 visiting any file.  The buffer `man' was made by Dired on the directory
2188 `/u2/emacs/man/'.
2189
2190    As you move the mouse over the `*Buffer List*' buffer, the lines are
2191 highlighted.  This visual cue indicates that clicking the right mouse
2192 button (`button3') will pop up a menu of commands on the buffer
2193 represented by this line.  This menu duplicates most of those commands
2194 which are bound to keys in the `*Buffer List*' buffer.
2195
2196 \1f
2197 File: xemacs.info,  Node: Misc Buffer,  Next: Kill Buffer,  Prev: List Buffers,  Up: Buffers
2198
2199 15.3 Miscellaneous Buffer Operations
2200 ====================================
2201
2202 `C-x C-q'
2203      Toggle read-only status of buffer (`toggle-read-only').
2204
2205 `M-x rename-buffer'
2206      Change the name of the current buffer.
2207
2208 `M-x view-buffer'
2209      Scroll through a buffer.
2210
2211    A buffer can be "read-only", which means that commands to change its
2212 text are not allowed.  Normally, read-only buffers are created by
2213 subsystems such as Dired and Rmail that have special commands to operate
2214 on the text.  Emacs also creates a read-only buffer if you visit a file
2215 that is protected.  To make changes in a read-only buffer, use the
2216 command `C-x C-q' (`toggle-read-only').  It makes a read-only buffer
2217 writable, and makes a writable buffer read-only.  This works by setting
2218 the variable `buffer-read-only', which has a local value in each buffer
2219 and makes a buffer read-only if its value is non-`nil'.
2220
2221    `M-x rename-buffer' changes the name of the current buffer,
2222 prompting for the new name in the minibuffer.  There is no default.  If
2223 you specify a name that is used by a different buffer, an error is
2224 signalled and renaming is not done.
2225
2226    `M-x view-buffer' is similar to `M-x view-file' (*note Misc File
2227 Ops::), but it examines an already existing Emacs buffer.  View mode
2228 provides convenient commands for scrolling through the buffer but not
2229 for changing it.  When you exit View mode, the resulting value of point
2230 remains in effect.
2231
2232    To copy text from one buffer to another, use the commands `M-x
2233 append-to-buffer' and `M-x insert-buffer'.  *Note Accumulating Text::.
2234
2235 \1f
2236 File: xemacs.info,  Node: Kill Buffer,  Next: Several Buffers,  Prev: Misc Buffer,  Up: Buffers
2237
2238 15.4 Killing Buffers
2239 ====================
2240
2241 After using Emacs for a while, you may accumulate a large number of
2242 buffers and may want to eliminate the ones you no longer need.  There
2243 are several commands for doing this.
2244
2245 `C-x k'
2246      Kill a buffer, specified by name (`kill-buffer').
2247
2248 `M-x kill-some-buffers'
2249      Offer to kill each buffer, one by one.
2250
2251    `C-x k' (`kill-buffer') kills one buffer, whose name you specify in
2252 the minibuffer.  If you type just <RET> in the minibuffer, the default,
2253 killing the current buffer, is used.  If the current buffer is killed,
2254 the buffer that has been selected recently but does not appear in any
2255 window now is selected.  If the buffer being killed contains unsaved
2256 changes, you are asked to confirm with `yes' before the buffer is
2257 killed.
2258
2259    The command `M-x kill-some-buffers' asks about each buffer, one by
2260 one.  An answer of `y' means to kill the buffer.  Killing the current
2261 buffer or a buffer containing unsaved changes selects a new buffer or
2262 asks for confirmation just like `kill-buffer'.
2263
2264 \1f
2265 File: xemacs.info,  Node: Several Buffers,  Prev: Kill Buffer,  Up: Buffers
2266
2267 15.5 Operating on Several Buffers
2268 =================================
2269
2270 The "buffer-menu" facility is like a "Dired for buffers"; it allows you
2271 to request operations on various Emacs buffers by editing a buffer
2272 containing a list of them.  You can save buffers, kill them (here
2273 called "deleting" them, for consistency with Dired), or display them.
2274
2275 `M-x buffer-menu'
2276      Begin editing a buffer listing all Emacs buffers.
2277
2278    The command `buffer-menu' writes a list of all Emacs buffers into
2279 the buffer `*Buffer List*', and selects that buffer in Buffer Menu
2280 mode.  The buffer is read-only.  You can only change it using the
2281 special commands described in this section.  Most of the commands are
2282 graphic characters.  You can use  Emacs cursor motion commands in the
2283 `*Buffer List*' buffer.  If the cursor is on a line describing a
2284 buffer, the following  special commands apply to that buffer:
2285
2286 `d'
2287      Request to delete (kill) the buffer, then move down.  A `D' before
2288      the buffer name on a line indicates a deletion request.  Requested
2289      deletions actually take place when you use the `x' command.
2290
2291 `k'
2292      Synonym for `d'.
2293
2294 `C-d'
2295      Like `d' but move up afterwards instead of down.
2296
2297 `s'
2298      Request to save the buffer.  An `S' before the buffer name on a
2299      line indicates the request.  Requested saves actually take place
2300      when you use the `x' command.  You can request both saving and
2301      deletion for the same buffer.
2302
2303 `~'
2304      Mark buffer "unmodified".  The command `~' does this immediately
2305      when typed.
2306
2307 `x'
2308      Perform previously requested deletions and saves.
2309
2310 `u'
2311      Remove any request made for the current line, and move down.
2312
2313 `<DEL>'
2314      Move to previous line and remove any request made for that line.
2315
2316    All commands that add or remove flags to request later operations
2317 also move down a line.  They accept a numeric argument as a repeat
2318 count, unless otherwise specified.
2319
2320    There are also special commands to use the buffer list to select
2321 another buffer, and to specify one or more other buffers for display in
2322 additional windows.
2323
2324 `1'
2325      Select the buffer in a full-frame window.  This command takes
2326      effect immediately.
2327
2328 `2'
2329      Immediately set up two windows, with this buffer in one and the
2330      buffer selected before `*Buffer List*' in the other.
2331
2332 `f'
2333      Immediately select the buffer in place of the `*Buffer List*'
2334      buffer.
2335
2336 `o'
2337      Immediately select the buffer in another window as if by `C-x 4 b',
2338      leaving `*Buffer List*' visible.
2339
2340 `q'
2341      Immediately select this buffer, and display any buffers previously
2342      flagged with the `m' command in other windows.  If there are no
2343      buffers flagged with `m', this command is equivalent to `1'.
2344
2345 `m'
2346      Flag this buffer to be displayed in another window if the `q'
2347      command is used.  The request shows as a `>' at the beginning of
2348      the line.  The same buffer may not have both a delete request and a
2349      display request.
2350
2351    Going back between a `buffer-menu' buffer and other Emacs buffers is
2352 easy.  You can, for example, switch from the `*Buffer List*' buffer to
2353 another Emacs buffer, and edit there.  You can then reselect the
2354 `buffer-menu' buffer and perform operations already requested, or you
2355 can kill that buffer or pay no further attention to it.   All that
2356 `buffer-menu' does directly is create and select a suitable buffer, and
2357 turn on Buffer Menu mode.  All the other capabilities of the buffer
2358 menu are implemented by special commands provided in Buffer Menu mode.
2359
2360    The only difference between `buffer-menu' and `list-buffers' is that
2361 `buffer-menu' selects the `*Buffer List*' buffer and `list-buffers'
2362 does not.  If you run `list-buffers' (that is, type `C-x C-b') and
2363 select the buffer list manually, you can use all the commands described
2364 here.
2365
2366 \1f
2367 File: xemacs.info,  Node: Windows,  Next: Mule,  Prev: Buffers,  Up: Top
2368
2369 16 Multiple Windows
2370 *******************
2371
2372 Emacs can split the frame into two or many windows, which can display
2373 parts of different buffers or different parts of one buffer.  If you are
2374 running XEmacs under X, that means you can have the X window that
2375 contains the Emacs frame have multiple subwindows.
2376
2377 * Menu:
2378
2379 * Basic Window::     Introduction to Emacs windows.
2380 * Split Window::     New windows are made by splitting existing windows.
2381 * Other Window::     Moving to another window or doing something to it.
2382 * Pop Up Window::    Finding a file or buffer in another window.
2383 * Change Window::    Deleting windows and changing their sizes.
2384
2385 \1f
2386 File: xemacs.info,  Node: Basic Window,  Next: Split Window,  Prev: Windows,  Up: Windows
2387
2388 16.1 Concepts of Emacs Windows
2389 ==============================
2390
2391 When Emacs displays multiple windows, each window has one Emacs buffer
2392 designated for display.  The same buffer may appear in more than one
2393 window; if it does, any changes in its text are displayed in all the
2394 windows that display it.  Windows showing the same buffer can show
2395 different parts of it, because each window has its own value of point.
2396
2397    At any time, one  window is the "selected window"; the buffer
2398 displayed by that window is the current buffer.  The cursor shows the
2399 location of point in that window.  Each other window has a location of
2400 point as well, but since the terminal has only one cursor, it cannot
2401 show the location of point in the other windows.
2402
2403    Commands to move point affect the value of point for the selected
2404 Emacs window only.  They do not change the value of point in any other
2405 Emacs window, including those showing the same buffer.  The same is
2406 true for commands such as `C-x b' to change the selected buffer in the
2407 selected window; they do not affect other windows at all.  However,
2408 there are other commands such as `C-x 4 b' that select a different
2409 window and switch buffers in it.  Also, all commands that display
2410 information in a window, including (for example) `C-h f'
2411 (`describe-function') and `C-x C-b' (`list-buffers'), work by switching
2412 buffers in a non-selected window without affecting the selected window.
2413
2414    Each window has its own mode line, which displays the buffer name,
2415 modification status, and major and minor modes of the buffer that is
2416 displayed in the window.  *Note Mode Line::, for details on the mode
2417 line.
2418
2419 \1f
2420 File: xemacs.info,  Node: Split Window,  Next: Other Window,  Prev: Basic Window,  Up: Windows
2421
2422 16.2 Splitting Windows
2423 ======================
2424
2425 `C-x 2'
2426      Split the selected window into two windows, one above the other
2427      (`split-window-vertically').
2428
2429 `C-x 3'
2430      Split the selected window into two windows positioned side by side
2431      (`split-window-horizontally').
2432
2433 `C-x 6'
2434      Save the current window configuration in register REG (a letter).
2435
2436 `C-x 7'
2437      Restore (make current) the window configuration in register REG (a
2438      letter).  Use with a register previously set with `C-x 6'.
2439
2440    The command `C-x 2' (`split-window-vertically') breaks the selected
2441 window into two windows, one above the other.  Both windows start out
2442 displaying the same buffer, with the same value of point.  By default
2443 each of the two windows gets half the height of the window that was
2444 split.  A numeric argument specifies how many lines to give to the top
2445 window.
2446
2447    `C-x 3' (`split-window-horizontally') breaks the selected window
2448 into two side-by-side windows.  A numeric argument specifies how many
2449 columns to give the one on the left.  A line of vertical bars separates
2450 the two windows.  Windows that are not the full width of the frame have
2451 truncated mode lines which do not always appear in inverse video,
2452 because Emacs display routines cannot display a region of inverse video
2453 that is only part of a line on the screen.
2454
2455    When a window is less than the full width, many text lines are too
2456 long to fit.  Continuing all those lines might be confusing.  Set the
2457 variable `truncate-partial-width-windows' to non-`nil' to force
2458 truncation in all windows less than the full width of the frame,
2459 independent of the buffer and its value for `truncate-lines'.  *Note
2460 Continuation Lines::.
2461
2462    Horizontal scrolling is often used in side-by-side windows.  *Note
2463 Display::.
2464
2465    You can resize a window and store that configuration in a register by
2466 supplying a REGISTER argument to `window-configuration-to-register'
2467 (`C-x 6'). To return to the window configuration established with
2468 `window-configuration-to-register', use `jump-to-register' (`C-x j').
2469
2470 \1f
2471 File: xemacs.info,  Node: Other Window,  Next: Pop Up Window,  Prev: Split Window,  Up: Windows
2472
2473 16.3 Using Other Windows
2474 ========================
2475
2476 `C-x o'
2477      Select another window (`other-window').  That is the letter `o',
2478      not zero.
2479
2480 `M-C-v'
2481      Scroll the next window (`scroll-other-window').
2482
2483 `M-x compare-windows'
2484      Find the next place where the text in the selected window does not
2485      match the text in the next window.
2486
2487 `M-x other-window-any-frame N'
2488      Select the Nth different window on any frame.
2489
2490    To select a different window, use `C-x o' (`other-window').  That is
2491 an `o', for `other', not a zero.  When there are more than two windows,
2492 the command moves through all the windows in a cyclic order, generally
2493 top to bottom and left to right.  From the rightmost and bottommost
2494 window, it goes back to the one at the upper left corner.  A numeric
2495 argument, N, moves several steps in the cyclic order of windows. A
2496 negative numeric argument moves around the cycle in the opposite order.
2497 If the optional second argument WHICH-FRAMES is non-`nil', the
2498 function cycles through all frames.  When the minibuffer is active, the
2499 minibuffer is the last window in the cycle; you can switch from the
2500 minibuffer window to one of the other windows, and later switch back
2501 and finish supplying the minibuffer argument that is requested.  *Note
2502 Minibuffer Edit::.
2503
2504    The command `M-x other-window-any-frame' also selects the window N
2505 steps away in the cyclic order.  However, unlike `other-window', this
2506 command selects a window on the next or previous frame instead of
2507 wrapping around to the top or bottom of the current frame, when there
2508 are no more windows.
2509
2510    The usual scrolling commands (*note Display::) apply to the selected
2511 window only.  `M-C-v' (`scroll-other-window') scrolls the window that
2512 `C-x o' would select.  Like `C-v', it takes positive and negative
2513 arguments.
2514
2515    The command `M-x compare-windows' compares the text in the current
2516 window with the text in the next window.  Comparison starts at point in
2517 each window.  Point moves forward in each window, a character at a time,
2518 until the next set of characters in the two windows are different.
2519 Then the command is finished.
2520
2521    A prefix argument IGNORE-WHITESPACE means ignore changes in
2522 whitespace.  The variable `compare-windows-whitespace' controls how
2523 whitespace is skipped.
2524
2525    If `compare-ignore-case' is non-`nil', changes in case are also
2526 ignored.
2527
2528 \1f
2529 File: xemacs.info,  Node: Pop Up Window,  Next: Change Window,  Prev: Other Window,  Up: Windows
2530
2531 16.4 Displaying in Another Window
2532 =================================
2533
2534 `C-x 4' is a prefix key for commands that select another window
2535 (splitting the window if there is only one) and select a buffer in that
2536 window.  Different `C-x 4' commands have different ways of finding the
2537 buffer to select.
2538
2539 `C-x 4 b BUFNAME <RET>'
2540      Select buffer BUFNAME in another window.  This runs
2541      `switch-to-buffer-other-window'.
2542
2543 `C-x 4 f FILENAME <RET>'
2544      Visit file FILENAME and select its buffer in another window.  This
2545      runs `find-file-other-window'.  *Note Visiting::.
2546
2547 `C-x 4 d DIRECTORY <RET>'
2548      Select a Dired buffer for directory DIRECTORY in another window.
2549      This runs `dired-other-window'.  *Note Dired::.
2550
2551 `C-x 4 m'
2552      Start composing a mail message in another window.  This runs
2553      `mail-other-window', and its same-window version is `C-x m' (*note
2554      Sending Mail::).
2555
2556 `C-x 4 .'
2557      Find a tag in the current tag table in another window.  This runs
2558      `find-tag-other-window', the multiple-window variant of `M-.'
2559      (*note Tags::).
2560
2561    If the variable `display-buffer-function' is non-`nil', its value is
2562 the function to call to handle `display-buffer'. It receives two
2563 arguments, the buffer and a flag that if non-`nil' means that the
2564 currently selected window is not acceptable. Commands such as
2565 `switch-to-buffer-other-window' and `find-file-other-window' work using
2566 this function.
2567
2568 \1f
2569 File: xemacs.info,  Node: Change Window,  Prev: Pop Up Window,  Up: Windows
2570
2571 16.5 Deleting and Rearranging Windows
2572 =====================================
2573
2574 `C-x 0'
2575      Get rid of the selected window (`delete-window').  That is a zero.
2576      If there is more than one Emacs frame, deleting the sole remaining
2577      window on that frame deletes the frame as well. If the current
2578      frame is the only frame, it is not deleted.
2579
2580 `C-x 1'
2581      Get rid of all windows except the selected one
2582      (`delete-other-windows').
2583
2584 `C-x ^'
2585      Make the selected window taller, at the expense of the other(s)
2586      (`enlarge-window').
2587
2588 `C-x }'
2589      Make the selected window wider (`enlarge-window-horizontally').
2590
2591    To delete a window, type `C-x 0' (`delete-window').  (That is a
2592 zero.)  The space occupied by the deleted window is distributed among
2593 the other active windows (but not the minibuffer window, even if that
2594 is active at the time).  Once a window is deleted, its attributes are
2595 forgotten; there is no automatic way to make another window of the same
2596 shape or showing the same buffer.  The buffer continues to exist, and
2597 you can select it in any window with `C-x b'.
2598
2599    `C-x 1' (`delete-other-windows') is more powerful than `C-x 0'; it
2600 deletes all the windows except the selected one (and the minibuffer).
2601 The selected window expands to use the whole frame except for the echo
2602 area.
2603
2604    To readjust the division of space among existing windows, use `C-x
2605 ^' (`enlarge-window').  It makes the currently selected window longer
2606 by one line or as many lines as a numeric argument specifies.  With a
2607 negative argument, it makes the selected window smaller.  `C-x }'
2608 (`enlarge-window-horizontally') makes the selected window wider by the
2609 specified number of columns.  The extra screen space given to a window
2610 comes from one of its neighbors, if that is possible; otherwise, all
2611 the competing windows are shrunk in the same proportion.  If this makes
2612 some windows too small, those windows are deleted and their space is
2613 divided up.   Minimum window size is specified by the variables
2614 `window-min-height' and `window-min-width'.
2615
2616    You can also resize windows within a frame by clicking the left mouse
2617 button on a modeline, and dragging.
2618
2619    Clicking the right button on a mode line pops up a menu of common
2620 window manager operations.  This menu contains the following options:
2621
2622 Delete Window
2623      Remove the window above this modeline from the frame.
2624
2625 Delete Other Windows
2626      Delete all windows on the frame except for the one above this
2627      modeline.
2628
2629 Split Window
2630      Split the window above the mode line in half, creating another
2631      window.
2632
2633 Split Window Horizontally
2634      Split the window above the mode line in half horizontally, so that
2635      there will be two windows side-by-side.
2636
2637 Balance Windows
2638      Readjust the sizes of all windows on the frame until all windows
2639      have roughly the same number of lines.
2640
2641 \1f
2642 File: xemacs.info,  Node: Mule,  Next: Major Modes,  Prev: Windows,  Up: Top
2643
2644 17 World Scripts Support
2645 ************************
2646
2647 If you compile XEmacs with Mule option, it supports a wide variety of
2648 world scripts, including Latin script, as well as Arabic script,
2649 Simplified Chinese script (for mainland of China), Traditional Chinese
2650 script (for Taiwan and Hong-Kong), Greek script, Hebrew script, IPA
2651 symbols, Japanese scripts (Hiragana, Katakana and Kanji), Korean scripts
2652 (Hangul and Hanja) and Cyrillic script (for Byelorussian, Bulgarian,
2653 Russian, Serbian and Ukrainian).  These features have been merged from
2654 the modified version of Emacs known as MULE (for "MULti-lingual
2655 Enhancement to GNU Emacs").
2656
2657 * Menu:
2658
2659 * Mule Intro::              Basic concepts of Mule.
2660 * Language Environments::   Setting things up for the language you use.
2661 * Input Methods::           Entering text characters not on your keyboard.
2662 * Select Input Method::     Specifying your choice of input methods.
2663 * Mule and Fonts::          Additional font-related issues
2664 * Coding Systems::          Character set conversion when you read and
2665                               write files, and so on.
2666 * Recognize Coding::        How XEmacs figures out which conversion to use.
2667 * Specify Coding::          Various ways to choose which conversion to use.
2668
2669 \1f
2670 File: xemacs.info,  Node: Mule Intro,  Next: Language Environments,  Prev: Mule,  Up: Mule
2671
2672 17.1 What is Mule?
2673 ==================
2674
2675 Mule is the MUltiLingual Extension to XEmacs.  It provides facilities
2676 not only for handling text written in many different languages, but in
2677 fact multilingual texts containing several languages in the same buffer.
2678 This goes beyond the simple facilities offered by Unicode for
2679 representation of multilingual text.  Mule also supports input methods,
2680 composing display using fonts in various different encodings, changing
2681 character syntax and other editing facilities to correspond to local
2682 language usage, and more.
2683
2684    The most obvious problem is that of the different character coding
2685 systems used by different languages.  ASCII supplies all the characters
2686 needed for most computer programming languages and US English (it lacks
2687 the currency symbol for British English), but other Western European
2688 languages (French, Spanish, German) require more than 96 code positions
2689 for accented characters.  In fact, even with 8 bits to represent 96 more
2690 character (including accented characters and symbols such as currency
2691 symbols), some languages' alphabets remain incomplete (Croatian,
2692 Polish).  (The 64 "missing characters" are reserved for control
2693 characters.)  Furthermore, many European languages have their own
2694 alphabets, which must conflict with the accented characters since the
2695 ASCII characters are needed for computer interaction (error and log
2696 messages are typically in ASCII).
2697
2698    For economy of space, historical practice has been for each language
2699 to establish its own encoding for the characters it needs.  This allows
2700 most European languages to represented with one octet (byte) per
2701 character.  However, many Asian languages have thousands of characters
2702 and require two or more octets per character.  For multilingual
2703 purposes, the ISO 2022 standard establishes escape codes that allow
2704 switching encodings in midstream.  (It's also ISO 2022 that establishes
2705 the standard that code points 0-31 and 128-159 are control codes.)
2706
2707    However, this is error-prone and complex for internal processing.
2708 For this reason XEmacs uses an internal coding system which can encode
2709 all of the world's scripts.  Unfortunately, for historical reasons, this
2710 code is not Unicode, although we are moving in that direction.
2711
2712    XEmacs translates between the internal character encoding and various
2713 other coding systems when reading and writing files, when exchanging
2714 data with subprocesses, and (in some cases) in the `C-q' command (see
2715 below).  The internal encoding is never visible to the user in a
2716 production XEmacs, but unfortunately the process cannot be completely
2717 transparent to the user.  This is because the same ranges of octets may
2718 represent 1-octet ISO-8859-1 (which is satisfactory for most Western
2719 European use prior to the introduction of the Euro currency), 1-octet
2720 ISO-8859-15 (which substitutes the Euro for the rarely used "generic
2721 currency" symbol), 1-octet ISO-8859-5 (Cyrillic), or multioctet EUC-JP
2722 (Japanese).  There's no way to tell without being able to read!
2723
2724    A number of heuristics are incorporated in Mule for automatic
2725 recognition, there are facilities for the user to set defaults, and
2726 where necessary (rarely, we hope) to set coding systems directly.
2727
2728    The command `C-h h' (`view-hello-file') displays the file
2729 `etc/HELLO', which shows how to say "hello" in many languages.  This
2730 illustrates various scripts.
2731
2732    Keyboards, even in the countries where these character sets are used,
2733 generally don't have keys for all the characters in them.  So XEmacs
2734 supports various "input methods", typically one for each script or
2735 language, to make it convenient to type them.
2736
2737    The prefix key `C-x <RET>' is used for commands that pertain to
2738 world scripts, coding systems, and input methods.
2739
2740 \1f
2741 File: xemacs.info,  Node: Language Environments,  Next: Input Methods,  Prev: Mule Intro,  Up: Mule
2742
2743 17.2 Language Environments
2744 ==========================
2745
2746 All supported character sets are supported in XEmacs buffers if it is
2747 compiled with Mule; there is no need to select a particular language in
2748 order to display its characters in an XEmacs buffer.  However, it is
2749 important to select a "language environment" in order to set various
2750 defaults.  The language environment really represents a choice of
2751 preferred script (more or less) rather that a choice of language.
2752
2753    The language environment controls which coding systems to recognize
2754 when reading text (*note Recognize Coding::).  This applies to files,
2755 incoming mail, netnews, and any other text you read into XEmacs.  It may
2756 also specify the default coding system to use when you create a file.
2757 Each language environment also specifies a default input method.
2758
2759    The command to select a language environment is `M-x
2760 set-language-environment'.  It makes no difference which buffer is
2761 current when you use this command, because the effects apply globally to
2762 the XEmacs session.  The supported language environments include:
2763
2764      ASCII, Chinese-BIG5, Chinese-GB, Croatian, Cyrillic-ALT,
2765      Cyrillic-ISO, Cyrillic-KOI8, Cyrillic-Win, Czech, English,
2766      Ethiopic, French, German, Greek, Hebrew, IPA, Japanese, Korean,
2767      Latin-1, Latin-2, Latin-3, Latin-4, Latin-5, Norwegian, Polish,
2768      Romanian, Slovenian, Thai-XTIS, Vietnamese.
2769
2770    Some operating systems let you specify the language you are using by
2771 setting locale environment variables.  XEmacs handles one common special
2772 case of this: if your locale name for character types contains the
2773 string `8859-N', XEmacs automatically selects the corresponding
2774 language environment.
2775
2776    To display information about the effects of a certain language
2777 environment LANG-ENV, use the command `C-h L LANG-ENV <RET>'
2778 (`describe-language-environment').  This tells you which languages this
2779 language environment is useful for, and lists the character sets,
2780 coding systems, and input methods that go with it.  It also shows some
2781 sample text to illustrate scripts used in this language environment.
2782 By default, this command describes the chosen language environment.
2783
2784 \1f
2785 File: xemacs.info,  Node: Input Methods,  Next: Select Input Method,  Prev: Language Environments,  Up: Mule
2786
2787 17.3 Input Methods
2788 ==================
2789
2790 An "input method" is a kind of character conversion designed
2791 specifically for interactive input.  In XEmacs, typically each language
2792 has its own input method; sometimes several languages which use the same
2793 characters can share one input method.  A few languages support several
2794 input methods.
2795
2796    The simplest kind of input method works by mapping ASCII letters into
2797 another alphabet.  This is how the Greek and Russian input methods work.
2798
2799    A more powerful technique is composition: converting sequences of
2800 characters into one letter.  Many European input methods use composition
2801 to produce a single non-ASCII letter from a sequence that consists of a
2802 letter followed by accent characters.  For example, some methods convert
2803 the sequence `'a' into a single accented letter.
2804
2805    The input methods for syllabic scripts typically use mapping followed
2806 by composition.  The input methods for Thai and Korean work this way.
2807 First, letters are mapped into symbols for particular sounds or tone
2808 marks; then, sequences of these which make up a whole syllable are
2809 mapped into one syllable sign.
2810
2811    Chinese and Japanese require more complex methods.  In Chinese input
2812 methods, first you enter the phonetic spelling of a Chinese word (in
2813 input method `chinese-py', among others), or a sequence of portions of
2814 the character (input methods `chinese-4corner' and `chinese-sw', and
2815 others).  Since one phonetic spelling typically corresponds to many
2816 different Chinese characters, you must select one of the alternatives
2817 using special XEmacs commands.  Keys such as `C-f', `C-b', `C-n',
2818 `C-p', and digits have special definitions in this situation, used for
2819 selecting among the alternatives.  <TAB> displays a buffer showing all
2820 the possibilities.
2821
2822    In Japanese input methods, first you input a whole word using
2823 phonetic spelling; then, after the word is in the buffer, XEmacs
2824 converts it into one or more characters using a large dictionary.  One
2825 phonetic spelling corresponds to many differently written Japanese
2826 words, so you must select one of them; use `C-n' and `C-p' to cycle
2827 through the alternatives.
2828
2829    Sometimes it is useful to cut off input method processing so that the
2830 characters you have just entered will not combine with subsequent
2831 characters.  For example, in input method `latin-1-postfix', the
2832 sequence `e '' combines to form an `e' with an accent.  What if you
2833 want to enter them as separate characters?
2834
2835    One way is to type the accent twice; that is a special feature for
2836 entering the separate letter and accent.  For example, `e ' '' gives
2837 you the two characters `e''.  Another way is to type another letter
2838 after the `e'--something that won't combine with that--and immediately
2839 delete it.  For example, you could type `e e <DEL> '' to get separate
2840 `e' and `''.
2841
2842    Another method, more general but not quite as easy to type, is to use
2843 `C-\ C-\' between two characters to stop them from combining.  This is
2844 the command `C-\' (`toggle-input-method') used twice.  *Note Select
2845 Input Method::.
2846
2847    `C-\ C-\' is especially useful inside an incremental search, because
2848 stops waiting for more characters to combine, and starts searching for
2849 what you have already entered.
2850
2851    The variables `input-method-highlight-flag' and
2852 `input-method-verbose-flag' control how input methods explain what is
2853 happening.  If `input-method-highlight-flag' is non-`nil', the partial
2854 sequence is highlighted in the buffer.  If `input-method-verbose-flag'
2855 is non-`nil', the list of possible characters to type next is displayed
2856 in the echo area (but not when you are in the minibuffer).
2857
2858 \1f
2859 File: xemacs.info,  Node: Select Input Method,  Next: Mule and Fonts,  Prev: Input Methods,  Up: Mule
2860
2861 17.4 Selecting an Input Method
2862 ==============================
2863
2864 `C-\'
2865      Enable or disable use of the selected input method.
2866
2867 `C-x <RET> C-\ METHOD <RET>'
2868      Select a new input method for the current buffer.
2869
2870 `C-h I METHOD <RET>'
2871 `C-h C-\ METHOD <RET>'
2872      Describe the input method METHOD (`describe-input-method').  By
2873      default, it describes the current input method (if any).
2874
2875 `M-x list-input-methods'
2876      Display a list of all the supported input methods.
2877
2878    To choose an input method for the current buffer, use `C-x <RET>
2879 C-\' (`select-input-method').  This command reads the input method name
2880 with the minibuffer; the name normally starts with the language
2881 environment that it is meant to be used with.  The variable
2882 `current-input-method' records which input method is selected.
2883
2884    Input methods use various sequences of ASCII characters to stand for
2885 non-ASCII characters.  Sometimes it is useful to turn off the input
2886 method temporarily.  To do this, type `C-\' (`toggle-input-method').
2887 To reenable the input method, type `C-\' again.
2888
2889    If you type `C-\' and you have not yet selected an input method, it
2890 prompts for you to specify one.  This has the same effect as using `C-x
2891 <RET> C-\' to specify an input method.
2892
2893    Selecting a language environment specifies a default input method for
2894 use in various buffers.  When you have a default input method, you can
2895 select it in the current buffer by typing `C-\'.  The variable
2896 `default-input-method' specifies the default input method (`nil' means
2897 there is none).
2898
2899    Some input methods for alphabetic scripts work by (in effect)
2900 remapping the keyboard to emulate various keyboard layouts commonly used
2901 for those scripts.  How to do this remapping properly depends on your
2902 actual keyboard layout.  To specify which layout your keyboard has, use
2903 the command `M-x quail-set-keyboard-layout'.
2904
2905    To display a list of all the supported input methods, type `M-x
2906 list-input-methods'.  The list gives information about each input
2907 method, including the string that stands for it in the mode line.
2908
2909 \1f
2910 File: xemacs.info,  Node: Mule and Fonts,  Next: Coding Systems,  Prev: Select Input Method,  Up: Mule
2911
2912 17.5 Mule and Fonts
2913 ===================
2914
2915 (This section is X11-specific.)
2916
2917    Text in XEmacs buffers is displayed using various faces.  In
2918 addition to specifying properties of a face, such as font and color,
2919 there are some additional properties of Mule charsets that are used in
2920 text.
2921
2922    There is currently two properties of a charset that could be
2923 adjusted by user: font registry and so called "ccl-program".
2924
2925    Font registry is a regular expression matching the font registry
2926 field for this character set.  For example, both the `ascii' and
2927 `latin-iso8859-1' charsets use the registry `"ISO8859-1"'.  This field
2928 is used to choose an appropriate font when the user gives a general
2929 font specification such as `-*-courier-medium-r-*-140-*', i.e. a
2930 14-point upright medium-weight Courier font.
2931
2932    You can set font registry for a charset using `set-charset-registry'
2933 function in one of your startup files.  This function takes two
2934 arguments: character set (as a symbol) and font registry (as a string).
2935
2936    E. g., for Cyrillic texts Mule uses `cyrillic-iso8859-5' charset
2937 with `"ISO8859-5"' as a default registry, and we want to use `"koi8-r"'
2938 instead, because fonts in that encoding are installed on our system.
2939 Use:
2940
2941      (set-charset-registry 'cyrillic-iso8859-5 "koi8-r")
2942
2943    (Please note that you probably also want to set font registry for
2944 `ascii' charset so that mixed English/Cyrillic texts be displayed using
2945 the same font.)
2946
2947    "CCL-programs" are a little special-purpose scripts defined within
2948 XEmacs or in some package.  Those scripts allow XEmacs to use fonts that
2949 are in different encoding from the encoding that is used by Mule for
2950 text in buffer.  Returning to the above example, we need to somehow tell
2951 XEmacs that we have different encodings of fonts and text and so it
2952 needs to convert characters between those encodings when displaying.
2953 That's what `set-charset-ccl-program' function is used for.  There are
2954 quite a few various CCL programs defined within XEmacs, and there is no
2955 comprehensive list of them, so you currently have to consult sources.
2956
2957    We know that there is a CCL program called `ccl-encode-koi8-r-font'
2958 that is used exactly for needed purpose: to convert characters between
2959 `ISO8859-5' encoding and `koi8-r'.  Use:
2960
2961      (set-charset-ccl-program 'cyrillic-iso8859-5 'ccl-encode-koi8-r-font)
2962
2963    There are several more uses for CCL programs, not related to fonts,
2964 but those uses are not described here.
2965
2966 \1f
2967 File: xemacs.info,  Node: Coding Systems,  Next: Recognize Coding,  Prev: Mule and Fonts,  Up: Mule
2968
2969 17.6 Coding Systems
2970 ===================
2971
2972 Users of various languages have established many more-or-less standard
2973 coding systems for representing them.  XEmacs does not use these coding
2974 systems internally; instead, it converts from various coding systems to
2975 its own system when reading data, and converts the internal coding
2976 system to other coding systems when writing data.  Conversion is
2977 possible in reading or writing files, in sending or receiving from the
2978 terminal, and in exchanging data with subprocesses.
2979
2980    XEmacs assigns a name to each coding system.  Most coding systems are
2981 used for one language, and the name of the coding system starts with the
2982 language name.  Some coding systems are used for several languages;
2983 their names usually start with `iso'.  There are also special coding
2984 systems `binary' and `no-conversion' which do not convert printing
2985 characters at all.
2986
2987    In addition to converting various representations of non-ASCII
2988 characters, a coding system can perform end-of-line conversion.  XEmacs
2989 handles three different conventions for how to separate lines in a file:
2990 newline, carriage-return linefeed, and just carriage-return.
2991
2992 `C-h C CODING <RET>'
2993      Describe coding system CODING.
2994
2995 `C-h C <RET>'
2996      Describe the coding systems currently in use.
2997
2998 `M-x list-coding-systems'
2999      Display a list of all the supported coding systems.
3000
3001 `C-u M-x list-coding-systems'
3002      Display comprehensive list of specific details of all supported
3003      coding systems.
3004
3005    The command `C-x RET C' (`describe-coding-system') displays
3006 information about particular coding systems.  You can specify a coding
3007 system name as argument; alternatively, with an empty argument, it
3008 describes the coding systems currently selected for various purposes,
3009 both in the current buffer and as the defaults, and the priority list
3010 for recognizing coding systems (*note Recognize Coding::).
3011
3012    To display a list of all the supported coding systems, type `M-x
3013 list-coding-systems'.  The list gives information about each coding
3014 system, including the letter that stands for it in the mode line (*note
3015 Mode Line::).
3016
3017    Each of the coding systems that appear in this list--except for
3018 `binary', which means no conversion of any kind--specifies how and
3019 whether to convert printing characters, but leaves the choice of
3020 end-of-line conversion to be decided based on the contents of each file.
3021 For example, if the file appears to use carriage-return linefeed between
3022 lines, that end-of-line conversion will be used.
3023
3024    Each of the listed coding systems has three variants which specify
3025 exactly what to do for end-of-line conversion:
3026
3027 `...-unix'
3028      Don't do any end-of-line conversion; assume the file uses newline
3029      to separate lines.  (This is the convention normally used on Unix
3030      and GNU systems.)
3031
3032 `...-dos'
3033      Assume the file uses carriage-return linefeed to separate lines,
3034      and do the appropriate conversion.  (This is the convention
3035      normally used on Microsoft systems.)
3036
3037 `...-mac'
3038      Assume the file uses carriage-return to separate lines, and do the
3039      appropriate conversion.  (This is the convention normally used on
3040      the Macintosh system.)
3041
3042    These variant coding systems are omitted from the
3043 `list-coding-systems' display for brevity, since they are entirely
3044 predictable.  For example, the coding system `iso-8859-1' has variants
3045 `iso-8859-1-unix', `iso-8859-1-dos' and `iso-8859-1-mac'.
3046
3047    In contrast, the coding system `binary' specifies no character code
3048 conversion at all--none for non-Latin-1 byte values and none for end of
3049 line.  This is useful for reading or writing binary files, tar files,
3050 and other files that must be examined verbatim.
3051
3052    The easiest way to edit a file with no conversion of any kind is with
3053 the `M-x find-file-literally' command.  This uses `binary', and also
3054 suppresses other XEmacs features that might convert the file contents
3055 before you see them.  *Note Visiting::.
3056
3057    The coding system `no-conversion' means that the file contains
3058 non-Latin-1 characters stored with the internal XEmacs encoding.  It
3059 handles end-of-line conversion based on the data encountered, and has
3060 the usual three variants to specify the kind of end-of-line conversion.
3061
3062 \1f
3063 File: xemacs.info,  Node: Recognize Coding,  Next: Specify Coding,  Prev: Coding Systems,  Up: Mule
3064
3065 17.7 Recognizing Coding Systems
3066 ===============================
3067
3068 Most of the time, XEmacs can recognize which coding system to use for
3069 any given file-once you have specified your preferences.
3070
3071    Some coding systems can be recognized or distinguished by which byte
3072 sequences appear in the data.  However, there are coding systems that
3073 cannot be distinguished, not even potentially.  For example, there is no
3074 way to distinguish between Latin-1 and Latin-2; they use the same byte
3075 values with different meanings.
3076
3077    XEmacs handles this situation by means of a priority list of coding
3078 systems.  Whenever XEmacs reads a file, if you do not specify the coding
3079 system to use, XEmacs checks the data against each coding system,
3080 starting with the first in priority and working down the list, until it
3081 finds a coding system that fits the data.  Then it converts the file
3082 contents assuming that they are represented in this coding system.
3083
3084    The priority list of coding systems depends on the selected language
3085 environment (*note Language Environments::).  For example, if you use
3086 French, you probably want XEmacs to prefer Latin-1 to Latin-2; if you
3087 use Czech, you probably want Latin-2 to be preferred.  This is one of
3088 the reasons to specify a language environment.
3089
3090    However, you can alter the priority list in detail with the command
3091 `M-x prefer-coding-system'.  This command reads the name of a coding
3092 system from the minibuffer, and adds it to the front of the priority
3093 list, so that it is preferred to all others.  If you use this command
3094 several times, each use adds one element to the front of the priority
3095 list.
3096
3097    Sometimes a file name indicates which coding system to use for the
3098 file.  The variable `file-coding-system-alist' specifies this
3099 correspondence.  There is a special function
3100 `modify-coding-system-alist' for adding elements to this list.  For
3101 example, to read and write all `.txt' using the coding system
3102 `china-iso-8bit', you can execute this Lisp expression:
3103
3104      (modify-coding-system-alist 'file "\\.txt\\'" 'china-iso-8bit)
3105
3106 The first argument should be `file', the second argument should be a
3107 regular expression that determines which files this applies to, and the
3108 third argument says which coding system to use for these files.
3109
3110    You can specify the coding system for a particular file using the
3111 `-*-...-*-' construct at the beginning of a file, or a local variables
3112 list at the end (*note File Variables::).  You do this by defining a
3113 value for the "variable" named `coding'.  XEmacs does not really have a
3114 variable `coding'; instead of setting a variable, it uses the specified
3115 coding system for the file.  For example, `-*-mode: C; coding:
3116 iso-8859-1;-*-' specifies use of the iso-8859-1 coding system, as well
3117 as C mode.
3118
3119    Once XEmacs has chosen a coding system for a buffer, it stores that
3120 coding system in `buffer-file-coding-system' and uses that coding
3121 system, by default, for operations that write from this buffer into a
3122 file.  This includes the commands `save-buffer' and `write-region'.  If
3123 you want to write files from this buffer using a different coding
3124 system, you can specify a different coding system for the buffer using
3125 `set-buffer-file-coding-system' (*note Specify Coding::).
3126
3127 \1f
3128 File: xemacs.info,  Node: Specify Coding,  Prev: Recognize Coding,  Up: Mule
3129
3130 17.8 Specifying a Coding System
3131 ===============================
3132
3133 In cases where XEmacs does not automatically choose the right coding
3134 system, you can use these commands to specify one:
3135
3136 `C-x <RET> f CODING <RET>'
3137      Use coding system CODING for the visited file in the current
3138      buffer.
3139
3140 `C-x <RET> c CODING <RET>'
3141      Specify coding system CODING for the immediately following command.
3142
3143 `C-x <RET> k CODING <RET>'
3144      Use coding system CODING for keyboard input.  (This feature is
3145      non-functional and is temporarily disabled.)
3146
3147 `C-x <RET> t CODING <RET>'
3148      Use coding system CODING for terminal output.
3149
3150 `C-x <RET> p CODING <RET>'
3151      Use coding system CODING for subprocess input and output in the
3152      current buffer.
3153
3154    The command `C-x RET f' (`set-buffer-file-coding-system') specifies
3155 the file coding system for the current buffer--in other words, which
3156 coding system to use when saving or rereading the visited file.  You
3157 specify which coding system using the minibuffer.  Since this command
3158 applies to a file you have already visited, it affects only the way the
3159 file is saved.
3160
3161    Another way to specify the coding system for a file is when you visit
3162 the file.  First use the command `C-x <RET> c'
3163 (`universal-coding-system-argument'); this command uses the minibuffer
3164 to read a coding system name.  After you exit the minibuffer, the
3165 specified coding system is used for _the immediately following command_.
3166
3167    So if the immediately following command is `C-x C-f', for example,
3168 it reads the file using that coding system (and records the coding
3169 system for when the file is saved).  Or if the immediately following
3170 command is `C-x C-w', it writes the file using that coding system.
3171 Other file commands affected by a specified coding system include `C-x
3172 C-i' and `C-x C-v', as well as the other-window variants of `C-x C-f'.
3173
3174    In addition, if you run some file input commands with the precedent
3175 `C-u', you can specify coding system to read from minibuffer.  So if
3176 the immediately following command is `C-x C-f', for example, it reads
3177 the file using that coding system (and records the coding system for
3178 when the file is saved).  Other file commands affected by a specified
3179 coding system include `C-x C-i' and `C-x C-v', as well as the
3180 other-window variants of `C-x C-f'.
3181
3182    The variable `default-buffer-file-coding-system' specifies the
3183 choice of coding system to use when you create a new file.  It applies
3184 when you find a new file, and when you create a buffer and then save it
3185 in a file.  Selecting a language environment typically sets this
3186 variable to a good choice of default coding system for that language
3187 environment.
3188
3189    The command `C-x <RET> t' (`set-terminal-coding-system') specifies
3190 the coding system for terminal output.  If you specify a character code
3191 for terminal output, all characters output to the terminal are
3192 translated into that coding system.
3193
3194    This feature is useful for certain character-only terminals built to
3195 support specific languages or character sets--for example, European
3196 terminals that support one of the ISO Latin character sets.
3197
3198    By default, output to the terminal is not translated at all.
3199
3200    The command `C-x <RET> k' (`set-keyboard-coding-system') specifies
3201 the coding system for keyboard input.  Character-code translation of
3202 keyboard input is useful for terminals with keys that send non-ASCII
3203 graphic characters--for example, some terminals designed for ISO
3204 Latin-1 or subsets of it.
3205
3206    By default, keyboard input is not translated at all.
3207
3208    There is a similarity between using a coding system translation for
3209 keyboard input, and using an input method: both define sequences of
3210 keyboard input that translate into single characters.  However, input
3211 methods are designed to be convenient for interactive use by humans, and
3212 the sequences that are translated are typically sequences of ASCII
3213 printing characters.  Coding systems typically translate sequences of
3214 non-graphic characters.
3215
3216    (This feature is non-functional and is temporarily disabled.)
3217
3218    The command `C-x <RET> p' (`set-buffer-process-coding-system')
3219 specifies the coding system for input and output to a subprocess.  This
3220 command applies to the current buffer; normally, each subprocess has its
3221 own buffer, and thus you can use this command to specify translation to
3222 and from a particular subprocess by giving the command in the
3223 corresponding buffer.
3224
3225    By default, process input and output are not translated at all.
3226
3227    The variable `file-name-coding-system' specifies a coding system to
3228 use for encoding file names.  If you set the variable to a coding
3229 system name (as a Lisp symbol or a string), XEmacs encodes file names
3230 using that coding system for all file operations.  This makes it
3231 possible to use non-Latin-1 characters in file names--or, at least,
3232 those non-Latin-1 characters which the specified coding system can
3233 encode.  By default, this variable is `nil', which implies that you
3234 cannot use non-Latin-1 characters in file names.
3235
3236 \1f
3237 File: xemacs.info,  Node: Major Modes,  Next: Indentation,  Prev: Mule,  Up: Top
3238
3239 18 Major Modes
3240 **************
3241
3242 Emacs has many different "major modes", each of which customizes Emacs
3243 for editing text of a particular sort.  The major modes are mutually
3244 exclusive;  at any time, each buffer has one major mode.  The mode line
3245 normally contains the name of the current major mode in parentheses.
3246 *Note Mode Line::.
3247
3248    The least specialized major mode is called "Fundamental mode".  This
3249 mode has no mode-specific redefinitions or variable settings.  Each
3250 Emacs command behaves in its most general manner, and each option is in
3251 its default state.  For editing any specific type of text, such as Lisp
3252 code or English text, you should switch to the appropriate major mode,
3253 such as Lisp mode or Text mode.
3254
3255    Selecting a major mode changes the meanings of a few keys to become
3256 more specifically adapted to the language being edited.  <TAB>, <DEL>,
3257 and <LFD> are changed frequently.  In addition, commands which handle
3258 comments use the mode to determine how to delimit comments.  Many major
3259 modes redefine the syntactical properties of characters appearing in
3260 the buffer.  *Note Syntax::.
3261
3262    The major modes fall into three major groups.  Programming modes
3263 (*note Programs::) are for specific programming languages.  Text modes
3264 (like Nroff mode, TeX mode, Outline mode, XML mode, etc.) are for
3265 editing human readable text.  The remaining major modes are not intended
3266 for direct use in editing user files; they are used in buffers created
3267 by Emacs for specific purposes. Examples of such modes include Dired
3268 mode which is used for buffers made by Dired (*note Dired::), Mail mode
3269 for buffers made by `C-x m' (*note Sending Mail::), and Shell mode for
3270 buffers used for communicating with an inferior shell process (*note
3271 Interactive Shell::).
3272
3273    Most programming language major modes specify that only blank lines
3274 separate paragraphs.  This is so that the paragraph commands remain
3275 useful.  *Note Paragraphs::.  They also cause Auto Fill mode to use the
3276 definition of <TAB> to indent the new lines it creates.  This is
3277 because most lines in a program are usually indented.  *Note
3278 Indentation::.
3279
3280 * Menu:
3281
3282 * Choosing Modes::     How major modes are specified or chosen.
3283 * Mode Hooks::         Customizing a major mode
3284
3285 \1f
3286 File: xemacs.info,  Node: Choosing Modes,  Next: Mode Hooks,  Prev: Major Modes,  Up: Major Modes
3287
3288 18.1 Choosing Major Modes
3289 =========================
3290
3291 You can select a major mode explicitly for the current buffer, but most
3292 of the time Emacs determines which mode to use based on the file name
3293 or some text in the file.
3294
3295    Use a `M-x' command to explicitly select a new major mode.  Add
3296 `-mode' to the name of a major mode to get the name of a command to
3297 select that mode.  For example, to enter Lisp mode, execute `M-x
3298 lisp-mode'.
3299
3300    When you visit a file, Emacs usually chooses the right major mode
3301 based on the file's name.  For example, files whose names end in `.c'
3302 are edited in C mode.  The variable `auto-mode-alist' controls the
3303 correspondence between file names and major mode.  Its value is a list
3304 in which each element has the form:
3305
3306      (REGEXP . MODE-FUNCTION)
3307
3308 For example, one element normally found in the list has the form
3309 `("\\.c$" . c-mode)'. It is responsible for selecting C mode for files
3310 whose names end in `.c'.  (Note that `\\' is needed in Lisp syntax to
3311 include a `\' in the string, which is needed to suppress the special
3312 meaning of `.' in regexps.)  The only practical way to change this
3313 variable is with Lisp code.
3314
3315    You can specify which major mode should be used for editing a certain
3316 file by a special sort of text in the first non-blank line of the file.
3317 The mode name should appear in this line both preceded and followed by
3318 `-*-'.  Other text may appear on the line as well.  For example,
3319
3320      ;-*-Lisp-*-
3321
3322 tells Emacs to use Lisp mode.  Note how the semicolon is used to make
3323 Lisp treat this line as a comment.  Such an explicit specification
3324 overrides any default mode based on the file name.
3325
3326    Another format of mode specification is:
3327
3328      -*-Mode: MODENAME;-*-
3329
3330 which allows other things besides the major mode name to be specified.
3331 However, Emacs does not look for anything except the mode name.
3332
3333    The major mode can also be specified in a local variables list.
3334 *Note File Variables::.
3335
3336    When you visit a file that does not specify a major mode to use, or
3337 when you create a new buffer with `C-x b', Emacs uses the major mode
3338 specified by the variable `default-major-mode'.  Normally this value is
3339 the symbol `fundamental-mode', which specifies Fundamental mode.  If
3340 `default-major-mode' is `nil', the major mode is taken from the
3341 previously selected buffer.
3342
3343 \1f
3344 File: xemacs.info,  Node: Mode Hooks,  Prev: Choosing Modes,  Up: Major Modes
3345
3346 18.2 Mode Hook Variables
3347 ========================
3348
3349 The last step taken by a major mode, by convention, is to invoke a list
3350 of user supplied functions that are stored in a "hook" variable.  This
3351 allows a user to further customize the major mode, and is particularly
3352 convenient for setting up buffer local variables (*note Locals::).
3353
3354    The name of the hook variable is created by appending the string
3355 `-hook' to the name of the major mode.  For example, the hook variable
3356 used by `text-mode' would be named `text-mode-hook'.  By convention the
3357 mode hook function receives no arguments. If a hook variable does not
3358 exist, or it has the value `nil', the major mode simply ignores it.
3359
3360    The recommended way to add functions to a hook variable is with the
3361 `add-hook' function.  For example, to automatically turn on the Auto
3362 Fill mode when Text mode is invoked the following code can be used in
3363 the initialization file (*note Init File::)
3364
3365      (add-hook 'text-mode-hook 'turn-on-auto-fill)
3366
3367    The `add-hook' function will check that the function is not already
3368 listed in the hook variable before adding it. It will also create a hook
3369 variable with the value `nil' if one does not exist before adding the
3370 function. `add-hook' adds functions to the front of the hook variable
3371 list. This means that the last hook added is run first by the major
3372 mode. It is considered very poor style to write hook functions that
3373 depend on the order that hooks are executed.
3374
3375    Hooks can be removed from hook variables with `remove-hook'.
3376
3377 \1f
3378 File: xemacs.info,  Node: Indentation,  Next: Text,  Prev: Major Modes,  Up: Top
3379
3380 19 Indentation
3381 **************
3382
3383 `<TAB>'
3384      Indent current line "appropriately" in a mode-dependent fashion.
3385
3386 `<LFD>'
3387      Perform <RET> followed by <TAB> (`newline-and-indent').
3388
3389 `M-^'
3390      Merge two lines (`delete-indentation').  This would cancel out the
3391      effect of <LFD>.
3392
3393 `C-M-o'
3394      Split line at point; text on the line after point becomes a new
3395      line indented to the same column that it now starts in
3396      (`split-line').
3397
3398 `M-m'
3399      Move (forward or back) to the first non-blank character on the
3400      current line (`back-to-indentation').
3401
3402 `C-M-\'
3403      Indent several lines to same column (`indent-region').
3404
3405 `C-x <TAB>'
3406      Shift block of lines rigidly right or left (`indent-rigidly').
3407
3408 `M-i'
3409      Indent from point to the next prespecified tab stop column
3410      (`tab-to-tab-stop').
3411
3412 `M-x indent-relative'
3413      Indent from point to under an indentation point in the previous
3414      line.
3415
3416    Most programming languages have some indentation convention.  For
3417 Lisp code, lines are indented according to their nesting in
3418 parentheses.  The same general idea is used for C code, though details
3419 differ.
3420
3421    Use the <TAB> command to indent a line whatever the language.  Each
3422 major mode defines this command to perform indentation appropriate for
3423 the particular language.  In Lisp mode, <TAB> aligns a line according
3424 to its depth in parentheses.  No matter where in the line you are when
3425 you type <TAB>, it aligns the line as a whole.  In C mode, <TAB>
3426 implements a subtle and sophisticated indentation style that knows
3427 about many aspects of C syntax.
3428
3429    In Text mode, <TAB> runs the command `tab-to-tab-stop', which
3430 indents to the next tab stop column.  You can set the tab stops with
3431 `M-x edit-tab-stops'.
3432
3433 * Menu:
3434
3435 * Indentation Commands:: Various commands and techniques for indentation.
3436 * Tab Stops::            You can set arbitrary "tab stops" and then
3437                          indent to the next tab stop when you want to.
3438 * Just Spaces::          You can request indentation using just spaces.
3439
3440 \1f
3441 File: xemacs.info,  Node: Indentation Commands,  Next: Tab Stops,  Prev: Indentation,  Up: Indentation
3442
3443 19.1 Indentation Commands and Techniques
3444 ========================================
3445
3446 If you just want to insert a tab character in the buffer, you can type
3447 `C-q <TAB>'.
3448
3449    To move over the indentation on a line, type `Meta-m'
3450 (`back-to-indentation').  This command, given anywhere on a line,
3451 positions point at the first non-blank character on the line.
3452
3453    To insert an indented line before the current line, type `C-a C-o
3454 <TAB>'.  To make an indented line after the current line, use `C-e
3455 <LFD>'.
3456
3457    `C-M-o' (`split-line') moves the text from point to the end of the
3458 line vertically down, so that the current line becomes two lines.
3459 `C-M-o' first moves point forward over any spaces and tabs.  Then it
3460 inserts after point a newline and enough indentation to reach the same
3461 column point is on.  Point remains before the inserted newline; in this
3462 regard, `C-M-o' resembles `C-o'.
3463
3464    To join two lines cleanly, use the `Meta-^' (`delete-indentation')
3465 command to delete the indentation at the front of the current line, and
3466 the line boundary as well.  Empty spaces are replaced by a single
3467 space, or by no space if at the beginning of a line, before a close
3468 parenthesis, or after an open parenthesis.  To delete just the
3469 indentation of a line, go to the beginning of the line and use `Meta-\'
3470 (`delete-horizontal-space'), which deletes all spaces and tabs around
3471 the cursor.
3472
3473    There are also commands for changing the indentation of several
3474 lines at once.  `Control-Meta-\' (`indent-region') gives each line which
3475 begins in the region the "usual" indentation by invoking <TAB> at the
3476 beginning of the line.  A numeric argument specifies the column to
3477 indent to.  Each line is shifted left or right so that its first
3478 non-blank character appears in that column.  `C-x <TAB>'
3479 (`indent-rigidly') moves all the lines in the region right by its
3480 argument (left, for negative arguments).  The whole group of lines moves
3481 rigidly sideways, which is how the command gets its name.
3482
3483    `M-x indent-relative' indents at point based on the previous line
3484 (actually, the last non-empty line.)  It inserts whitespace at point,
3485 moving point, until it is underneath an indentation point in the
3486 previous line.  An indentation point is the end of a sequence of
3487 whitespace or the end of the line.  If point is farther right than any
3488 indentation point in the previous line, the whitespace before point is
3489 deleted and the first indentation point then applicable is used.  If no
3490 indentation point is applicable even then, `tab-to-tab-stop' is run
3491 (see next section).
3492
3493    `indent-relative' is the definition of <TAB> in Indented Text mode.
3494 *Note Text::.
3495
3496 \1f
3497 File: xemacs.info,  Node: Tab Stops,  Next: Just Spaces,  Prev: Indentation Commands,  Up: Indentation
3498
3499 19.2 Tab Stops
3500 ==============
3501
3502 For typing in tables, you can use Text mode's definition of <TAB>,
3503 `tab-to-tab-stop'.  This command inserts indentation before point,
3504 enough to reach the next tab stop column.  Even if you are not in Text
3505 mode, this function is associated with `M-i' anyway.
3506
3507    You can arbitrarily set the tab stops used by `M-i'.  They are
3508 stored as a list of column-numbers in increasing order in the variable
3509 `tab-stop-list'.
3510
3511    The convenient way to set the tab stops is using `M-x
3512 edit-tab-stops', which creates and selects a buffer containing a
3513 description of the tab stop settings.  You can edit this buffer to
3514 specify different tab stops, and then type `C-c C-c' to make those new
3515 tab stops take effect.  In the tab stop buffer, `C-c C-c' runs the
3516 function `edit-tab-stops-note-changes' rather than the default
3517 `save-buffer'.  `edit-tab-stops' records which buffer was current when
3518 you invoked it, and stores the tab stops in that buffer.  Normally all
3519 buffers share the same tab stops and changing them in one buffer
3520 affects all.  If you make `tab-stop-list' local in one buffer
3521 `edit-tab-stops' in that buffer edits only the local settings.
3522
3523    Below is the text representing ordinary tab stops every eight
3524 columns:
3525
3526              :       :       :       :       :       :
3527      0         1         2         3         4
3528      0123456789012345678901234567890123456789012345678
3529      To install changes, type C-c C-c
3530
3531    The first line contains a colon at each tab stop.  The remaining
3532 lines help you see where the colons are and tell you what to do.
3533
3534    Note that the tab stops that control `tab-to-tab-stop' have nothing
3535 to do with displaying tab characters in the buffer.  *Note Display
3536 Vars::, for more information on that.
3537
3538 \1f
3539 File: xemacs.info,  Node: Just Spaces,  Prev: Tab Stops,  Up: Indentation
3540
3541 19.3 Tabs vs. Spaces
3542 ====================
3543
3544 Emacs normally uses both tabs and spaces to indent lines.  If you
3545 prefer, all indentation can be made from spaces only.  To request this,
3546 set `indent-tabs-mode' to `nil'.  This is a per-buffer variable;
3547 altering the variable affects only the current buffer, but there is a
3548 default value which you can change as well.  *Note Locals::.
3549
3550    There are also commands to convert tabs to spaces or vice versa,
3551 always preserving the columns of all non-blank text.  `M-x tabify'
3552 scans the region for sequences of spaces, and converts sequences of at
3553 least three spaces to tabs if that is possible without changing
3554 indentation.  `M-x untabify' changes all tabs in the region to
3555 corresponding numbers of spaces.
3556
3557 \1f
3558 File: xemacs.info,  Node: Text,  Next: Programs,  Prev: Indentation,  Up: Top
3559
3560 20 Commands for Human Languages
3561 *******************************
3562
3563 The term "text" has two widespread meanings in our area of the computer
3564 field.  One is data that is a sequence of characters.  In this sense of
3565 the word any file that you edit with Emacs is text.  The other meaning
3566 is more restrictive: a sequence of characters in a human language for
3567 humans to read (possibly after processing by a text formatter), as
3568 opposed to a program or commands for a program.
3569
3570    Human languages have syntactic and stylistic conventions that editor
3571 commands should support or use to advantage: conventions involving
3572 words, sentences, paragraphs, and capital letters.  This chapter
3573 describes Emacs commands for all these things.  There are also commands
3574 for "filling", or rearranging paragraphs into lines of approximately
3575 equal length.  The commands for moving over and killing words,
3576 sentences, and paragraphs, while intended primarily for editing text,
3577 are also often useful for editing programs.
3578
3579    Emacs has several major modes for editing human language text.  If a
3580 file contains plain text, use Text mode, which customizes Emacs in
3581 small ways for the syntactic conventions of text.  For text which
3582 contains embedded commands for text formatters, Emacs has other major
3583 modes, each for a particular text formatter.  Thus, for input to TeX,
3584 you can use TeX mode; for input to nroff, Nroff mode.
3585
3586 * Menu:
3587
3588 * Text Mode::   The major modes for editing text files.
3589 * Nroff Mode::  The major mode for editing input to the formatter nroff.
3590 * TeX Mode::    The major modes for editing input to the formatter TeX.
3591 * Outline Mode:: The major mode for editing outlines.
3592 * Words::       Moving over and killing words.
3593 * Sentences::   Moving over and killing sentences.
3594 * Paragraphs::  Moving over paragraphs.
3595 * Pages::       Moving over pages.
3596 * Filling::     Filling or justifying text
3597 * Case::        Changing the case of text
3598
3599 \1f
3600 File: xemacs.info,  Node: Text Mode,  Next: Words,  Prev: Text,  Up: Text
3601
3602 20.1 Text Mode
3603 ==============
3604
3605 You should use Text mode--rather than Fundamental or Lisp mode--to edit
3606 files of text in a human language.  Invoke `M-x text-mode' to enter
3607 Text mode.  In Text mode, <TAB> runs the function `tab-to-tab-stop',
3608 which allows you to use arbitrary tab stops set with `M-x
3609 edit-tab-stops' (*note Tab Stops::).  Features concerned with comments
3610 in programs are turned off unless they are explicitly invoked.  The
3611 syntax table is changed so that periods are not considered part of a
3612 word, while apostrophes, backspaces and underlines are.
3613
3614    A similar variant mode is Indented Text mode, intended for editing
3615 text in which most lines are indented.  This mode defines <TAB> to run
3616 `indent-relative' (*note Indentation::), and makes Auto Fill indent the
3617 lines it creates.  As a result, a line made by Auto Filling, or by
3618 <LFD>, is normally indented just like the previous line.  Use `M-x
3619 indented-text-mode' to select this mode.
3620
3621    Entering Text mode or Indented Text mode calls the value of the
3622 variable `text-mode-hook' with no arguments, if that value exists and
3623 is not `nil'.  This value is also called when modes related to Text
3624 mode are entered; this includes Nroff mode, TeX mode, Outline mode, and
3625 Mail mode.  Your hook can look at the value of `major-mode' to see
3626 which of these modes is actually being entered.
3627
3628    Two modes similar to Text mode are of use for editing text that is to
3629 be passed through a text formatter before achieving its final readable
3630 form.
3631
3632 * Menu:
3633
3634 * Nroff Mode::  The major mode for editing input to the formatter nroff.
3635 * TeX Mode::    The major modes for editing input to the formatter TeX.
3636
3637
3638   Another similar mode is used for editing outlines.  It allows you
3639 to view the text at various levels of detail.  You can view either
3640 the outline headings alone or both headings and text; you can also
3641 hide some of the headings at lower levels from view to make the high
3642 level structure more visible.
3643
3644
3645 * Outline Mode:: The major mode for editing outlines.
3646
3647 \1f
3648 File: xemacs.info,  Node: Nroff Mode,  Next: TeX Mode,  Prev: Text Mode,  Up: Text Mode
3649
3650 20.1.1 Nroff Mode
3651 -----------------
3652
3653 Nroff mode is a mode like Text mode but modified to handle nroff
3654 commands present in the text.  Invoke `M-x nroff-mode' to enter this
3655 mode.  Nroff mode differs from Text mode in only a few ways.  All nroff
3656 command lines are considered paragraph separators, so that filling never
3657 garbles the nroff commands.  Pages are separated by `.bp' commands.
3658 Comments start with backslash-doublequote.  There are also three special
3659 commands that are not available in Text mode:
3660
3661 `M-n'
3662      Move to the beginning of the next line that isn't an nroff command
3663      (`forward-text-line').  An argument is a repeat count.
3664
3665 `M-p'
3666      Like `M-n' but move up (`backward-text-line').
3667
3668 `M-?'
3669      Prints in the echo area the number of text lines (lines that are
3670      not nroff commands) in the region (`count-text-lines').
3671
3672    The other feature of Nroff mode is Electric Nroff newline mode.
3673 This is a minor mode that you can turn on or off with `M-x
3674 electric-nroff-mode' (*note Minor Modes::).  When the mode is on and
3675 you use <RET> to end a line containing an nroff command that opens a
3676 kind of grouping, Emacs automatically inserts the matching nroff
3677 command to close that grouping on the following line.  For example, if
3678 you are at the beginning of a line and type `.(b <RET>', the matching
3679 command `.)b' will be inserted on a new line following point.
3680
3681    Entering Nroff mode calls the value of the variable `text-mode-hook'
3682 with no arguments, if that value exists and is not `nil'; then it does
3683 the same with the variable `nroff-mode-hook'.
3684
3685 \1f
3686 File: xemacs.info,  Node: TeX Mode,  Next: Outline Mode,  Prev: Nroff Mode,  Up: Text Mode
3687
3688 20.1.2 TeX Mode
3689 ---------------
3690
3691 TeX is a powerful text formatter written by Donald Knuth; like GNU
3692 Emacs, it is free.  LaTeX is a simplified input format for TeX,
3693 implemented by TeX macros.  It is part of TeX.
3694
3695    Emacs has a special TeX mode for editing TeX input files.  It
3696 provides facilities for checking the balance of delimiters and for
3697 invoking TeX on all or part of the file.
3698
3699    TeX mode has two variants, Plain TeX mode and LaTeX mode, which are
3700 two distinct major modes that differ only slightly.  These modes are
3701 designed for editing the two different input formats.  The command `M-x
3702 tex-mode' looks at the contents of a buffer to determine whether it
3703 appears to be LaTeX input or not; it then selects the appropriate mode.
3704 If it can't tell which is right (e.g., the buffer is empty), the
3705 variable `tex-default-mode' controls which mode is used.
3706
3707    The commands `M-x plain-tex-mode' and `M-x latex-mode' explicitly
3708 select one of the variants of TeX mode.  Use these commands when `M-x
3709 tex-mode' does not guess right.
3710
3711 * Menu:
3712
3713 * Editing: TeX Editing.   Special commands for editing in TeX mode.
3714 * Printing: TeX Print.    Commands for printing part of a file with TeX.
3715
3716    TeX for Unix systems can be obtained from the University of
3717 Washington for a distribution fee.
3718
3719    To order a full distribution, send $140.00 for a 1/2 inch 9-track
3720 tape, $165.00 for two 4-track 1/4 inch cartridge tapes (foreign sites
3721 $150.00, for 1/2 inch, $175.00 for 1/4 inch, to cover the extra
3722 postage) payable to the University of Washington to:
3723
3724      The Director
3725      Northwest Computer Support Group,  DW-10
3726      University of Washington
3727      Seattle, Washington 98195
3728
3729 Purchase orders are acceptable, but there is an extra charge of $10.00
3730 to pay for processing charges. (The total cost comes to $150 for
3731 domestic sites, $175 for foreign sites).
3732
3733    The normal distribution is a tar tape, blocked 20, 1600 bpi, on an
3734 industry standard 2400 foot half-inch reel.  The physical format for
3735 the 1/4 inch streamer cartridges uses QIC-11, 8000 bpi, 4-track
3736 serpentine recording for the SUN.  Also, SystemV tapes can be written
3737 in cpio format, blocked 5120 bytes, ASCII headers.
3738
3739 \1f
3740 File: xemacs.info,  Node: TeX Editing,  Next: TeX Print,  Prev: TeX Mode,  Up: TeX Mode
3741
3742 20.1.2.1 TeX Editing Commands
3743 .............................
3744
3745 Here are the special commands provided in TeX mode for editing the text
3746 of the file.
3747
3748 `"'
3749      Insert, according to context, either ```' or `"' or `'''
3750      (`TeX-insert-quote').
3751
3752 `<LFD>'
3753      Insert a paragraph break (two newlines) and check the previous
3754      paragraph for unbalanced braces or dollar signs (`tex-terminate-
3755      paragraph').
3756
3757 `M-x validate-tex-buffer'
3758      Check each paragraph in the buffer for unbalanced braces or dollar
3759      signs.
3760
3761 `C-c {'
3762      Insert `{}' and position point between them (`tex-insert-braces').
3763
3764 `C-c }'
3765      Move forward past the next unmatched close brace (`up-list').
3766
3767 `C-c C-e'
3768      Close a block for LaTeX (`tex-close-latex-block').
3769
3770    In TeX, the character `"' is not normally used; you use ```' to
3771 start a quotation and `''' to end one.  TeX mode defines the key `"' to
3772 insert ```' after whitespace or an open brace, `"' after a backslash,
3773 or `''' otherwise.  This is done by the command `tex-insert-quote'.  If
3774 you need the character `"' itself in unusual contexts, use `C-q' to
3775 insert it.  Also, `"' with a numeric argument always inserts that
3776 number of `"' characters.
3777
3778    In TeX mode, `$' has a special syntax code which attempts to
3779 understand the way TeX math mode delimiters match.  When you insert a
3780 `$' that is meant to exit math mode, the position of the matching `$'
3781 that entered math mode is displayed for a second.  This is the same
3782 feature that displays the open brace that matches a close brace that is
3783 inserted.  However, there is no way to tell whether a `$' enters math
3784 mode or leaves it; so when you insert a `$' that enters math mode, the
3785 previous `$' position is shown as if it were a match, even though they
3786 are actually unrelated.
3787
3788    If you prefer to keep braces balanced at all times, you can use `C-c
3789 {' (`tex-insert-braces') to insert a pair of braces.  It leaves point
3790 between the two braces so you can insert the text that belongs inside.
3791 Afterward, use the command `C-c }' (`up-list') to move forward past the
3792 close brace.
3793
3794    There are two commands for checking the matching of braces.  <LFD>
3795 (`tex-terminate-paragraph') checks the paragraph before point, and
3796 inserts two newlines to start a new paragraph.  It prints a message in
3797 the echo area if any mismatch is found.  `M-x validate-tex-buffer'
3798 checks the entire buffer, paragraph by paragraph.  When it finds a
3799 paragraph that contains a mismatch, it displays point at the beginning
3800 of the paragraph for a few seconds and pushes a mark at that spot.
3801 Scanning continues until the whole buffer has been checked or until you
3802 type another key.  The positions of the last several paragraphs with
3803 mismatches can be found in the mark ring (*note Mark Ring::).
3804
3805    Note that square brackets and parentheses, not just braces, are
3806 matched in TeX mode.  This is wrong if you want to  check TeX syntax.
3807 However, parentheses and square brackets are likely to be used in text
3808 as matching delimiters and it is useful for the various motion commands
3809 and automatic match display to work with them.
3810
3811    In LaTeX input, `\begin' and `\end' commands must balance.  After
3812 you insert a `\begin', use `C-c C-f' (`tex-close-latex-block') to
3813 insert automatically a matching `\end' (on a new line following the
3814 `\begin').  A blank line is inserted between the two, and point is left
3815 there.
3816
3817 \1f
3818 File: xemacs.info,  Node: TeX Print,  Prev: TeX Editing,  Up: TeX Mode
3819
3820 20.1.2.2 TeX Printing Commands
3821 ..............................
3822
3823 You can invoke TeX as an inferior of Emacs on either the entire
3824 contents of the buffer or just a region at a time.  Running TeX in this
3825 way on just one chapter is a good way to see what your changes look
3826 like without taking the time to format the entire file.
3827
3828 `C-c C-r'
3829      Invoke TeX on the current region, plus the buffer's header
3830      (`tex-region').
3831
3832 `C-c C-b'
3833      Invoke TeX on the entire current buffer (`tex-buffer').
3834
3835 `C-c C-l'
3836      Recenter the window showing output from the inferior TeX so that
3837      the last line can be seen (`tex-recenter-output-buffer').
3838
3839 `C-c C-k'
3840      Kill the inferior TeX (`tex-kill-job').
3841
3842 `C-c C-p'
3843      Print the output from the last `C-c C-r' or `C-c C-b' command
3844      (`tex-print').
3845
3846 `C-c C-q'
3847      Show the printer queue (`tex-show-print-queue').
3848
3849    You can pass the current buffer through an inferior TeX using `C-c
3850 C-b' (`tex-buffer').  The formatted output appears in a file in `/tmp';
3851 to print it, type `C-c C-p' (`tex-print').  Afterward use `C-c C-q'
3852 (`tex-show-print-queue') to view the progress of your output towards
3853 being printed.
3854
3855    The console output from TeX, including any error messages, appears
3856 in a buffer called `*TeX-shell*'.  If TeX gets an error, you can switch
3857 to this buffer and feed it input (this works as in Shell mode; *note
3858 Interactive Shell::).  Without switching to this buffer, you can scroll
3859 it so that its last line is visible by typing `C-c C-l'.
3860
3861    Type `C-c C-k' (`tex-kill-job') to kill the TeX process if you see
3862 that its output is no longer useful.  Using `C-c C-b' or `C-c C-r' also
3863 kills any TeX process still running.
3864
3865    You can pass an arbitrary region through an inferior TeX by typing
3866 `C-c C-r' (`tex-region').  This is tricky, however, because most files
3867 of TeX input contain commands at the beginning to set parameters and
3868 define macros.  Without them, no later part of the file will format
3869 correctly.  To solve this problem, `C-c C-r' allows you to designate a
3870 part of the file as containing essential commands; it is included
3871 before the specified region as part of the input to TeX.  The
3872 designated part of the file is called the "header".
3873
3874    To indicate the bounds of the header in Plain TeX mode, insert two
3875 special strings in the file: `%**start of header' before the header,
3876 and `%**end of header' after it.  Each string must appear entirely on
3877 one line, but there may be other text on the line before or after.  The
3878 lines containing the two strings are included in the header.  If
3879 `%**start of header' does not appear within the first 100 lines of the
3880 buffer, `C-c C-r' assumes there is no header.
3881
3882    In LaTeX mode, the header begins with `\documentstyle' and ends with
3883 `\begin{document}'.  These are commands that LaTeX requires you to use,
3884 so you don't need to do anything special to identify the header.
3885
3886    When you enter either kind of TeX mode, Emacs calls with no
3887 arguments the value of the variable `text-mode-hook', if that value
3888 exists and is not `nil'.  Emacs then calls the variable `TeX-mode-hook'
3889 and either `plain-TeX-mode-hook' or `LaTeX-mode-hook' under the same
3890 conditions.
3891
3892 \1f
3893 File: xemacs.info,  Node: Outline Mode,  Prev: TeX Mode,  Up: Text Mode
3894
3895 20.1.3 Outline Mode
3896 -------------------
3897
3898 Outline mode is a major mode similar to Text mode but intended for
3899 editing outlines.  It allows you to make parts of the text temporarily
3900 invisible so that you can see just the overall structure of the
3901 outline.  Type `M-x outline-mode' to turn on Outline mode in the
3902 current buffer.
3903
3904    When you enter Outline mode, Emacs calls with no arguments the value
3905 of the variable `text-mode-hook', if that value exists and is not
3906 `nil'; then it does the same with the variable `outline-mode-hook'.
3907
3908    When a line is invisible in outline mode, it does not appear on the
3909 screen.  The screen appears exactly as if the invisible line were
3910 deleted, except that an ellipsis (three periods in a row) appears at
3911 the end of the previous visible line (only one ellipsis no matter how
3912 many invisible lines follow).
3913
3914    All editing commands treat the text of the invisible line as part of
3915 the previous visible line.  For example, `C-n' moves onto the next
3916 visible line.  Killing an entire visible line, including its
3917 terminating newline, really kills all the following invisible lines as
3918 well; yanking everything back yanks the invisible lines and they remain
3919 invisible.
3920
3921 * Menu:
3922
3923 * Format: Outline Format.         What the text of an outline looks like.
3924 * Motion: Outline Motion.         Special commands for moving through outlines.
3925 * Visibility: Outline Visibility. Commands to control what is visible.
3926
3927 \1f
3928 File: xemacs.info,  Node: Outline Format,  Next: Outline Motion,  Prev: Outline Mode,  Up: Outline Mode
3929
3930 20.1.3.1 Format of Outlines
3931 ...........................
3932
3933 Outline mode assumes that the lines in the buffer are of two types:
3934 "heading lines" and "body lines".  A heading line represents a topic in
3935 the outline.  Heading lines start with one or more stars; the number of
3936 stars determines the depth of the heading in the outline structure.
3937 Thus, a heading line with one star is a major topic; all the heading
3938 lines with two stars between it and the next one-star heading are its
3939 subtopics; and so on.  Any line that is not a heading line is a body
3940 line.  Body lines belong to the preceding heading line.  Here is an
3941 example:
3942
3943      * Food
3944
3945      This is the body,
3946      which says something about the topic of food.
3947
3948      ** Delicious Food
3949
3950      This is the body of the second-level header.
3951
3952      ** Distasteful Food
3953
3954      This could have
3955      a body too, with
3956      several lines.
3957
3958      *** Dormitory Food
3959
3960      * Shelter
3961
3962      A second first-level topic with its header line.
3963
3964    A heading line together with all following body lines is called
3965 collectively an "entry".  A heading line together with all following
3966 deeper heading lines and their body lines is called a "subtree".
3967
3968    You can customize the criterion for distinguishing heading lines by
3969 setting the variable `outline-regexp'.  Any line whose beginning has a
3970 match for this regexp is considered a heading line.  Matches that start
3971 within a line (not at the beginning) do not count.  The length of the
3972 matching text determines the level of the heading; longer matches make
3973 a more deeply nested level.  Thus, for example, if a text formatter has
3974 commands `@chapter', `@section' and `@subsection' to divide the
3975 document into chapters and sections, you can make those lines count as
3976 heading lines by setting `outline-regexp' to
3977 `"@chap\\|@\\(sub\\)*section"'.  Note the trick: the two words
3978 `chapter' and `section' are the same length, but by defining the regexp
3979 to match only `chap' we ensure that the length of the text matched on a
3980 chapter heading is shorter, so that Outline mode will know that
3981 sections are contained in chapters.  This works as long as no other
3982 command starts with `@chap'.
3983
3984    Outline mode makes a line invisible by changing the newline before it
3985 into an ASCII Control-M (code 015).  Most editing commands that work on
3986 lines treat an invisible line as part of the previous line because,
3987 strictly speaking, it is part of that line, since there is no longer a
3988 newline in between.  When you save the file in Outline mode, Control-M
3989 characters are saved as newlines, so the invisible lines become ordinary
3990 lines in the file.  Saving does not change the visibility status of a
3991 line inside Emacs.
3992
3993 \1f
3994 File: xemacs.info,  Node: Outline Motion,  Next: Outline Visibility,  Prev: Outline Format,  Up: Outline Mode
3995
3996 20.1.3.2 Outline Motion Commands
3997 ................................
3998
3999 Some special commands in Outline mode move backward and forward to
4000 heading lines.
4001
4002 `C-c C-n'
4003      Move point to the next visible heading line
4004      (`outline-next-visible-heading').
4005
4006 `C-c C-p'
4007      Move point to the previous visible heading line
4008      (`outline-previous-visible-heading').
4009
4010 `C-c C-f'
4011      Move point to the next visible heading line at the same level as
4012      the one point is on (`outline-forward-same-level').
4013
4014 `C-c C-b'
4015      Move point to the previous visible heading line at the same level
4016      (`outline-backward-same-level').
4017
4018 `C-c C-u'
4019      Move point up to a lower-level (more inclusive) visible heading
4020      line (`outline-up-heading').
4021
4022    `C-c C-n' (`next-visible-heading') moves down to the next heading
4023 line.  `C-c C-p' (`previous-visible-heading') moves similarly backward.
4024 Both accept numeric arguments as repeat counts.  The names emphasize
4025 that invisible headings are skipped, but this is not really a special
4026 feature.  All editing commands that look for lines ignore the invisible
4027 lines automatically.
4028
4029    More advanced motion commands understand the levels of headings.
4030 The commands `C-c C-f' (`outline-forward-same-level') and `C-c C-b'
4031 (`outline-backward-same-level') move from one heading line to another
4032 visible heading at the same depth in the outline.  `C-c C-u'
4033 (`outline-up-heading') moves backward to another heading that is less
4034 deeply nested.
4035
4036 \1f
4037 File: xemacs.info,  Node: Outline Visibility,  Prev: Outline Motion,  Up: Outline Mode
4038
4039 20.1.3.3 Outline Visibility Commands
4040 ....................................
4041
4042 The other special commands of outline mode are used to make lines
4043 visible or invisible.  Their names all start with `hide' or `show'.
4044 Most of them exist as pairs of opposites.  They are not undoable;
4045 instead, you can undo right past them.  Making lines visible or
4046 invisible is simply not recorded by the undo mechanism.
4047
4048 `M-x hide-body'
4049      Make all body lines in the buffer invisible.
4050
4051 `M-x show-all'
4052      Make all lines in the buffer visible.
4053
4054 `C-c C-d'
4055      Make everything under this heading invisible, not including this
4056      heading itself (`hide-subtree').
4057
4058 `C-c C-s'
4059      Make everything under this heading visible, including body,
4060      subheadings, and their bodies (`show-subtree').
4061
4062 `M-x hide-leaves'
4063      Make the body of this heading line, and of all its subheadings,
4064      invisible.
4065
4066 `M-x show-branches'
4067      Make all subheadings of this heading line, at all levels, visible.
4068
4069 `C-c C-i'
4070      Make immediate subheadings (one level down) of this heading line
4071      visible (`show-children').
4072
4073 `M-x hide-entry'
4074      Make this heading line's body invisible.
4075
4076 `M-x show-entry'
4077      Make this heading line's body visible.
4078
4079    Two commands that are exact opposites are `M-x hide-entry' and `M-x
4080 show-entry'.  They are used with point on a heading line, and apply
4081 only to the body lines of that heading.  The subtopics and their bodies
4082 are not affected.
4083
4084    Two more powerful opposites are `C-c C-d' (`hide-subtree') and `C-c
4085 C-s' (`show-subtree').  Both should be used when point is on a heading
4086 line, and both apply to all the lines of that heading's "subtree": its
4087 body, all its subheadings, both direct and indirect, and all of their
4088 bodies.  In other words, the subtree contains everything following this
4089 heading line, up to and not including the next heading of the same or
4090 higher rank.
4091
4092    Intermediate between a visible subtree and an invisible one is having
4093 all the subheadings visible but none of the body.  There are two
4094 commands for doing this, one that hides the bodies and one that makes
4095 the subheadings visible.  They are `M-x hide-leaves' and `M-x
4096 show-branches'.
4097
4098    A little weaker than `show-branches' is `C-c C-i' (`show-children').
4099 It makes just the direct subheadings visible--those one level down.
4100 Deeper subheadings remain invisible.
4101
4102    Two commands have a blanket effect on the whole file.  `M-x
4103 hide-body' makes all body lines invisible, so that you see just the
4104 outline structure.  `M-x show-all' makes all lines visible.  You can
4105 think of these commands as a pair of opposites even though `M-x
4106 show-all' applies to more than just body lines.
4107
4108    You can turn off the use of ellipses at the ends of visible lines by
4109 setting `selective-display-ellipses' to `nil'.  The result is no
4110 visible indication of the presence of invisible lines.
4111
4112 \1f
4113 File: xemacs.info,  Node: Words,  Next: Sentences,  Prev: Text Mode,  Up: Text
4114
4115 20.2 Words
4116 ==========
4117
4118 Emacs has commands for moving over or operating on words.  By
4119 convention, the keys for them are all `Meta-' characters.
4120
4121 `M-f'
4122      Move forward over a word (`forward-word').
4123
4124 `M-b'
4125      Move backward over a word (`backward-word').
4126
4127 `M-d'
4128      Kill up to the end of a word (`kill-word').
4129
4130 `M-<DEL>'
4131      Kill back to the beginning of a word (`backward-kill-word').
4132
4133 `M-@'
4134      Mark the end of the next word (`mark-word').
4135
4136 `M-t'
4137      Transpose two words;  drag a word forward or backward across other
4138      words (`transpose-words').
4139
4140    Notice how these keys form a series that parallels the
4141 character-based `C-f', `C-b', `C-d', `C-t' and <DEL>.  `M-@' is related
4142 to `C-@', which is an alias for `C-<SPC>'.
4143
4144    The commands `Meta-f' (`forward-word') and `Meta-b'
4145 (`backward-word') move forward and backward over words.  They are
4146 analogous to `Control-f' and `Control-b', which move over single
4147 characters.  Like their `Control-' analogues, `Meta-f' and `Meta-b'
4148 move several words if given an argument.  `Meta-f' with a negative
4149 argument moves backward, and `Meta-b' with a negative argument moves
4150 forward.  Forward motion stops after the last letter of the word, while
4151 backward motion stops before the first letter.
4152
4153    `Meta-d' (`kill-word') kills the word after point.  To be precise,
4154 it kills everything from point to the place `Meta-f' would move to.
4155 Thus, if point is in the middle of a word, `Meta-d' kills just the part
4156 after point.  If some punctuation comes between point and the next
4157 word, it is killed along with the word.  (To kill only the next word
4158 but not the punctuation before it, simply type `Meta-f' to get to the
4159 end and kill the word backwards with `Meta-<DEL>'.)  `Meta-d' takes
4160 arguments just like `Meta-f'.
4161
4162    `Meta-<DEL>' (`backward-kill-word') kills the word before point.  It
4163 kills everything from point back to where `Meta-b' would move to.  If
4164 point is after the space in `FOO, BAR', then `FOO, ' is killed.   To
4165 kill just `FOO', type `Meta-b Meta-d' instead of `Meta-<DEL>'.
4166
4167    `Meta-t' (`transpose-words') exchanges the word before or containing
4168 point with the following word.  The delimiter characters between the
4169 words do not move.  For example, transposing `FOO, BAR' results in
4170 `BAR, FOO' rather than `BAR FOO,'.  *Note Transpose::, for more on
4171 transposition and on arguments to transposition commands.
4172
4173    To operate on the next N words with an operation which applies
4174 between point and mark, you can either set the mark at point and then
4175 move over the words, or you can use the command `Meta-@' (`mark-word')
4176 which does not move point but sets the mark where `Meta-f' would move
4177 to.  It can be given arguments just like `Meta-f'.
4178
4179    The word commands' understanding of syntax is completely controlled
4180 by the syntax table.  For example, any character can be declared to be
4181 a word delimiter.  *Note Syntax::.
4182
4183 \1f
4184 File: xemacs.info,  Node: Sentences,  Next: Paragraphs,  Prev: Words,  Up: Text
4185
4186 20.3 Sentences
4187 ==============
4188
4189 The Emacs commands for manipulating sentences and paragraphs are mostly
4190 on `Meta-' keys, and therefore are like the word-handling commands.
4191
4192 `M-a'
4193      Move back to the beginning of the sentence (`backward-sentence').
4194
4195 `M-e'
4196      Move forward to the end of the sentence (`forward-sentence').
4197
4198 `M-k'
4199      Kill forward to the end of the sentence (`kill-sentence').
4200
4201 `C-x <DEL>'
4202      Kill back to the beginning of the sentence
4203      (`backward-kill-sentence').
4204
4205    The commands `Meta-a' and `Meta-e' (`backward-sentence' and
4206 `forward-sentence') move to the beginning and end of the current
4207 sentence, respectively.  They resemble `Control-a' and `Control-e',
4208 which move to the beginning and end of a line.  Unlike their
4209 counterparts, `Meta-a' and `Meta-e' move over successive sentences if
4210 repeated or given numeric arguments.  Emacs assumes the typist's
4211 convention is followed, and thus considers a sentence to end wherever
4212 there is a `.', `?', or `!' followed by the end of a line or two
4213 spaces, with any number of `)', `]', `'', or `"' characters allowed in
4214 between.  A sentence also begins or ends wherever a paragraph begins or
4215 ends.
4216
4217    Neither `M-a' nor `M-e' moves past the newline or spaces beyond the
4218 sentence edge at which it is stopping.
4219
4220    `M-a' and `M-e' have a corresponding kill command, just like `C-a'
4221 and `C-e' have `C-k'.  The command is  `M-k' (`kill-sentence') which
4222 kills from point to the end of the sentence.  With minus one as an
4223 argument it kills back to the beginning of the sentence.  Larger
4224 arguments serve as repeat counts.
4225
4226    There is a special command, `C-x <DEL>' (`backward-kill-sentence'),
4227 for killing back to the beginning of a sentence, which is useful when
4228 you change your mind in the middle of composing text.
4229
4230    The variable `sentence-end' controls recognition of the end of a
4231 sentence.  It is a regexp that matches the last few characters of a
4232 sentence, together with the whitespace following the sentence.  Its
4233 normal value is:
4234
4235      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
4236
4237 This example is explained in the section on regexps.  *Note Regexps::.
4238
4239 \1f
4240 File: xemacs.info,  Node: Paragraphs,  Next: Pages,  Prev: Sentences,  Up: Text
4241
4242 20.4 Paragraphs
4243 ===============
4244
4245 The Emacs commands for manipulating paragraphs are also `Meta-' keys.
4246
4247 `M-{'
4248      Move back to previous paragraph beginning
4249      (`backward-paragraph').
4250
4251 `M-}'
4252      Move forward to next paragraph end (`forward-paragraph').
4253
4254 `M-h'
4255      Put point and mark around this or next paragraph
4256      (`mark-paragraph').
4257
4258    `Meta-{' moves to the beginning of the current or previous paragraph,
4259 while `Meta-}' moves to the end of the current or next paragraph.
4260 Blank lines and text formatter command lines separate paragraphs and are
4261 not part of any paragraph.  An indented line starts a new paragraph.
4262
4263    In major modes for programs (as opposed to Text mode), paragraphs
4264 begin and end only at blank lines.  As a result, the paragraph commands
4265 continue to be useful even though there are no paragraphs per se.
4266
4267    When there is a fill prefix, paragraphs are delimited by all lines
4268 which don't start with the fill prefix.  *Note Filling::.
4269
4270    To operate on a paragraph, you can use the command `Meta-h'
4271 (`mark-paragraph') to set the region around it.  This command puts
4272 point at the beginning and mark at the end of the paragraph point was
4273 in.  If point is between paragraphs (in a run of blank lines or at a
4274 boundary), the paragraph following point is surrounded by point and
4275 mark.  If there are blank lines preceding the first line of the
4276 paragraph, one of the blank lines is included in the region.  Thus, for
4277 example, `M-h C-w' kills the paragraph around or after point.
4278
4279    The precise definition of a paragraph boundary is controlled by the
4280 variables `paragraph-separate' and `paragraph-start'.  The value of
4281 `paragraph-start' is a regexp that matches any line that either starts
4282 or separates paragraphs.  The value of `paragraph-separate' is another
4283 regexp that  matches only lines that separate paragraphs without being
4284 part of any paragraph.  Lines that start a new paragraph and are
4285 contained in it must match both regexps.  For example, normally
4286 `paragraph-start' is `"^[ \t\n\f]"' and `paragraph-separate' is `"^[
4287 \t\f]*$"'.
4288
4289    Normally it is desirable for page boundaries to separate paragraphs.
4290 The default values of these variables recognize the usual separator for
4291 pages.
4292
4293 \1f
4294 File: xemacs.info,  Node: Pages,  Next: Filling,  Prev: Paragraphs,  Up: Text
4295
4296 20.5 Pages
4297 ==========
4298
4299 Files are often thought of as divided into "pages" by the "formfeed"
4300 character (ASCII Control-L, octal code 014).  For example, if a file is
4301 printed on a line printer, each "page" of the file starts on a new page
4302 of paper.  Emacs treats a page-separator character just like any other
4303 character.  It can be inserted with `C-q C-l' or deleted with <DEL>.
4304 You are free to paginate your file or not.  However, since pages are
4305 often meaningful divisions of the file, commands are provided to move
4306 over them and operate on them.
4307
4308 `C-x ['
4309      Move point to previous page boundary (`backward-page').
4310
4311 `C-x ]'
4312      Move point to next page boundary (`forward-page').
4313
4314 `C-x C-p'
4315      Put point and mark around this page (or another page)
4316      (`mark-page').
4317
4318 `C-x l'
4319      Count the lines in this page (`count-lines-page').
4320
4321    The `C-x [' (`backward-page') command moves point to immediately
4322 after the previous page delimiter.  If point is already right after a
4323 page delimiter, the command skips that one and stops at the previous
4324 one.  A numeric argument serves as a repeat count.  The `C-x ]'
4325 (`forward-page') command moves forward past the next page delimiter.
4326
4327    The `C-x C-p' command (`mark-page') puts point at the beginning of
4328 the current page and the mark at the end.  The page delimiter at the end
4329 is included (the mark follows it).  The page delimiter at the front is
4330 excluded (point follows it).  You can follow this command  by `C-w' to
4331 kill a page you want to move elsewhere.  If you insert the page after a
4332 page delimiter, at a place where `C-x ]' or `C-x [' would take you, the
4333 page will be properly delimited before and after once again.
4334
4335    A numeric argument to `C-x C-p' is used to specify which page to go
4336 to, relative to the current one.  Zero means the current page.  One
4337 means the next page, and -1 means the previous one.
4338
4339    The `C-x l' command (`count-lines-page') can help you decide where
4340 to break a page in two.  It prints the total number of lines in the
4341 current page in the echo area, then divides the lines into those
4342 preceding the current line and those following it, for example
4343
4344      Page has 96 (72+25) lines
4345
4346 Notice that the sum is off by one; this is correct if point is not at
4347 the beginning of a line.
4348
4349    The variable `page-delimiter' should have as its value a regexp that
4350 matches the beginning of a line that separates pages.  This defines
4351 where pages begin.  The normal value of this variable is `"^\f"', which
4352 matches a formfeed character at the beginning of a line.
4353
4354 \1f
4355 File: xemacs.info,  Node: Filling,  Next: Case,  Prev: Pages,  Up: Text
4356
4357 20.6 Filling Text
4358 =================
4359
4360 If you use Auto Fill mode, Emacs "fills" text (breaks it up into lines
4361 that fit in a specified width) as you insert it.  When you alter
4362 existing text it is often no longer be properly filled afterwards and
4363 you can use explicit commands for filling.
4364
4365 * Menu:
4366
4367 * Auto Fill::     Auto Fill mode breaks long lines automatically.
4368 * Fill Commands:: Commands to refill paragraphs and center lines.
4369 * Fill Prefix::   Filling when every line is indented or in a comment, etc.
4370
4371 \1f
4372 File: xemacs.info,  Node: Auto Fill,  Next: Fill Commands,  Prev: Filling,  Up: Filling
4373
4374 20.6.1 Auto Fill Mode
4375 ---------------------
4376
4377 "Auto Fill" mode is a minor mode in which lines are broken
4378 automatically when they become too wide.  Breaking happens only when
4379 you type a <SPC> or <RET>.
4380
4381 `M-x auto-fill-mode'
4382      Enable or disable Auto Fill mode.
4383
4384 `<SPC>'
4385 `<RET>'
4386      In Auto Fill mode, break lines when appropriate.
4387
4388    `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off
4389 if it was on.  With a positive numeric argument the command always turns
4390 Auto Fill mode on, and with a negative argument it always turns it off.
4391 The presence of the word `Fill' in the mode line, inside the
4392 parentheses, indicates that Auto Fill mode is in effect.  Auto Fill mode
4393 is a minor mode; you can turn it on or off for each buffer individually.
4394 *Note Minor Modes::.
4395
4396    In Auto Fill mode, lines are broken automatically at spaces when
4397 they get longer than desired.  Line breaking and rearrangement takes
4398 place only when you type <SPC> or <RET>.  To insert a space or newline
4399 without permitting line-breaking, type `C-q <SPC>' or `C-q <LFD>'
4400 (recall that a newline is really a linefeed).  `C-o' inserts a newline
4401 without line breaking.
4402
4403    Auto Fill mode works well with Lisp mode: when it makes a new line in
4404 Lisp mode, it indents that line with <TAB>.  If a line ending in a Lisp
4405 comment gets too long, the text of the comment is split into two
4406 comment lines.  Optionally, new comment delimiters are inserted at the
4407 end of the first line and the beginning of the second, so that each line
4408 is a separate comment.  The variable `comment-multi-line' controls the
4409 choice (*note Comments::).
4410
4411    Auto Fill mode does not refill entire paragraphs.  It can break
4412 lines but cannot merge lines.  Editing in the middle of a paragraph can
4413 result in a paragraph that is not correctly filled.  The easiest way to
4414 make the paragraph properly filled again is using an explicit fill
4415 commands.
4416
4417    Many users like Auto Fill mode and want to use it in all text files.
4418 The section on init files explains how you can arrange this permanently
4419 for yourself.  *Note Init File::.
4420
4421 \1f
4422 File: xemacs.info,  Node: Fill Commands,  Next: Fill Prefix,  Prev: Auto Fill,  Up: Filling
4423
4424 20.6.2 Explicit Fill Commands
4425 -----------------------------
4426
4427 `M-q'
4428      Fill current paragraph (`fill-paragraph').
4429
4430 `M-g'
4431      Fill each paragraph in the region (`fill-region').
4432
4433 `C-x f'
4434      Set the fill column (`set-fill-column').
4435
4436 `M-x fill-region-as-paragraph'
4437      Fill the region, considering it as one paragraph.
4438
4439 `M-s'
4440      Center a line.
4441
4442    To refill a paragraph, use the command `Meta-q' (`fill-paragraph').
4443 It causes the paragraph containing point, or the one after point if
4444 point is between paragraphs, to be refilled.  All line breaks are
4445 removed, and new ones are inserted where necessary.  `M-q' can be
4446 undone with `C-_'.  *Note Undo::.
4447
4448    To refill many paragraphs, use `M-g' (`fill-region'), which divides
4449 the region into paragraphs and fills each of them.
4450
4451    `Meta-q' and `Meta-g' use the same criteria as `Meta-h' for finding
4452 paragraph boundaries (*note Paragraphs::).  For more control, you can
4453 use `M-x fill-region-as-paragraph', which refills everything between
4454 point and mark.  This command recognizes only blank lines as paragraph
4455 separators.
4456
4457    A numeric argument to `M-g' or `M-q' causes it to "justify" the text
4458 as well as filling it.  Extra spaces are inserted to make the right
4459 margin line up exactly at the fill column.  To remove the extra spaces,
4460 use `M-q' or `M-g' with no argument.
4461
4462    The variable `auto-fill-inhibit-regexp' takes as a value a regexp to
4463 match lines that should not be auto-filled.
4464
4465    The command `Meta-s' (`center-line') centers the current line within
4466 the current fill column.  With an argument, it centers several lines
4467 individually and moves past them.
4468
4469    The maximum line width for filling is in the variable `fill-column'.
4470 Altering the value of `fill-column' makes it local to the current
4471 buffer; until then, the default value--initially 70--is in effect.
4472 *Note Locals::.
4473
4474    The easiest way to set `fill-column' is to use the command `C-x f'
4475 (`set-fill-column').  With no argument, it sets `fill-column' to the
4476 current horizontal position of point.  With a numeric argument, it uses
4477 that number as the new fill column.
4478
4479 \1f
4480 File: xemacs.info,  Node: Fill Prefix,  Prev: Fill Commands,  Up: Filling
4481
4482 20.6.3 The Fill Prefix
4483 ----------------------
4484
4485 To fill a paragraph in which each line starts with a special marker
4486 (which might be a few spaces, giving an indented paragraph), use the
4487 "fill prefix" feature.  The fill prefix is a string which is not
4488 included in filling.  Emacs expects every line to start with a fill
4489 prefix.
4490
4491 `C-x .'
4492      Set the fill prefix (`set-fill-prefix').
4493
4494 `M-q'
4495      Fill a paragraph using current fill prefix (`fill-paragraph').
4496
4497 `M-x fill-individual-paragraphs'
4498      Fill the region, considering each change of indentation as
4499      starting a new paragraph.
4500
4501    To specify a fill prefix, move to a line that starts with the desired
4502 prefix, put point at the end of the prefix, and give the command
4503 `C-x .' (`set-fill-prefix').  That's a period after the `C-x'.  To turn
4504 off the fill prefix, specify an empty prefix: type `C-x .' with point
4505 at the beginning of a line.
4506
4507    When a fill prefix is in effect, the fill commands remove the fill
4508 prefix from each line before filling and insert it on each line after
4509 filling.  Auto Fill mode also inserts the fill prefix inserted on new
4510 lines it creates.  Lines that do not start with the fill prefix are
4511 considered to start paragraphs, both in `M-q' and the paragraph
4512 commands; this is just right if you are using paragraphs with hanging
4513 indentation (every line indented except the first one).  Lines which are
4514 blank or indented once the prefix is removed also separate or start
4515 paragraphs; this is what you want if you are writing multi-paragraph
4516 comments with a comment delimiter on each line.
4517
4518    The fill prefix is stored in the variable `fill-prefix'.  Its value
4519 is a string, or `nil' when there is no fill prefix.  This is a
4520 per-buffer variable; altering the variable affects only the current
4521 buffer, but there is a default value which you can change as well.
4522 *Note Locals::.
4523
4524    Another way to use fill prefixes is through `M-x
4525 fill-individual-paragraphs'.  This function divides the region into
4526 groups of consecutive lines with the same amount and kind of
4527 indentation and fills each group as a paragraph, using its indentation
4528 as a fill prefix.
4529
4530 \1f
4531 File: xemacs.info,  Node: Case,  Prev: Filling,  Up: Text
4532
4533 20.7 Case Conversion Commands
4534 =============================
4535
4536 Emacs has commands for converting either a single word or any arbitrary
4537 range of text to upper case or to lower case.
4538
4539 `M-l'
4540      Convert following word to lower case (`downcase-word').
4541
4542 `M-u'
4543      Convert following word to upper case (`upcase-word').
4544
4545 `M-c'
4546      Capitalize the following word (`capitalize-word').
4547
4548 `C-x C-l'
4549      Convert region to lower case (`downcase-region').
4550
4551 `C-x C-u'
4552      Convert region to upper case (`upcase-region').
4553
4554    The word conversion commands are used most frequently.  `Meta-l'
4555 (`downcase-word') converts the word after point to lower case, moving
4556 past it.  Thus, repeating `Meta-l' converts successive words.  `Meta-u'
4557 (`upcase-word') converts to all capitals instead, while `Meta-c'
4558 (`capitalize-word') puts the first letter of the word into upper case
4559 and the rest into lower case.  The word conversion commands convert
4560 several words at once if given an argument.  They are especially
4561 convenient for converting a large amount of text from all upper case to
4562 mixed case: you can move through the text using `M-l', `M-u', or `M-c'
4563 on each word as appropriate, occasionally using `M-f' instead to skip a
4564 word.
4565
4566    When given a negative argument, the word case conversion commands
4567 apply to the appropriate number of words before point, but do not move
4568 point.  This is convenient when you have just typed a word in the wrong
4569 case: you can give the case conversion command and continue typing.
4570
4571    If a word case conversion command is given in the middle of a word,
4572 it applies only to the part of the word which follows point.  This is
4573 just like what `Meta-d' (`kill-word') does.  With a negative argument,
4574 case conversion applies only to the part of the word before point.
4575
4576    The other case conversion commands are `C-x C-u' (`upcase-region')
4577 and `C-x C-l' (`downcase-region'), which convert everything between
4578 point and mark to the specified case.  Point and mark do not move.
4579
4580 \1f
4581 File: xemacs.info,  Node: Programs,  Next: Running,  Prev: Text,  Up: Top
4582
4583 21 Editing Programs
4584 *******************
4585
4586 XEmacs provides specialized support for editing source files for many
4587 different programming languages. For example it is possible to
4588
4589    * Follow the usual indentation conventions of the language (*note
4590      Grinding::).
4591
4592    * Move over or kill balanced expressions or "sexps" (*note Lists::).
4593
4594    * Move over or mark top-level balanced expressions ("defuns", in
4595      Lisp; functions, in C).
4596
4597    * Show how parentheses balance (*note Matching::).
4598
4599    * Insert, kill, or align comments (*note Comments::).
4600
4601    * Find functions and symbols in program by name (*note Tags::).
4602
4603    The commands available for words, sentences, and paragraphs are
4604 useful in editing code even though their canonical application is for
4605 editing human language text.  Most symbols contain words (*note
4606 Words::); sentences can be found in strings and comments (*note
4607 Sentences::).  Paragraphs per se are not present in code, but the
4608 paragraph commands are useful anyway, because Lisp mode and C mode
4609 define paragraphs to begin and end at blank lines (*note Paragraphs::).
4610 Judicious use of blank lines to make the program clearer also provides
4611 interesting chunks of text for the paragraph commands to work on.
4612
4613    The selective display feature is useful for looking at the overall
4614 structure of a function (*note Selective Display::).  This feature
4615 causes only the lines that are indented less than a specified amount to
4616 appear on the screen.
4617
4618 * Menu:
4619
4620 * Program Modes::       Major modes for editing programs.
4621 * Lists::               Expressions with balanced parentheses.
4622                          There are editing commands to operate on them.
4623 * Defuns::              Each program is made up of separate functions.
4624                          There are editing commands to operate on them.
4625 * Grinding::            Adjusting indentation to show the nesting.
4626 * Matching::            Insertion of a close-delimiter flashes matching open.
4627 * Comments::            Inserting, filling and aligning comments.
4628 * Balanced Editing::    Inserting two matching parentheses at once, etc.
4629 * Lisp Completion::     Completion on symbol names in Lisp code.
4630 * Documentation::       Getting documentation of functions you plan to call.
4631 * Change Log::          Maintaining a change history for your program.
4632 * Tags::                Go direct to any function in your program in one
4633                          command.  Tags remembers which file it is in.
4634 * CC Mode::             Modes for C, C++, Java and similar languages
4635 * Fortran::             Fortran mode and its special features.
4636 * Asm Mode::            Asm mode and its special features.
4637
4638 \1f
4639 File: xemacs.info,  Node: Program Modes,  Next: Lists,  Prev: Programs,  Up: Programs
4640
4641 21.1 Major Modes for Programming Languages
4642 ==========================================
4643
4644 Emacs has several major modes (*note Major Modes::) to support
4645 programming languages. These major modes will typically understand
4646 language syntax, provide automatic indentation features, syntax based
4647 highlighting of text, and will often provide interfaces to the
4648 programming environment to assist in compiling, executing and debugging
4649 programs.
4650
4651    A language mode exist when someone decides to take the trouble to
4652 write it. At this time many widely used programming languages are
4653 supported by XEmacs. Examples include Ada, Awk, C, C++, CORBA (IDL),
4654 Fortran, Java, Lisp, Modula 2, Objective-C, Perl, Pike, Prolog, Python,
4655 Ruby, Scheme, Simula, SQL, Tcl, Unix Shell scripts, and VHDL. Some of
4656 these language have seperate manuals, and some times more than one mode
4657 may be available for a language.  For example, there are several
4658 variants of Lisp mode, which differ in the way they interface to Lisp
4659 execution.  *Note Lisp Modes::.
4660
4661    Major modes for programming language support are distributed in
4662 optional XEmacs packages (*note Packages::) that must be installed
4663 before use. A notable exception to this rule is that a Lisp Mode is
4664 integral to XEmacs. The Programming Mode Package (`prog-modes')
4665 contains many such modes. Some languages are supported by packages of
4666 their own; prominent examples of such packages include `cc-mode' for C,
4667 C++, Java, Objective C etc., `python-modes' for Python, and `scheme'
4668 for Scheme.
4669
4670    For a language named LANG the major mode for the language will
4671 typically be named `LANG-mode'.  For example, the mode for C is called
4672 `c-mode', that for Bourne shell scripts is called `sh-mode' and so on.
4673 These modes will invoke the functions listed in the corresponding hook
4674 variables as a last step. *Note Mode Hooks::.
4675
4676    A mode can be invoked by typing `M-x LANG-mode <RET>'. However this
4677 step is not normally required. If the package for a language mode is
4678 installed XEmacs usually knows when to automatically invoke the mode.
4679 This is normally done based on examining the file name to determine the
4680 language. *Note Choosing Modes::.
4681
4682    Each of the programming language modes defines the <TAB> key to run
4683 an indentation function that knows the indentation conventions of that
4684 language and updates the current line's indentation accordingly.  <LFD>
4685 is normally defined to do <RET> followed by <TAB>; thus it, too,
4686 indents in a mode-specific fashion.
4687
4688    In most programming languages, indentation is likely to vary from
4689 line to line.  So the major modes for those languages rebind <DEL> to
4690 treat a tab as if it were the equivalent number of spaces (using the
4691 command `backward-delete-char-untabify').  This makes it possible to
4692 rub out indentation one column at a time without worrying whether it is
4693 made up of spaces or tabs.  In these modes, use `C-b C-d' to delete a
4694 tab character before point.
4695
4696    Programming language modes define paragraphs to be separated only by
4697 blank lines, so that the paragraph commands remain useful.  Auto Fill
4698 mode, if enabled in a programming language major mode, indents the new
4699 lines which it creates.
4700
4701 \1f
4702 File: xemacs.info,  Node: Lists,  Next: Defuns,  Prev: Program Modes,  Up: Programs
4703
4704 21.2 Lists and Sexps
4705 ====================
4706
4707 By convention, Emacs keys for dealing with balanced expressions are
4708 usually `Control-Meta-' characters.  They tend to be analogous in
4709 function to their `Control-' and `Meta-' equivalents.  These commands
4710 are usually thought of as pertaining to expressions in programming
4711 languages, but can be useful with any language in which some sort of
4712 parentheses exist (including English).
4713
4714    The commands fall into two classes.  Some commands deal only with
4715 "lists" (parenthetical groupings).  They see nothing except
4716 parentheses, brackets, braces (depending on what must balance in the
4717 language you are working with), and escape characters that might be used
4718 to quote those.
4719
4720    The other commands deal with expressions or "sexps".  The word `sexp'
4721 is derived from "s-expression", the term for a symbolic expression in
4722 Lisp.  In Emacs, the notion of `sexp' is not limited to Lisp.  It
4723 refers to an expression in the language  your program is written in.
4724 Each programming language has its own major mode, which customizes the
4725 syntax tables so that expressions in that language count as sexps.
4726
4727    Sexps typically include symbols, numbers, and string constants, as
4728 well as anything contained in parentheses, brackets, or braces.
4729
4730    In languages that use prefix and infix operators, such as C, it is
4731 not possible for all expressions to be sexps.  For example, C mode does
4732 not recognize `foo + bar' as an sexp, even though it is a C expression;
4733 it recognizes `foo' as one sexp and `bar' as another, with the `+' as
4734 punctuation between them.  This is a fundamental ambiguity: both `foo +
4735 bar' and `foo' are legitimate choices for the sexp to move over if
4736 point is at the `f'.  Note that `(foo + bar)' is a sexp in C mode.
4737
4738    Some languages have obscure forms of syntax for expressions that
4739 nobody has bothered to make Emacs understand properly.
4740
4741 `C-M-f'
4742      Move forward over an sexp (`forward-sexp').
4743
4744 `C-M-b'
4745      Move backward over an sexp (`backward-sexp').
4746
4747 `C-M-k'
4748      Kill sexp forward (`kill-sexp').
4749
4750 `C-M-u'
4751      Move up and backward in list structure (`backward-up-list').
4752
4753 `C-M-d'
4754      Move down and forward in list structure (`down-list').
4755
4756 `C-M-n'
4757      Move forward over a list (`forward-list').
4758
4759 `C-M-p'
4760      Move backward over a list (`backward-list').
4761
4762 `C-M-t'
4763      Transpose expressions (`transpose-sexps').
4764
4765 `C-M-@'
4766      Put mark after following expression (`mark-sexp').
4767
4768    To move forward over an sexp, use `C-M-f' (`forward-sexp').  If the
4769 first significant character after point is an opening delimiter (`(' in
4770 Lisp; `(', `[', or `{' in C), `C-M-f' moves past the matching closing
4771 delimiter.  If the character begins a symbol, string, or number,
4772 `C-M-f' moves over that.  If the character after point is a closing
4773 delimiter, `C-M-f' just moves past it.  (This last is not really moving
4774 across an sexp; it is an exception which is included in the definition
4775 of `C-M-f' because it is as useful a behavior as anyone can think of
4776 for that situation.)
4777
4778    The command `C-M-b' (`backward-sexp') moves backward over a sexp.
4779 The detailed rules are like those above for `C-M-f', but with
4780 directions reversed.  If there are any prefix characters (single quote,
4781 back quote, and comma, in Lisp) preceding the sexp, `C-M-b' moves back
4782 over them as well.
4783
4784    `C-M-f' or `C-M-b' with an argument repeats that operation the
4785 specified number of times; with a negative argument, it moves in the
4786 opposite direction.
4787
4788    Killing an sexp at a time can be done with `C-M-k' (`kill-sexp').
4789 `C-M-k' kills the characters that `C-M-f' would move over.
4790
4791    The "list commands", `C-M-n' (`forward-list') and `C-M-p'
4792 (`backward-list'), move over lists like the sexp commands but skip over
4793 any number of other kinds of sexps (symbols, strings, etc).  In some
4794 situations, these commands are useful because they usually ignore
4795 comments, since the comments usually do not contain any lists.
4796
4797    `C-M-n' and `C-M-p' stay at the same level in parentheses, when that
4798 is possible.  To move up one (or N) levels, use `C-M-u'
4799 (`backward-up-list').  `C-M-u' moves backward up past one unmatched
4800 opening delimiter.  A positive argument serves as a repeat count; a
4801 negative argument reverses direction of motion and also requests
4802 repetition, so it moves forward and up one or more levels.
4803
4804    To move down in list structure, use `C-M-d' (`down-list').  In Lisp
4805 mode, where `(' is the only opening delimiter, this is nearly the same
4806 as searching for a `('.  An argument specifies the number of levels of
4807 parentheses to go down.
4808
4809    `C-M-t' (`transpose-sexps') drags the previous sexp across the next
4810 one.  An argument serves as a repeat count, and a negative argument
4811 drags backwards (thus canceling out the effect of `C-M-t' with a
4812 positive argument).  An argument of zero, rather than doing nothing,
4813 transposes the sexps ending after point and the mark.
4814
4815    To make the region be the next sexp in the buffer, use `C-M-@'
4816 (`mark-sexp') which sets the mark at the same place that `C-M-f' would
4817 move to.  `C-M-@' takes arguments like `C-M-f'.  In particular, a
4818 negative argument is useful for putting the mark at the beginning of
4819 the previous sexp.
4820
4821    The list and sexp commands' understanding of syntax is completely
4822 controlled by the syntax table.  Any character can, for example, be
4823 declared to be an opening delimiter and act like an open parenthesis.
4824 *Note Syntax::.
4825
4826 \1f
4827 File: xemacs.info,  Node: Defuns,  Next: Grinding,  Prev: Lists,  Up: Programs
4828
4829 21.3 Defuns
4830 ===========
4831
4832 In Emacs, a parenthetical grouping at the top level in the buffer is
4833 called a "defun".  The name derives from the fact that most top-level
4834 lists in Lisp are instances of the special form `defun', but Emacs
4835 calls any top-level parenthetical grouping counts a defun regardless of
4836 its contents or the programming language.  For example, in C, the body
4837 of a function definition is a defun.
4838
4839 `C-M-a'
4840      Move to beginning of current or preceding defun
4841      (`beginning-of-defun').
4842
4843 `C-M-e'
4844      Move to end of current or following defun (`end-of-defun').
4845
4846 `C-M-h'
4847      Put region around whole current or following defun (`mark-defun').
4848
4849    The commands to move to the beginning and end of the current defun
4850 are `C-M-a' (`beginning-of-defun') and `C-M-e' (`end-of-defun').
4851
4852    To operate on the current defun, use `C-M-h' (`mark-defun') which
4853 puts point at the beginning and the mark at the end of the current or
4854 next defun.  This is the easiest way to prepare for moving the defun to
4855 a different place.  In C mode, `C-M-h' runs the function
4856 `mark-c-function', which is almost the same as `mark-defun', but which
4857 backs up over the argument declarations, function name, and returned
4858 data type so that the entire C function is inside the region.
4859
4860    To compile and evaluate the current defun, use `M-x compile-defun'.
4861 This function prints the results in the minibuffer. If you include an
4862 argument, it inserts the value in the current buffer after the defun.
4863
4864    Emacs assumes that any open-parenthesis found in the leftmost column
4865 is the start of a defun.  Therefore, never put an open-parenthesis at
4866 the left margin in a Lisp file unless it is the start of a top level
4867 list.  Never put an open-brace or other opening delimiter at the
4868 beginning of a line of C code unless it starts the body of a function.
4869 The most likely problem case is when you want an opening delimiter at
4870 the start of a line inside a string.  To avoid trouble, put an escape
4871 character (`\' in C and Emacs Lisp, `/' in some other Lisp dialects)
4872 before the opening delimiter.  It will not affect the contents of the
4873 string.
4874
4875    The original Emacs found defuns by moving upward a level of
4876 parentheses until there were no more levels to go up.  This required
4877 scanning back to the beginning of the buffer for every function.  To
4878 speed this up, Emacs was changed to assume that any `(' (or other
4879 character assigned the syntactic class of opening-delimiter) at the
4880 left margin is the start of a defun.  This heuristic is nearly always
4881 right; however, it mandates the convention described above.
4882
4883 \1f
4884 File: xemacs.info,  Node: Grinding,  Next: Matching,  Prev: Defuns,  Up: Programs
4885
4886 21.4 Indentation for Programs
4887 =============================
4888
4889 The best way to keep a program properly indented ("ground") is to use
4890 Emacs to re-indent it as you change the program.  Emacs has commands to
4891 indent properly either a single line, a specified number of lines, or
4892 all of the lines inside a single parenthetical grouping.
4893
4894 * Menu:
4895
4896 * Basic Indent::
4897 * Multi-line Indent::   Commands to reindent many lines at once.
4898 * Lisp Indent::         Specifying how each Lisp function should be indented.
4899
4900 \1f
4901 File: xemacs.info,  Node: Basic Indent,  Next: Multi-line Indent,  Prev: Grinding,  Up: Grinding
4902
4903 21.4.1 Basic Program Indentation Commands
4904 -----------------------------------------
4905
4906 `<TAB>'
4907      Adjust indentation of current line.
4908
4909 `<LFD>'
4910      Equivalent to <RET> followed by <TAB> (`newline-and-indent').
4911
4912    The basic indentation command is <TAB>, which gives the current line
4913 the correct indentation as determined from the previous lines.  The
4914 function that <TAB> runs depends on the major mode; it is
4915 `lisp-indent-line' in Lisp mode, `c-indent-line' in C mode, etc.  These
4916 functions understand different syntaxes for different languages, but
4917 they all do about the same thing.  <TAB> in any programming language
4918 major mode inserts or deletes whitespace at the beginning of the
4919 current line, independent of where point is in the line.  If point is
4920 inside the whitespace at the beginning of the line, <TAB> leaves it at
4921 the end of that whitespace; otherwise, <TAB> leaves point fixed with
4922 respect to the characters around it.
4923
4924    Use `C-q <TAB>' to insert a tab at point.
4925
4926    When entering a large amount of new code, use <LFD>
4927 (`newline-and-indent'), which is equivalent to a <RET> followed by a
4928 <TAB>.  <LFD> creates a blank line, then gives it the appropriate
4929 indentation.
4930
4931    <TAB> indents the second and following lines of the body of a
4932 parenthetical grouping each under the preceding one; therefore, if you
4933 alter one line's indentation to be nonstandard, the lines below tend to
4934 follow it.  This is the right behavior in cases where the standard
4935 result of <TAB> does not look good.
4936
4937    Remember that Emacs assumes that an open-parenthesis, open-brace, or
4938 other opening delimiter at the left margin (including the indentation
4939 routines) is the start of a function.  You should therefore never have
4940 an opening delimiter in column zero that is not the beginning of a
4941 function, not even inside a string.  This restriction is vital for
4942 making the indentation commands fast. *Note Defuns::, for more
4943 information on this behavior.
4944
4945 \1f
4946 File: xemacs.info,  Node: Multi-line Indent,  Next: Lisp Indent,  Prev: Basic Indent,  Up: Grinding
4947
4948 21.4.2 Indenting Several Lines
4949 ------------------------------
4950
4951 Several commands are available to re-indent several lines of code which
4952 have been altered or moved to a different level in a list structure.
4953
4954 `C-M-q'
4955      Re-indent all the lines within one list (`indent-sexp').
4956
4957 `C-u <TAB>'
4958      Shift an entire list rigidly sideways so that its first line is
4959      properly indented.
4960
4961 `C-M-\'
4962      Re-indent all lines in the region (`indent-region').
4963
4964    To re-indent the contents of a single list, position point before the
4965 beginning of it and type `C-M-q'. This key is bound to `indent-sexp' in
4966 Lisp mode, `indent-c-exp' in C mode, and bound to other suitable
4967 functions in other modes.  The indentation of the line the sexp starts
4968 on is not changed; therefore, only the relative indentation within the
4969 list, and not its position, is changed.  To correct the position as
4970 well, type a <TAB> before `C-M-q'.
4971
4972    If the relative indentation within a list is correct but the
4973 indentation of its beginning is not, go to the line on which the list
4974 begins and type `C-u <TAB>'.  When you give <TAB> a numeric argument,
4975 it moves all the lines in the group, starting on the current line,
4976 sideways the same amount that the current line moves.  The command does
4977 not move lines that start inside strings, or C preprocessor lines when
4978 in C mode.
4979
4980    Another way to specify a range to be re-indented is with point and
4981 mark.  The command `C-M-\' (`indent-region') applies <TAB> to every
4982 line whose first character is between point and mark.
4983
4984 \1f
4985 File: xemacs.info,  Node: Lisp Indent,  Prev: Multi-line Indent,  Up: Grinding
4986
4987 21.4.3 Customizing Lisp Indentation
4988 -----------------------------------
4989
4990 The indentation pattern for a Lisp expression can depend on the function
4991 called by the expression.  For each Lisp function, you can choose among
4992 several predefined patterns of indentation, or define an arbitrary one
4993 with a Lisp program.
4994
4995    The standard pattern of indentation is as follows: the second line
4996 of the expression is indented under the first argument, if that is on
4997 the same line as the beginning of the expression; otherwise, the second
4998 line is indented underneath the function name.  Each following line is
4999 indented under the previous line whose nesting depth is the same.
5000
5001    If the variable `lisp-indent-offset' is non-`nil', it overrides the
5002 usual indentation pattern for the second line of an expression, so that
5003 such lines are always indented `lisp-indent-offset' more columns than
5004 the containing list.
5005
5006    Certain functions override the standard pattern.  Functions whose
5007 names start with `def' always indent the second line by
5008 `lisp-body-indention' extra columns beyond the open-parenthesis
5009 starting the expression.
5010
5011    Individual functions can override the standard pattern in various
5012 ways, according to the `lisp-indent-function' property of the function
5013 name.  (Note: `lisp-indent-function' was formerly called
5014 `lisp-indent-hook').  There are four possibilities for this property:
5015
5016 `nil'
5017      This is the same as no property; the standard indentation pattern
5018      is used.
5019
5020 `defun'
5021      The pattern used for function names that start with `def' is used
5022      for this function also.
5023
5024 a number, NUMBER
5025      The first NUMBER arguments of the function are "distinguished"
5026      arguments; the rest are considered the "body" of the expression.
5027      A line in the expression is indented according to whether the
5028      first argument on it is distinguished or not.  If the argument is
5029      part of the body, the line is indented `lisp-body-indent' more
5030      columns than the open-parenthesis starting the containing
5031      expression.  If the argument is distinguished and is either the
5032      first or second argument, it is indented twice that many extra
5033      columns.  If the argument is distinguished and not the first or
5034      second argument, the standard pattern is followed for that line.
5035
5036 a symbol, SYMBOL
5037      SYMBOL should be a function name; that function is called to
5038      calculate the indentation of a line within this expression.  The
5039      function receives two arguments:
5040     STATE
5041           The value returned by `parse-partial-sexp' (a Lisp primitive
5042           for indentation and nesting computation) when it parses up to
5043           the beginning of this line.
5044
5045     POS
5046           The position at which the line being indented begins.
5047      It should return either a number, which is the number of columns of
5048      indentation for that line, or a list whose first element is such a
5049      number.  The difference between returning a number and returning a
5050      list is that a number says that all following lines at the same
5051      nesting level should be indented just like this one; a list says
5052      that following lines might call for different indentations.  This
5053      makes a difference when the indentation is computed by `C-M-q'; if
5054      the value is a number, `C-M-q' need not recalculate indentation
5055      for the following lines until the end of the list.
5056
5057 \1f
5058 File: xemacs.info,  Node: Matching,  Next: Comments,  Prev: Grinding,  Up: Programs
5059
5060 21.5 Automatic Display of Matching Parentheses
5061 ==============================================
5062
5063 The Emacs parenthesis-matching feature shows you automatically how
5064 parentheses match in the text.  Whenever a self-inserting character that
5065 is a closing delimiter is typed, the cursor moves momentarily to the
5066 location of the matching opening delimiter, provided that is visible on
5067 the screen.  If it is not on the screen, some text starting with that
5068 opening delimiter is displayed in the echo area.  Either way, you see
5069 the grouping you are closing off.
5070
5071    In Lisp, automatic matching applies only to parentheses.  In C, it
5072 also applies to braces and brackets.  Emacs knows which characters to
5073 regard as matching delimiters based on the syntax table set by the major
5074 mode.  *Note Syntax::.
5075
5076    If the opening delimiter and closing delimiter are mismatched--as in
5077 `[x)'--the echo area displays a warning message.  The correct matches
5078 are specified in the syntax table.
5079
5080    Two variables control parenthesis matching displays.
5081 `blink-matching-paren' turns the feature on or off. The default is `t'
5082 (match display is on); `nil' turns it off.
5083 `blink-matching-paren-distance' specifies how many characters back
5084 Emacs searches to find a matching opening delimiter.  If the match is
5085 not found in the specified region, scanning stops, and nothing is
5086 displayed.  This prevents wasting lots of time scanning when there is no
5087 match.  The default is 4000.
5088
5089 \1f
5090 File: xemacs.info,  Node: Comments,  Next: Balanced Editing,  Prev: Matching,  Up: Programs
5091
5092 21.6 Manipulating Comments
5093 ==========================
5094
5095 The comment commands insert, kill and align comments.
5096
5097 `M-;'
5098      Insert or align comment (`indent-for-comment').
5099
5100 `C-x ;'
5101      Set comment column (`set-comment-column').
5102
5103 `C-u - C-x ;'
5104      Kill comment on current line (`kill-comment').
5105
5106 `M-<LFD>'
5107      Like <RET> followed by inserting and aligning a comment
5108      (`indent-new-comment-line').
5109
5110    The command that creates a comment is `Meta-;'
5111 (`indent-for-comment').  If there is no comment already on the line, a
5112 new comment is created and aligned at a specific column called the
5113 "comment column".  Emacs creates the comment by inserting the string at
5114 the value of `comment-start'; see below.  Point is left after that
5115 string.  If the text of the line extends past the comment column,
5116 indentation is done to a suitable boundary (usually, at least one space
5117 is inserted).  If the major mode has specified a string to terminate
5118 comments, that string is inserted after point, to keep the syntax valid.
5119
5120    You can also use `Meta-;' to align an existing comment.  If a line
5121 already contains the string that starts comments, `M-;' just moves
5122 point after it and re-indents it to the conventional place.  Exception:
5123 comments starting in column 0 are not moved.
5124
5125    Some major modes have special rules for indenting certain kinds of
5126 comments in certain contexts.  For example, in Lisp code, comments which
5127 start with two semicolons are indented as if they were lines of code,
5128 instead of at the comment column.  Comments which start with three
5129 semicolons are supposed to start at the left margin.  Emacs understands
5130 these conventions by indenting a double-semicolon comment using <TAB>
5131 and by not changing the indentation of a triple-semicolon comment at
5132 all.
5133
5134      ;; This function is just an example.
5135      ;;; Here either two or three semicolons are appropriate.
5136      (defun foo (x)
5137      ;;; And now, the first part of the function:
5138        ;; The following line adds one.
5139        (1+ x))           ; This line adds one.
5140
5141    In C code, a comment preceded on its line by nothing but whitespace
5142 is indented like a line of code.
5143
5144    Even when an existing comment is properly aligned, `M-;' is still
5145 useful for moving directly to the start of the comment.
5146
5147    `C-u - C-x ;' (`kill-comment') kills the comment on the current
5148 line, if there is one.  The indentation before the start of the comment
5149 is killed as well.  If there does not appear to be a comment in the
5150 line, nothing happens.  To reinsert the comment on another line, move
5151 to the end of that line, type first `C-y', and then `M-;' to realign
5152 the comment.  Note that `C-u - C-x ;' is not a distinct key; it is `C-x
5153 ;' (`set-comment-column') with a negative argument.  That command is
5154 programmed to call `kill-comment' when called with a negative argument.
5155 However, `kill-comment' is a valid command which you could bind
5156 directly to a key if you wanted to.
5157
5158 21.6.1 Multiple Lines of Comments
5159 ---------------------------------
5160
5161 If you are typing a comment and want to continue it on another line,
5162 use the command `Meta-<LFD>' (`indent-new-comment-line'), which
5163 terminates the comment you are typing, creates a new blank line
5164 afterward, and begins a new comment indented under the old one.  If
5165 Auto Fill mode is on and you go past the fill column while typing, the
5166 comment is continued in just this fashion.  If point is not at the end
5167 of the line when you type `M-<LFD>', the text on the rest of the line
5168 becomes part of the new comment line.
5169
5170 21.6.2 Options Controlling Comments
5171 -----------------------------------
5172
5173 The comment column is stored in the variable `comment-column'.  You can
5174 explicitly set it to a number.  Alternatively, the command `C-x ;'
5175 (`set-comment-column') sets the comment column to the column point is
5176 at.  `C-u C-x ;' sets the comment column to match the last comment
5177 before point in the buffer, and then calls `Meta-;' to align the
5178 current line's comment under the previous one.  Note that `C-u - C-x ;'
5179 runs the function `kill-comment' as described above.
5180
5181    `comment-column' is a per-buffer variable; altering the variable
5182 affects only the current buffer.  You can also change the default value.
5183 *Note Locals::.  Many major modes initialize this variable for the
5184 current buffer.
5185
5186    The comment commands recognize comments based on the regular
5187 expression that is the value of the variable `comment-start-skip'.
5188 This regexp should not match the null string.  It may match more than
5189 the comment starting delimiter in the strictest sense of the word; for
5190 example, in C mode the value of the variable is `"/\\*+ *"', which
5191 matches extra stars and spaces after the `/*' itself.  (Note that `\\'
5192 is needed in Lisp syntax to include a `\' in the string, which is needed
5193 to deny the first star its special meaning in regexp syntax.  *Note
5194 Regexps::.)
5195
5196    When a comment command makes a new comment, it inserts the value of
5197 `comment-start' to begin it.  The value of `comment-end' is inserted
5198 after point and will follow the text you will insert into the comment.
5199 In C mode, `comment-start' has the value `"/* "' and `comment-end' has
5200 the value `" */"'.
5201
5202    `comment-multi-line' controls how `M-<LFD>'
5203 (`indent-new-comment-line') behaves when used inside a comment.  If
5204 `comment-multi-line' is `nil', as it normally is, then `M-<LFD>'
5205 terminates the comment on the starting line and starts a new comment on
5206 the new following line.  If `comment-multi-line' is not `nil', then
5207 `M-<LFD>' sets up the new following line as part of the same comment
5208 that was found on the starting line.  This is done by not inserting a
5209 terminator on the old line and not inserting a starter on the new line.
5210 In languages where multi-line comments are legal, the value you choose
5211 for this variable is a matter of taste.
5212
5213    The variable `comment-indent-hook' should contain a function that is
5214 called to compute the indentation for a newly inserted comment or for
5215 aligning an existing comment.  Major modes set this variable
5216 differently.  The function is called with no arguments, but with point
5217 at the beginning of the comment, or at the end of a line if a new
5218 comment is to be inserted.  The function should return the column in
5219 which the comment ought to start.  For example, in Lisp mode, the
5220 indent hook function bases its decision on the number of semicolons
5221 that begin an existing comment and on the code in the preceding lines.
5222
5223 \1f
5224 File: xemacs.info,  Node: Balanced Editing,  Next: Lisp Completion,  Prev: Comments,  Up: Programs
5225
5226 21.7 Editing Without Unbalanced Parentheses
5227 ===========================================
5228
5229 `M-('
5230      Put parentheses around next sexp(s) (`insert-parentheses').
5231
5232 `M-)'
5233      Move past next close parenthesis and re-indent
5234      (`move-over-close-and-reindent').
5235
5236    The commands `M-(' (`insert-parentheses') and `M-)'
5237 (`move-over-close-and-reindent') are designed to facilitate a style of
5238 editing which keeps parentheses balanced at all times.  `M-(' inserts a
5239 pair of parentheses, either together as in `()', or, if given an
5240 argument, around the next several sexps, and leaves point after the open
5241 parenthesis.  Instead of typing `( F O O )', you can type `M-( F O O',
5242 which has the same effect except for leaving the cursor before the
5243 close parenthesis.  You can then type `M-)', which moves past the close
5244 parenthesis, deletes any indentation preceding it (in this example
5245 there is none), and indents with <LFD> after it.
5246
5247 \1f
5248 File: xemacs.info,  Node: Lisp Completion,  Next: Documentation,  Prev: Balanced Editing,  Up: Programs
5249
5250 21.8 Completion for Lisp Symbols
5251 ================================
5252
5253 Completion usually happens in the minibuffer.  An exception is
5254 completion for Lisp symbol names, which is available in all buffers.
5255
5256    The command `M-<TAB>' (`lisp-complete-symbol') takes the partial
5257 Lisp symbol before point to be an abbreviation, and compares it against
5258 all non-trivial Lisp symbols currently known to Emacs.  Any additional
5259 characters that they all have in common are inserted at point.
5260 Non-trivial symbols are those that have function definitions, values, or
5261 properties.
5262
5263    If there is an open-parenthesis immediately before the beginning of
5264 the partial symbol, only symbols with function definitions are
5265 considered as completions.
5266
5267    If the partial name in the buffer has more than one possible
5268 completion and they have no additional characters in common, a list of
5269 all possible completions is displayed in another window.
5270
5271 \1f
5272 File: xemacs.info,  Node: Documentation,  Next: Change Log,  Prev: Lisp Completion,  Up: Programs
5273
5274 21.9 Documentation Commands
5275 ===========================
5276
5277 As you edit Lisp code to be run in Emacs, you can use the commands `C-h
5278 f' (`describe-function') and `C-h v' (`describe-variable') to print
5279 documentation of functions and variables you want to call.  These
5280 commands use the minibuffer to read the name of a function or variable
5281 to document, and display the documentation in a window.
5282
5283    For extra convenience, these commands provide default arguments
5284 based on the code in the neighborhood of point.  `C-h f' sets the
5285 default to the function called in the innermost list containing point.
5286 `C-h v' uses the symbol name around or adjacent to point as its default.
5287
5288    The `M-x manual-entry' command gives you access to documentation on
5289 Unix commands, system calls, and libraries.  The command reads a topic
5290 as an argument, and displays the Unix manual page for that topic.
5291 `manual-entry' always searches all 8 sections of the manual and
5292 concatenates all the entries it finds.  For example, the topic
5293 `termcap' finds the description of the termcap library from section 3,
5294 followed by the description of the termcap data base from section 5.
5295
5296 \1f
5297 File: xemacs.info,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
5298
5299 21.10 Change Logs
5300 =================
5301
5302 The Emacs command `M-x add-change-log-entry' helps you keep a record of
5303 when and why you have changed a program.  It assumes that you have a
5304 file in which you write a chronological sequence of entries describing
5305 individual changes.  The default is to store the change entries in a
5306 file called `ChangeLog' in the same directory as the file you are
5307 editing.  The same `ChangeLog' file therefore records changes for all
5308 the files in a directory.
5309
5310    A change log entry starts with a header line that contains your name
5311 and the current date.  Except for these header lines, every line in the
5312 change log starts with a tab.  One entry can describe several changes;
5313 each change starts with a line starting with a tab and a star.  `M-x
5314 add-change-log-entry' visits the change log file and creates a new entry
5315 unless the most recent entry is for today's date and your name.  In
5316 either case, it adds a new line to start the description of another
5317 change just after the header line of the entry.  When `M-x
5318 add-change-log-entry' is finished, all is prepared for you to edit in
5319 the description of what you changed and how.  You must then save the
5320 change log file yourself.
5321
5322    The change log file is always visited in Indented Text mode, which
5323 means that <LFD> and auto-filling indent each new line like the previous
5324 line.  This is convenient for entering the contents of an entry, which
5325 must be indented.  *Note Text Mode::.
5326
5327    Here is an example of the formatting conventions used in the change
5328 log for Emacs:
5329
5330      Wed Jun 26 19:29:32 1985  Richard M. Stallman  (rms at mit-prep)
5331
5332              * xdisp.c (try_window_id):
5333              If C-k is done at end of next-to-last line,
5334              this fn updates window_end_vpos and cannot leave
5335              window_end_pos nonnegative (it is zero, in fact).
5336              If display is preempted before lines are output,
5337              this is inconsistent.  Fix by setting
5338              blank_end_of_window to nonzero.
5339
5340      Tue Jun 25 05:25:33 1985  Richard M. Stallman  (rms at mit-prep)
5341
5342              * cmds.c (Fnewline):
5343              Call the auto fill hook if appropriate.
5344
5345              * xdisp.c (try_window_id):
5346              If point is found by compute_motion after xp, record that
5347              permanently.  If display_text_line sets point position wrong
5348              (case where line is killed, point is at eob and that line is
5349              not displayed), set it again in final compute_motion.
5350
5351 \1f
5352 File: xemacs.info,  Node: Tags,  Next: CC Mode,  Prev: Change Log,  Up: Programs
5353
5354 21.11 Tags Tables
5355 =================
5356
5357 A "tags table" is a description of how a multi-file program is broken
5358 up into files.  It lists the names of the component files and the names
5359 and positions of the functions (or other named subunits) in each file.
5360 Grouping the related files makes it possible to search or replace
5361 through all the files with one command.  Recording the function names
5362 and positions makes possible the `M-.' command which finds the
5363 definition of a function by looking up which of the files it is in.
5364
5365    Tags tables are stored in files called "tags table files".  The
5366 conventional name for a tags table file is `TAGS'.
5367
5368    Each entry in the tags table records the name of one tag, the name
5369 of the file that the tag is defined in (implicitly), and the position
5370 in that file of the tag's definition.
5371
5372    Just what names from the described files are recorded in the tags
5373 table depends on the programming language of the described file.  They
5374 normally include all functions and subroutines, and may also include
5375 global variables, data types, and anything else convenient.  Each name
5376 recorded is called a "tag".
5377
5378    The Ebrowse is a separate facility tailored for C++, with tags and a
5379 class browser.  *Note Top: (ebrowse)Top.
5380
5381 * Menu:
5382
5383 * Tag Syntax::          Tag syntax for various types of code and text files.
5384 * Create Tags Table::   Creating a tags table with `etags'.
5385 * Etags Regexps::       Create arbitrary tags using regular expressions.
5386 * Select Tags Table::   How to visit a tags table.
5387 * Find Tag::            Commands to find the definition of a specific tag.
5388 * Tags Search::         Using a tags table for searching and replacing.
5389 * List Tags::           Listing and finding tags defined in a file.
5390
5391 \1f
5392 File: xemacs.info,  Node: Tag Syntax,  Next: Create Tags Table,  Up: Tags
5393
5394 21.11.1 Source File Tag Syntax
5395 ------------------------------
5396
5397 Here is how tag syntax is defined for the most popular languages:
5398
5399    * In C code, any C function or typedef is a tag, and so are
5400      definitions of `struct', `union' and `enum'.  You can tag function
5401      declarations and external variables in addition to function
5402      definitions by giving the `--declarations' option to `etags'.
5403      `#define' macro definitions and `enum' constants are also tags,
5404      unless you specify `--no-defines' when making the tags table.
5405      Similarly, global variables are tags, unless you specify
5406      `--no-globals'.  Use of `--no-globals' and `--no-defines' can make
5407      the tags table file much smaller.
5408
5409    * In C++ code, in addition to all the tag constructs of C code,
5410      member functions are also recognized, and optionally member
5411      variables if you use the `--members' option.  Tags for variables
5412      and functions in classes are named `CLASS::VARIABLE' and
5413      `CLASS::FUNCTION'.  `operator' functions tags are named, for
5414      example `operator+'.
5415
5416    * In Java code, tags include all the constructs recognized in C++,
5417      plus the `interface', `extends' and `implements' constructs.  Tags
5418      for variables and functions in classes are named `CLASS.VARIABLE'
5419      and `CLASS.FUNCTION'.
5420
5421    * In LaTeX text, the argument of any of the commands `\chapter',
5422      `\section', `\subsection', `\subsubsection', `\eqno', `\label',
5423      `\ref', `\cite', `\bibitem', `\part', `\appendix', `\entry', or
5424      `\index', is a tag.
5425
5426      Other commands can make tags as well, if you specify them in the
5427      environment variable `TEXTAGS' before invoking `etags'.  The value
5428      of this environment variable should be a colon-separated list of
5429      command names.  For example,
5430
5431           TEXTAGS="def:newcommand:newenvironment"
5432           export TEXTAGS
5433
5434      specifies (using Bourne shell syntax) that the commands `\def',
5435      `\newcommand' and `\newenvironment' also define tags.
5436
5437    * In Lisp code, any function defined with `defun', any variable
5438      defined with `defvar' or `defconst', and in general the first
5439      argument of any expression that starts with `(def' in column zero,
5440      is a tag.
5441
5442    * In Scheme code, tags include anything defined with `def' or with a
5443      construct whose name starts with `def'.  They also include
5444      variables set with `set!' at top level in the file.
5445
5446    Several other languages are also supported:
5447
5448    * In Ada code, functions, procedures, packages, tasks, and types are
5449      tags.  Use the `--packages-only' option to create tags for
5450      packages only.
5451
5452      With Ada, it is possible to have the same name used for different
5453      entity kinds (e.g. the same name for a procedure and a function).
5454      Also, for things like packages, procedures and functions, there is
5455      the spec (i.e. the interface) and the body (i.e. the
5456      implementation).  To facilitate the choice to the user, a tag
5457      value is appended with a qualifier:
5458
5459     function
5460           `/f'
5461
5462     procedure
5463           `/p'
5464
5465     package spec
5466           `/s'
5467
5468     package body
5469           `/b'
5470
5471     type
5472           `/t'
5473
5474     task
5475           `/k'
5476
5477      So, as an example, `M-x find-tag bidule/b' will go directly to the
5478      body of the package BIDULE while `M-x find-tag bidule' will just
5479      search for any tag BIDULE.
5480
5481    * In assembler code, labels appearing at the beginning of a line,
5482      followed by a colon, are tags.
5483
5484    * In Bison or Yacc input files, each rule defines as a tag the
5485      nonterminal it constructs.  The portions of the file that contain
5486      C code are parsed as C code.
5487
5488    * In Cobol code, tags are paragraph names; that is, any word
5489      starting in column 8 and followed by a period.
5490
5491    * In Erlang code, the tags are the functions, records, and macros
5492      defined in the file.
5493
5494    * In Fortran code, functions, subroutines and blockdata are tags.
5495
5496    * In makefiles, targets are tags.
5497
5498    * In Objective C code, tags include Objective C definitions for
5499      classes, class categories, methods, and protocols.
5500
5501    * In Pascal code, the tags are the functions and procedures defined
5502      in the file.
5503
5504    * In Perl code, the tags are the procedures defined by the `sub',
5505      `my' and `local' keywords.  Use `--globals' if you want to tag
5506      global variables.
5507
5508    * In PostScript code, the tags are the functions.
5509
5510    * In Prolog code, a tag name appears at the left margin.
5511
5512    * In Python code, `def' or `class' at the beginning of a line
5513      generate a tag.
5514
5515    You can also generate tags based on regexp matching (*note Etags
5516 Regexps::) to handle other formats and languages.
5517
5518 \1f
5519 File: xemacs.info,  Node: Create Tags Table,  Next: Etags Regexps,  Prev: Tag Syntax,  Up: Tags
5520
5521 21.11.2 Creating Tags Tables
5522 ----------------------------
5523
5524 The `etags' program is used to create a tags table file.  It knows the
5525 syntax of several languages, as described in *Note Tag Syntax::.  Here
5526 is how to run `etags':
5527
5528      etags INPUTFILES...
5529
5530 The `etags' program reads the specified files, and writes a tags table
5531 named `TAGS' in the current working directory.  You can intermix
5532 compressed and plain text source file names.  `etags' knows about the
5533 most common compression formats, and does the right thing.  So you can
5534 compress all your source files and have `etags' look for compressed
5535 versions of its file name arguments, if it does not find uncompressed
5536 versions.  Under MS-DOS, `etags' also looks for file names like
5537 `mycode.cgz' if it is given `mycode.c' on the command line and
5538 `mycode.c' does not exist.
5539
5540    `etags' recognizes the language used in an input file based on its
5541 file name and contents.  You can specify the language with the
5542 `--language=NAME' option, described below.
5543
5544    If the tags table data become outdated due to changes in the files
5545 described in the table, the way to update the tags table is the same
5546 way it was made in the first place.  It is not necessary to do this
5547 often.
5548
5549    If the tags table fails to record a tag, or records it for the wrong
5550 file, then Emacs cannot possibly find its definition.  However, if the
5551 position recorded in the tags table becomes a little bit wrong (due to
5552 some editing in the file that the tag definition is in), the only
5553 consequence is a slight delay in finding the tag.  Even if the stored
5554 position is very wrong, Emacs will still find the tag, but it must
5555 search the entire file for it.
5556
5557    So you should update a tags table when you define new tags that you
5558 want to have listed, or when you move tag definitions from one file to
5559 another, or when changes become substantial.  Normally there is no need
5560 to update the tags table after each edit, or even every day.
5561
5562    One tags table can effectively include another.  Specify the included
5563 tags file name with the `--include=FILE' option when creating the file
5564 that is to include it.  The latter file then acts as if it contained
5565 all the files specified in the included file, as well as the files it
5566 directly contains.
5567
5568    If you specify the source files with relative file names when you run
5569 `etags', the tags file will contain file names relative to the
5570 directory where the tags file was initially written.  This way, you can
5571 move an entire directory tree containing both the tags file and the
5572 source files, and the tags file will still refer correctly to the source
5573 files.
5574
5575    If you specify absolute file names as arguments to `etags', then the
5576 tags file will contain absolute file names.  This way, the tags file
5577 will still refer to the same files even if you move it, as long as the
5578 source files remain in the same place.  Absolute file names start with
5579 `/', or with `DEVICE:/' on MS-DOS and MS-Windows.
5580
5581    When you want to make a tags table from a great number of files, you
5582 may have problems listing them on the command line, because some systems
5583 have a limit on its length.  The simplest way to circumvent this limit
5584 is to tell `etags' to read the file names from its standard input, by
5585 typing a dash in place of the file names, like this:
5586
5587      find . -name "*.[chCH]" -print | etags -
5588
5589    Use the option `--language=NAME' to specify the language explicitly.
5590 You can intermix these options with file names; each one applies to
5591 the file names that follow it.  Specify `--language=auto' to tell
5592 `etags' to resume guessing the language from the file names and file
5593 contents.  Specify `--language=none' to turn off language-specific
5594 processing entirely; then `etags' recognizes tags by regexp matching
5595 alone (*note Etags Regexps::).
5596
5597    `etags --help' prints the list of the languages `etags' knows, and
5598 the file name rules for guessing the language. It also prints a list of
5599 all the available `etags' options, together with a short explanation.
5600
5601 \1f
5602 File: xemacs.info,  Node: Etags Regexps,  Next: Select Tags Table,  Prev: Create Tags Table,  Up: Tags
5603
5604 21.11.3 Etags Regexps
5605 ---------------------
5606
5607 The `--regex' option provides a general way of recognizing tags based
5608 on regexp matching.  You can freely intermix it with file names.  Each
5609 `--regex' option adds to the preceding ones, and applies only to the
5610 following files.  The syntax is:
5611
5612      --regex=/TAGREGEXP[/NAMEREGEXP]/
5613
5614 where TAGREGEXP is used to match the lines to tag.  It is always
5615 anchored, that is, it behaves as if preceded by `^'.  If you want to
5616 account for indentation, just match any initial number of blanks by
5617 beginning your regular expression with `[ \t]*'.  In the regular
5618 expressions, `\' quotes the next character, and `\t' stands for the tab
5619 character.  Note that `etags' does not handle the other C escape
5620 sequences for special characters.
5621
5622    The syntax of regular expressions in `etags' is the same as in
5623 Emacs, augmented with the "interval operator", which works as in `grep'
5624 and `ed'.  The syntax of an interval operator is `\{M,N\}', and its
5625 meaning is to match the preceding expression at least M times and up to
5626 N times.
5627
5628    You should not match more characters with TAGREGEXP than that needed
5629 to recognize what you want to tag.  If the match is such that more
5630 characters than needed are unavoidably matched by TAGREGEXP (as will
5631 usually be the case), you should add a NAMEREGEXP, to pick out just the
5632 tag.  This will enable Emacs to find tags more accurately and to do
5633 completion on tag names more reliably.  You can find some examples
5634 below.
5635
5636    The option `--ignore-case-regex' (or `-c') is like `--regex', except
5637 that the regular expression provided will be matched without regard to
5638 case, which is appropriate for various programming languages.
5639
5640    The `-R' option deletes all the regexps defined with `--regex'
5641 options.  It applies to the file names following it, as you can see
5642 from the following example:
5643
5644      etags --regex=/REG1/ voo.doo --regex=/REG2/ \
5645          bar.ber -R --lang=lisp los.er
5646
5647 Here `etags' chooses the parsing language for `voo.doo' and `bar.ber'
5648 according to their contents.  `etags' also uses REG1 to recognize
5649 additional tags in `voo.doo', and both REG1 and REG2 to recognize
5650 additional tags in `bar.ber'.  `etags' uses the Lisp tags rules, and no
5651 regexp matching, to recognize tags in `los.er'.
5652
5653    A regular expression can be bound to a given language, by prepending
5654 it with `{lang}'.  When you do this, `etags' will use the regular
5655 expression only for files of that language.  `etags --help' prints the
5656 list of languages recognised by `etags'.  The following example tags
5657 the `DEFVAR' macros in the Emacs source files.  `etags' applies this
5658 regular expression to C files only:
5659
5660      --regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
5661
5662 This feature is particularly useful when storing a list of regular
5663 expressions in a file.  The following option syntax instructs `etags'
5664 to read two files of regular expressions.  The regular expressions
5665 contained in the second file are matched without regard to case.
5666
5667      --regex=@first-file --ignore-case-regex=@second-file
5668
5669 A regex file contains one regular expressions per line.  Empty lines,
5670 and lines beginning with space or tab are ignored.  When the first
5671 character in a line is `@', `etags' assumes that the rest of the line
5672 is the name of a file of regular expressions.  This means that such
5673 files can be nested.  All the other lines are taken to be regular
5674 expressions.  For example, one can create a file called `emacs.tags'
5675 with the following contents (the first line in the file is a comment):
5676
5677              -- This is for GNU Emacs source files
5678      {c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
5679
5680 and then use it like this:
5681
5682      etags --regex=@emacs.tags *.[ch] */*.[ch]
5683
5684    Here are some more examples.  The regexps are quoted to protect them
5685 from shell interpretation.
5686
5687    * Tag Octave files:
5688
5689           etags --language=none \
5690                 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
5691                 --regex='/###key \(.*\)/\1/' \
5692                 --regex='/[ \t]*global[ \t].*/' \
5693                 *.m
5694
5695      Note that tags are not generated for scripts so that you have to
5696      add a line by yourself of the form `###key <script-name>' if you
5697      want to jump to it.
5698
5699    * Tag Tcl files:
5700
5701           etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
5702
5703    * Tag VHDL files:
5704
5705           --language=none \
5706           --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
5707           --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
5708           \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
5709
5710 \1f
5711 File: xemacs.info,  Node: Select Tags Table,  Next: Find Tag,  Prev: Etags Regexps,  Up: Tags
5712
5713 21.11.4 Selecting a Tags Table
5714 ------------------------------
5715
5716 At any time Emacs has one "selected" tags table, and all the commands
5717 for working with tags tables use the selected one.  To select a tags
5718 table, use the variable `tag-table-alist'.
5719
5720    The value of `tag-table-alist' is a list that determines which
5721 `TAGS' files should be active for a given buffer.  This is not really
5722 an association list, in that all elements are checked.  The car of each
5723 element of this list is a pattern against which the buffers file name
5724 is compared; if it matches, then the cdr of the list should be the name
5725 of the tags table to use.  If more than one element of this list
5726 matches the buffers file name, all of the associated tags tables are
5727 used.  Earlier ones are searched first.
5728
5729    If the car of elements of this list are strings, they are treated as
5730 regular-expressions against which the file is compared (like the
5731 `auto-mode-alist').  If they are not strings, they are evaluated.  If
5732 they evaluate to non-`nil', the current buffer is considered to match.
5733
5734    If the cdr of the elements of this list are strings, they are
5735 assumed to name a tags file.  If they name a directory, the string
5736 `tags' is appended to them to get the file name.  If they are not
5737 strings, they are evaluated and must return an appropriate string.
5738
5739    For example:
5740
5741        (setq tag-table-alist
5742              '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
5743                ("\\.el$" . "/usr/local/emacs/src/")
5744                ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
5745                ("" . "/usr/local/emacs/src/")
5746                ))
5747
5748    The example defines the tags table alist in the following way:
5749
5750    * Anything in the directory `/usr/src/public/perl/' should use the
5751      `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
5752
5753    * Files ending in `.el' should use the `TAGS' file
5754      `/usr/local/emacs/src/TAGS'.
5755
5756    * Anything in or below the directory `/jbw/gnu/' should use the
5757      `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
5758
5759    If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
5760 files,
5761 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
5762 that order), because it matches both patterns.
5763
5764    If the buffer-local variable `buffer-tag-table' is set, it names a
5765 tags table that is searched before all others when `find-tag' is
5766 executed from this buffer.
5767
5768    If there is a file called `TAGS' in the same directory as the file
5769 in question, then that tags file will always be used as well (after the
5770 `buffer-tag-table' but before the tables specified by this list).
5771
5772    If the variable `tags-file-name' is set, the `TAGS' file it names
5773 will apply to all buffers (for backwards compatibility.)  It is searched
5774 first.
5775
5776    If the value of the variable `tags-always-build-completion-table' is
5777 `t', the tags file will always be added to the completion table without
5778 asking first, regardless of the size of the tags file.
5779
5780    The function `M-x visit-tags-table', is largely made obsolete by the
5781 variable `tag-table-alist', tells tags commands to use the tags table
5782 file FILE first.  The FILE should be the name of a file created with
5783 the `etags' program.  A directory name is also acceptable; it means the
5784 file `TAGS' in that directory.  The function only stores the file name
5785 you provide in the variable `tags-file-name'.  Emacs does not actually
5786 read in the tags table contents until you try to use them.  You can set
5787 the variable explicitly instead of using `visit-tags-table'.  The value
5788 of the variable `tags-file-name' is the name of the tags table used by
5789 all buffers.  This is for backward compatibility, and is largely
5790 supplanted by the variable `tag-table-alist'.
5791
5792 \1f
5793 File: xemacs.info,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tags Table,  Up: Tags
5794
5795 21.11.5 Finding a Tag
5796 ---------------------
5797
5798 The most important thing that a tags table enables you to do is to find
5799 the definition of a specific tag.
5800
5801 `M-. TAG &OPTIONAL OTHER-WINDOW'
5802      Find first definition of TAG (`find-tag').
5803
5804 `C-u M-.'
5805      Find next alternate definition of last tag specified.
5806
5807 `C-x 4 . TAG'
5808      Find first definition of TAG, but display it in another window
5809      (`find-tag-other-window').
5810
5811    `M-.' (`find-tag') is the command to find the definition of a
5812 specified tag.  It searches through the tags table for that tag, as a
5813 string, then uses the tags table information to determine the file in
5814 which the definition is used and the approximate character position of
5815 the definition in the file.  Then `find-tag' visits the file, moves
5816 point to the approximate character position, and starts searching
5817 ever-increasing distances away for the text that should appear at the
5818 beginning of the definition.
5819
5820    If an empty argument is given (by typing <RET>), the sexp in the
5821 buffer before or around point is used as the name of the tag to find.
5822 *Note Lists::, for information on sexps.
5823
5824    The argument to `find-tag' need not be the whole tag name; it can be
5825 a substring of a tag name.  However, there can be many tag names
5826 containing the substring you specify.  Since `find-tag' works by
5827 searching the text of the tags table, it finds the first tag in the
5828 table that the specified substring appears in.  To find other tags that
5829 match the substring, give `find-tag' a numeric argument, as in `C-u
5830 M-.'.  This does not read a tag name, but continues searching the tag
5831 table's text for another tag containing the same substring last used.
5832 If your keyboard has a real <META> key, `M-0 M-.' is an easier
5833 alternative to `C-u M-.'.
5834
5835    If the optional second argument OTHER-WINDOW is non-`nil', it uses
5836 another window to display the tag.  Multiple active tags tables and
5837 completion are supported.
5838
5839    Variables of note include the following:
5840
5841 `tag-table-alist'
5842      Controls which tables apply to which buffers.
5843
5844 `tags-file-name'
5845      Stores a default tags table.
5846
5847 `tags-build-completion-table'
5848      Controls completion behavior.
5849
5850 `buffer-tag-table'
5851      Specifies a buffer-local table.
5852
5853 `make-tags-files-invisible'
5854      Sets whether tags tables should be very hidden.
5855
5856 `tag-mark-stack-max'
5857      Specifies how many tags-based hops to remember.
5858
5859    Like most commands that can switch buffers, `find-tag' has another
5860 similar command that displays the new buffer in another window.  `C-x 4
5861 .' invokes the function `find-tag-other-window'.  (This key sequence
5862 ends with a period.)
5863
5864    Emacs comes with a tags table file `TAGS' (in the directory
5865 containing Lisp libraries) that includes all the Lisp libraries and all
5866 the C sources of Emacs.  By specifying this file with `visit-tags-table'
5867 and then using `M-.' you can quickly look at the source of any Emacs
5868 function.
5869
5870 \1f
5871 File: xemacs.info,  Node: Tags Search,  Next: List Tags,  Prev: Find Tag,  Up: Tags
5872
5873 21.11.6 Searching and Replacing with Tags Tables
5874 ------------------------------------------------
5875
5876 The commands in this section visit and search all the files listed in
5877 the selected tags table, one by one.  For these commands, the tags
5878 table serves only to specify a sequence of files to search.  A related
5879 command is `M-x grep' (*note Compilation::).
5880
5881 `M-x tags-search <RET> REGEXP <RET>'
5882      Search for REGEXP through the files in the selected tags table.
5883
5884 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
5885      Perform a `query-replace-regexp' on each file in the selected tags
5886      table.
5887
5888 `M-,'
5889      Restart one of the commands above, from the current location of
5890      point (`tags-loop-continue').
5891
5892    `M-x tags-search' reads a regexp using the minibuffer, then searches
5893 for matches in all the files in the selected tags table, one file at a
5894 time.  It displays the name of the file being searched so you can
5895 follow its progress.  As soon as it finds an occurrence, `tags-search'
5896 returns.
5897
5898    Having found one match, you probably want to find all the rest.  To
5899 find one more match, type `M-,' (`tags-loop-continue') to resume the
5900 `tags-search'.  This searches the rest of the current buffer, followed
5901 by the remaining files of the tags table.
5902
5903    `M-x tags-query-replace' performs a single `query-replace-regexp'
5904 through all the files in the tags table.  It reads a regexp to search
5905 for and a string to replace with, just like ordinary `M-x
5906 query-replace-regexp'.  It searches much like `M-x tags-search', but
5907 repeatedly, processing matches according to your input.  *Note
5908 Replace::, for more information on query replace.
5909
5910    It is possible to get through all the files in the tags table with a
5911 single invocation of `M-x tags-query-replace'.  But often it is useful
5912 to exit temporarily, which you can do with any input event that has no
5913 special query replace meaning.  You can resume the query replace
5914 subsequently by typing `M-,'; this command resumes the last tags search
5915 or replace command that you did.
5916
5917    The commands in this section carry out much broader searches than the
5918 `find-tag' family.  The `find-tag' commands search only for definitions
5919 of tags that match your substring or regexp.  The commands
5920 `tags-search' and `tags-query-replace' find every occurrence of the
5921 regexp, as ordinary search commands and replace commands do in the
5922 current buffer.
5923
5924    These commands create buffers only temporarily for the files that
5925 they have to search (those which are not already visited in Emacs
5926 buffers).  Buffers in which no match is found are quickly killed; the
5927 others continue to exist.
5928
5929    It may have struck you that `tags-search' is a lot like `grep'.  You
5930 can also run `grep' itself as an inferior of Emacs and have Emacs show
5931 you the matching lines one by one.  This works much like running a
5932 compilation; finding the source locations of the `grep' matches works
5933 like finding the compilation errors.  *Note Compilation::.
5934
5935    If you wish to process all the files in a selected tags table, but
5936 `M-x tags-search' and `M-x tags-query-replace' are not giving you the
5937 desired result, you can use `M-x next-file'.
5938
5939 `C-u M-x next-file'
5940      With a numeric argument, regardless of its value, visit the first
5941      file in the tags table and prepare to advance sequentially by
5942      files.
5943
5944 `M-x next-file'
5945      Visit the next file in the selected tags table.
5946
5947 \1f
5948 File: xemacs.info,  Node: List Tags,  Prev: Tags Search,  Up: Tags
5949
5950 21.11.7 Tags Table Inquiries
5951 ----------------------------
5952
5953 `M-x list-tags'
5954      Display a list of the tags defined in a specific program file.
5955
5956 `M-x tags-apropos'
5957      Display a list of all tags matching a specified regexp.
5958
5959    `M-x list-tags' reads the name of one of the files described by the
5960 selected tags table, and displays a list of all the tags defined in that
5961 file.  The "file name" argument is really just a string to compare
5962 against the names recorded in the tags table; it is read as a string
5963 rather than a file name.  Therefore, completion and defaulting are not
5964 available, and you must enter the string the same way it appears in the
5965 tag table.  Do not include a directory as part of the file name unless
5966 the file name recorded in the tags table contains that directory.
5967
5968    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
5969 then finds all the tags in the selected tags table whose entries match
5970 that regexp, and displays the tag names found.
5971
5972 \1f
5973 File: xemacs.info,  Node: CC Mode,  Next: Fortran,  Prev: Tags,  Up: Programs
5974
5975 21.12 Modes for C, C++, Java and similar languages
5976 ==================================================
5977
5978 The recommended means for supporting the "C-like" programming languages
5979 in XEmacs is the `cc-mode' package.  CC Mode is not included in the
5980 basic XEmacs distribution but is available as an optional package. If
5981 loading a file whose names ends in the `.cc' extension does not
5982 automatically invoke a C++ Mode then the `cc-mode' package is probably
5983 not yet installed. *Note Packages::.
5984
5985    CC Mode provides modes for editing source files in Awk (`awk-mode'),
5986 C (`c-mode'), C++ (`c++-mode'), CORBA IDL (`idl-mode'), Java
5987 (`java-mode'), Objective C (`objc-mode'), and Pike (`pike-mode'). All
5988 these languages are supported with an sophisticated "indentation
5989 engine" that is feature rich, customizable and quite efficient.
5990
5991    Each language major mode runs hooks in the conventionally named hook
5992 variables (*note Mode Hooks::). In addition to this conventional
5993 behavior all the CC Mode major modes will also run hooks in
5994 `c-mode-common-hook' _before_ invoking the major mode specific hook.
5995
5996    CC Mode runs any hooks in `c-initialization-hook' exactly once when
5997 it is first loaded.
5998
5999    CC Mode is a very comprehensive and flexible system and full
6000 description of its capabilities is beyond the scope of this manual.  It
6001 is strongly recommended that the reader consult the CC Mode
6002 documentation for details once the package has been installed. *Note CC
6003 Mode: (cc-mode)Top.
6004
6005 * Menu:
6006
6007 * Older Modes::             Older Modes for C and AWK
6008 * Customizing CC Mode::     An Introduction to Customizing CC Mode.
6009
6010 \1f
6011 File: xemacs.info,  Node: Older Modes,  Next: Customizing CC Mode,  Prev: CC Mode,  Up: CC Mode
6012
6013 21.12.1 Older Modes for C and AWK
6014 ---------------------------------
6015
6016 XEmacs provides older versions of a C Mode and an AWK Mode in the
6017 `prog-modes' package. These older modes do not share the indentation
6018 engine in CC Mode have have their own specific means of customizing
6019 indentation. To use these modes the `prog-modes' package must be
6020 installed.
6021
6022    This older C mode is known simply as the "Old C Mode". It supports
6023 only the C language and it lacks many of the features of CC Mode.
6024 However the old C mode offers modest space requirements and very fast
6025 operation.  Old C Mode might be useful in space constrained
6026 environments, on slow machines, or for editing very large files. This
6027 old C mode is available in the `old-c-mode' library. *Note Old C Mode:
6028 (prog-modes)old-c-mode.
6029
6030    The old AWK mode exists for similar reasons. It is available in the
6031 `awk-mode' library.  *Note Old AWK Mode: (prog-modes)awk-mode.
6032
6033    Note that the prog-modes package will never automatically invoke
6034 these older modes for a user. However installing the `cc-mode' package
6035 _will_ make CC Mode's versions available automatically.  As a result a
6036 user who wants to use these older modes must explicitly load the old
6037 libraries to use them.
6038
6039 \1f
6040 File: xemacs.info,  Node: Customizing CC Mode,  Prev: Older Modes,  Up: CC Mode
6041
6042 21.12.2 Customizing Indentation in CC Mode
6043 ------------------------------------------
6044
6045 A very brief introduction is included here on customizing CC Mode. CC
6046 Mode has many features, including useful minor modes, that are
6047 completely documented in its own manual.
6048
6049    CC Mode implements several different "styles" for C code (and the
6050 other languages supported by CC Mode). If you need to change the
6051 indentation style for CC Mode it is recommended that you first see if an
6052 existing style meets your requirements. The style chosen will affect the
6053 placement of language elements like braces, function declarations and
6054 comments. You can choose a style interactively by typing `C-c .' and
6055 pressing the space bar at the prompt to get a list of supported styles.
6056 `C-c .' runs the function `c-set-style' which applies to all CC Mode
6057 language modes though its name might suggest otherwise. A few of the
6058 the supported styles are listed below.
6059
6060    * "gnu" -- The recommeded style from the Free Software Foundation for
6061      GNU software.
6062
6063    * "k&r" -- The classic style from Kernighan and Ritchie.
6064
6065    * "linux" -- The style recommended for code in the Linux kernel.
6066
6067    * "bsd" -- The style recommended for software developed in BSD.
6068
6069    * "java -- The "traditional" Java style.
6070
6071    The default style in XEmacs is "gnu" except for Java mode where it
6072 is the "java" style (this is governed by the variable
6073 `c-default-style').
6074
6075    The styles included in CC Mode all use a buffer local variable called
6076 `c-basic-offset' as the basic indentation level (this buffer local
6077 variable is used in all CC Mode language modes though its name might
6078 suggest otherwise). All indentation is, by default, expressed in
6079 multiples of `c-basic-offset'.
6080
6081    Each style defines a default value for `c-basic-offset', for the
6082 "gnu" style sets it to 2. A very common customization scenario is where
6083 a user wants to use an existing style but with a different basic offset
6084 value. An easy way to do this is to set `c-basic-offset' in the
6085 language mode hook after selecting the chosen style.
6086
6087    For example, a user might want to follow a local coding convention of
6088 using the "k&r" style for C code with indentation in two columns
6089 multiples (instead of the five column default provided by the CC Mode
6090 "k&r" style). This can be achieved with the following code in the
6091 initialization file (*note Init File::)
6092
6093      (defun my-c-mode-hook ()
6094        (c-set-style "k&r")
6095        (setq c-basic-offset 2))
6096      (add-hook 'c-mode-hook 'my-c-mode-hook)
6097
6098    Most customizations for indentation in various CC modes can be
6099 accomplished by choosing a style and then choosing value for
6100 `c-basic-offset' that meets the local coding convention. CC Mode has a
6101 very customizable indentation engine and a furthur discussion is really
6102 beyond the scope of this manual. *Note Indentation Engine:
6103 (cc-mode)Indentation Engine.
6104
6105 \1f
6106 File: xemacs.info,  Node: Fortran,  Next: Asm Mode,  Prev: CC Mode,  Up: Programs
6107
6108 21.13 Fortran Mode
6109 ==================
6110
6111 Fortran mode provides special motion commands for Fortran statements and
6112 subprograms, and indentation commands that understand Fortran
6113 conventions of nesting, line numbers, and continuation statements.
6114
6115    Special commands for comments are provided because Fortran comments
6116 are unlike those of other languages.
6117
6118    Built-in abbrevs optionally save typing when you insert Fortran
6119 keywords.
6120
6121    Use `M-x fortran-mode' to switch to this major mode.  Doing so calls
6122 the value of `fortran-mode-hook' as a function of no arguments if that
6123 variable has a non-`nil' value.
6124
6125 * Menu:
6126
6127 * Motion: Fortran Motion.     Moving point by statements or subprograms.
6128 * Indent: Fortran Indent.     Indentation commands for Fortran.
6129 * Comments: Fortran Comments. Inserting and aligning comments.
6130 * Columns: Fortran Columns.   Measuring columns for valid Fortran.
6131 * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
6132
6133    Fortran mode was contributed by Michael Prange.
6134
6135 \1f
6136 File: xemacs.info,  Node: Fortran Motion,  Next: Fortran Indent,  Prev: Fortran,  Up: Fortran
6137
6138 21.13.1 Motion Commands
6139 -----------------------
6140
6141 Fortran mode provides special commands to move by subprograms (functions
6142 and subroutines) and by statements.  There is also a command to put the
6143 region around one subprogram, which is convenient for killing it or
6144 moving it.
6145
6146 `C-M-a'
6147      Move to beginning of subprogram
6148      (`beginning-of-fortran-subprogram').
6149
6150 `C-M-e'
6151      Move to end of subprogram (`end-of-fortran-subprogram').
6152
6153 `C-M-h'
6154      Put point at beginning of subprogram and mark at end
6155      (`mark-fortran-subprogram').
6156
6157 `C-c C-n'
6158      Move to beginning of current or next statement (`fortran-next-
6159      statement').
6160
6161 `C-c C-p'
6162      Move to beginning of current or previous statement (`fortran-
6163      previous-statement').
6164
6165 \1f
6166 File: xemacs.info,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
6167
6168 21.13.2 Fortran Indentation
6169 ---------------------------
6170
6171 Special commands and features are available for indenting Fortran code.
6172 They make sure various syntactic entities (line numbers, comment line
6173 indicators, and continuation line flags) appear in the columns that are
6174 required for standard Fortran.
6175
6176 * Menu:
6177
6178 * Commands: ForIndent Commands. Commands for indenting Fortran.
6179 * Numbers:  ForIndent Num.      How line numbers auto-indent.
6180 * Conv:     ForIndent Conv.     Conventions you must obey to avoid trouble.
6181 * Vars:     ForIndent Vars.     Variables controlling Fortran indent style.
6182
6183 \1f
6184 File: xemacs.info,  Node: ForIndent Commands,  Next: ForIndent Num,  Prev: Fortran Indent,  Up: Fortran Indent
6185
6186 21.13.2.1 Fortran Indentation Commands
6187 ......................................
6188
6189 `<TAB>'
6190      Indent the current line (`fortran-indent-line').
6191
6192 `M-<LFD>'
6193      Break the current line and set up a continuation line.
6194
6195 `C-M-q'
6196      Indent all the lines of the subprogram point is in
6197      (`fortran-indent-subprogram').
6198
6199    <TAB> is redefined by Fortran mode to reindent the current line for
6200 Fortran (`fortran-indent-line').  Line numbers and continuation markers
6201 are indented to their required columns, and the body of the statement
6202 is independently indented, based on its nesting in the program.
6203
6204    The key `C-M-q' is redefined as `fortran-indent-subprogram', a
6205 command that reindents all the lines of the Fortran subprogram
6206 (function or subroutine) containing point.
6207
6208    The key `M-<LFD>' is redefined as `fortran-split-line', a command to
6209 split a line in the appropriate fashion for Fortran.  In a non-comment
6210 line, the second half becomes a continuation line and is indented
6211 accordingly.  In a comment line, both halves become separate comment
6212 lines.
6213
6214 \1f
6215 File: xemacs.info,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Commands,  Up: Fortran Indent
6216
6217 21.13.2.2 Line Numbers and Continuation
6218 .......................................
6219
6220 If a number is the first non-whitespace in the line, it is assumed to be
6221 a line number and is moved to columns 0 through 4.  (Columns are always
6222 counted from 0 in XEmacs.)  If the text on the line starts with the
6223 conventional Fortran continuation marker `$', it is moved to column 5.
6224 If the text begins with any non whitespace character in column 5, it is
6225 assumed to be an unconventional continuation marker and remains in
6226 column 5.
6227
6228    Line numbers of four digits or less are normally indented one space.
6229 This amount is controlled by the variable `fortran-line-number-indent',
6230 which is the maximum indentation a line number can have.  Line numbers
6231 are indented to right-justify them to end in column 4 unless that would
6232 require more than the maximum indentation.  The default value of the
6233 variable is 1.
6234
6235    Simply inserting a line number is enough to indent it according to
6236 these rules.  As each digit is inserted, the indentation is recomputed.
6237 To turn off this feature, set the variable
6238 `fortran-electric-line-number' to `nil'.  Then inserting line numbers
6239 is like inserting anything else.
6240
6241 \1f
6242 File: xemacs.info,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
6243
6244 21.13.2.3 Syntactic Conventions
6245 ...............................
6246
6247 Fortran mode assumes that you follow certain conventions that simplify
6248 the task of understanding a Fortran program well enough to indent it
6249 properly:
6250
6251    * Two nested `do' loops never share a `continue' statement.
6252
6253    * The same character appears in column 5 of all continuation lines.
6254      It is the value of the variable `fortran-continuation-char'.  By
6255      default, this character is `$'.
6256
6257 If you fail to follow these conventions, the indentation commands may
6258 indent some lines unaesthetically.  However, a correct Fortran program
6259 will retain its meaning when reindented even if the conventions are not
6260 followed.
6261
6262 \1f
6263 File: xemacs.info,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
6264
6265 21.13.2.4 Variables for Fortran Indentation
6266 ...........................................
6267
6268 Several additional variables control how Fortran indentation works.
6269
6270 `fortran-do-indent'
6271      Extra indentation within each level of `do' statement (the default
6272      is 3).
6273
6274 `fortran-if-indent'
6275      Extra indentation within each level of `if' statement (the default
6276      is 3).
6277
6278 `fortran-continuation-indent'
6279      Extra indentation for bodies of continuation lines (the default is
6280      5).
6281
6282 `fortran-check-all-num-for-matching-do'
6283      If this is `nil', indentation assumes that each `do' statement
6284      ends on a `continue' statement.  Therefore, when computing
6285      indentation for a statement other than `continue', it can save
6286      time by not checking for a `do' statement ending there.  If this
6287      is non-`nil', indenting any numbered statement must check for a
6288      `do' that ends there.  The default is `nil'.
6289
6290 `fortran-minimum-statement-indent'
6291      Minimum indentation for Fortran statements.  For standard Fortran,
6292      this is 6.  Statement bodies are always indented at least this
6293      much.
6294
6295 \1f
6296 File: xemacs.info,  Node: Fortran Comments,  Next: Fortran Columns,  Prev: Fortran Indent,  Up: Fortran
6297
6298 21.13.3 Comments
6299 ----------------
6300
6301 The usual Emacs comment commands assume that a comment can follow a line
6302 of code.  In Fortran, the standard comment syntax requires an entire
6303 line to be just a comment.  Therefore, Fortran mode replaces the
6304 standard Emacs comment commands and defines some new variables.
6305
6306    Fortran mode can also handle a non-standard comment syntax where
6307 comments start with `!' and can follow other text.  Because only some
6308 Fortran compilers accept this syntax, Fortran mode will not insert such
6309 comments unless you have specified to do so in advance by setting the
6310 variable `comment-start' to `"!"' (*note Variables::).
6311
6312 `M-;'
6313      Align comment or insert new comment (`fortran-comment-indent').
6314
6315 `C-x ;'
6316      Applies to nonstandard `!' comments only.
6317
6318 `C-c ;'
6319      Turn all lines of the region into comments, or (with arg) turn
6320      them back into real code (`fortran-comment-region').
6321
6322    `M-;' in Fortran mode is redefined as the command
6323 `fortran-comment-indent'.  Like the usual `M-;' command, it recognizes
6324 an existing comment and aligns its text appropriately.  If there is no
6325 existing comment, a comment is inserted and aligned.
6326
6327    Inserting and aligning comments is not the same in Fortran mode as in
6328 other modes.  When a new comment must be inserted, a full-line comment
6329 is inserted if the current line is blank.  On a non-blank line, a
6330 non-standard `!' comment is inserted if you previously specified you
6331 wanted to use them.  Otherwise a full-line comment is inserted on a new
6332 line before the current line.
6333
6334    Non-standard `!' comments are aligned like comments in other
6335 languages, but full-line comments are aligned differently.  In a
6336 standard full-line comment, the comment delimiter itself must always
6337 appear in column zero.  What can be aligned is the text within the
6338 comment.  You can choose from three styles of alignment by setting the
6339 variable `fortran-comment-indent-style' to one of these values:
6340
6341 `fixed'
6342      The text is aligned at a fixed column, which is the value of
6343      `fortran-comment-line-column'.  This is the default.
6344
6345 `relative'
6346      The text is aligned as if it were a line of code, but with an
6347      additional `fortran-comment-line-column' columns of indentation.
6348
6349 `nil'
6350      Text in full-line columns is not moved automatically.
6351
6352    You can also specify the character to be used to indent within
6353 full-line comments by setting the variable `fortran-comment-indent-char'
6354 to the character you want to use.
6355
6356    Fortran mode introduces two variables `comment-line-start' and
6357 `comment-line-start-skip', which do for full-line comments what
6358 `comment-start' and `comment-start-skip' do for ordinary text-following
6359 comments.  Normally these are set properly by Fortran mode, so you do
6360 not need to change them.
6361
6362    The normal Emacs comment command `C-x ;' has not been redefined.  It
6363 can therefore be used if you use `!' comments, but is useless in
6364 Fortran mode otherwise.
6365
6366    The command `C-c ;' (`fortran-comment-region') turns all the lines
6367 of the region into comments by inserting the string `C$$$' at the front
6368 of each one.  With a numeric arg, the region is turned back into live
6369 code by deleting `C$$$' from the front of each line.  You can control
6370 the string used for the comments by setting the variable
6371 `fortran-comment-region'.  Note that here we have an example of a
6372 command and a variable with the same name; the two uses of the name
6373 never conflict because in Lisp and in Emacs it is always clear from the
6374 context which one is referred to.
6375
6376 \1f
6377 File: xemacs.info,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Comments,  Up: Fortran
6378
6379 21.13.4 Columns
6380 ---------------
6381
6382 `C-c C-r'
6383      Displays a "column ruler" momentarily above the current line
6384      (`fortran-column-ruler').
6385
6386 `C-c C-w'
6387      Splits the current window horizontally so that it is 72 columns
6388      wide.  This may help you avoid going over that limit
6389      (`fortran-window-create').
6390
6391    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
6392 above the current line.  The comment ruler consists of two lines of
6393 text that show you the locations of columns with special significance
6394 in Fortran programs.  Square brackets show the limits of the columns for
6395 line numbers, and curly brackets show the limits of the columns for the
6396 statement body.  Column numbers appear above them.
6397
6398    Note that the column numbers count from zero, as always in XEmacs.
6399 As a result, the numbers may not be those you are familiar with; but the
6400 actual positions in the line are standard Fortran.
6401
6402    The text used to display the column ruler is the value of the
6403 variable `fortran-comment-ruler'.  By changing this variable, you can
6404 change the display.
6405
6406    For even more help, use `C-c C-w' (`fortran-window-create'), a
6407 command which splits the current window horizontally, resulting in a
6408 window 72 columns wide.  When you edit in this window, you can
6409 immediately see when a line gets too wide to be correct Fortran.
6410
6411 \1f
6412 File: xemacs.info,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
6413
6414 21.13.5 Fortran Keyword Abbrevs
6415 -------------------------------
6416
6417 Fortran mode provides many built-in abbrevs for common keywords and
6418 declarations.  These are the same sort of abbrevs that you can define
6419 yourself.  To use them, you must turn on Abbrev mode.  *note Abbrevs::.
6420
6421    The built-in abbrevs are unusual in one way: they all start with a
6422 semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
6423 mode makes this possible by changing the syntax of semicolon to "word
6424 constituent".
6425
6426    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
6427 you insert `;c' and then insert a punctuation character such as a space
6428 or a newline, the `;c' changes automatically to `continue', provided
6429 Abbrev mode is enabled.
6430
6431    Type `;?' or `;C-h' to display a list of all built-in Fortran
6432 abbrevs and what they stand for.
6433
6434 \1f
6435 File: xemacs.info,  Node: Asm Mode,  Prev: Fortran,  Up: Programs
6436
6437 21.14 Asm Mode
6438 ==============
6439
6440 Asm mode is a major mode for editing files of assembler code.  It
6441 defines these commands:
6442
6443 `<TAB>'
6444      `tab-to-tab-stop'.
6445
6446 `<LFD>'
6447      Insert a newline and then indent using `tab-to-tab-stop'.
6448
6449 `:'
6450      Insert a colon and then remove the indentation from before the
6451      label preceding colon.  Then do `tab-to-tab-stop'.
6452
6453 `;'
6454      Insert or align a comment.
6455
6456    The variable `asm-comment-char' specifies which character starts
6457 comments in assembler syntax.
6458
6459 \1f
6460 File: xemacs.info,  Node: Running,  Next: Abbrevs,  Prev: Programs,  Up: Top
6461
6462 22 Compiling and Testing Programs
6463 *********************************
6464
6465 The previous chapter discusses the Emacs commands that are useful for
6466 making changes in programs.  This chapter deals with commands that
6467 assist in the larger process of developing and maintaining programs.
6468
6469 * Menu:
6470
6471 * Compilation::        Compiling programs in languages other than Lisp
6472                         (C, Pascal, etc.)
6473 * Modes: Lisp Modes.   Various modes for editing Lisp programs, with
6474                        different facilities for running the Lisp programs.
6475 * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
6476 * Eval: Lisp Eval.     Executing a single Lisp expression in Emacs.
6477 * Debug: Lisp Debug.   Debugging Lisp programs running in Emacs.
6478 * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
6479 * External Lisp::      Communicating through Emacs with a separate Lisp.
6480
6481 \1f
6482 File: xemacs.info,  Node: Compilation,  Next: Lisp Modes,  Prev: Running,  Up: Running
6483
6484 22.1 Running "make", or Compilers Generally
6485 ===========================================
6486
6487 Emacs can run compilers for non-interactive languages like C and
6488 Fortran as inferior processes, feeding the error log into an Emacs
6489 buffer.  It can also parse the error messages and visit the files in
6490 which errors are found, moving point to the line where the error
6491 occurred.
6492
6493 `M-x compile'
6494      Run a compiler asynchronously under Emacs, with error messages to
6495      `*compilation*' buffer.
6496
6497 `M-x grep'
6498      Run `grep' asynchronously under Emacs, with matching lines listed
6499      in the buffer named `*compilation*'.
6500
6501 `M-x kill-compilation'
6502      Kill the process made by the `M-x compile' command.
6503
6504 `M-x kill-grep'
6505      Kill the running compilation or `grep' subprocess.
6506
6507 `C-x `'
6508      Visit the next compiler error message or `grep' match.
6509
6510    To run `make' or another compiler, type `M-x compile'.  This command
6511 reads a shell command line using the minibuffer, then executes the
6512 specified command line in an inferior shell with output going to the
6513 buffer named `*compilation*'.  By default, the current buffer's default
6514 directory is used as the working directory for the execution of the
6515 command; therefore, the makefile comes from this directory.
6516
6517    When the shell command line is read, the minibuffer appears
6518 containing a default command line (the command you used the last time
6519 you typed `M-x compile').  If you type just <RET>, the same command
6520 line is used again.  The first `M-x compile' provides `make -k' as the
6521 default.  The default is taken from the variable `compile-command'; if
6522 the appropriate compilation command for a file is something other than
6523 `make -k', it can be useful to have the file specify a local value for
6524 `compile-command' (*note File Variables::).
6525
6526    When you start a compilation, the buffer `*compilation*' is
6527 displayed in another window but not selected.  Its mode line displays
6528 the word `run' or `exit' in the parentheses to tell you whether
6529 compilation is finished.  You do not have to keep this buffer visible;
6530 compilation continues in any case.
6531
6532    To kill the compilation process, type `M-x kill-compilation'.  The
6533 mode line of the `*compilation*' buffer changes to say `signal' instead
6534 of `run'.  Starting a new compilation also kills any running
6535 compilation, as only one can occur at any time.  Starting a new
6536 compilation prompts for confirmation before actually killing a
6537 compilation that is running.
6538
6539    To parse the compiler error messages, type `C-x `' (`next-error').
6540 The character following `C-x' is the grave accent, not the single
6541 quote.  The command displays the buffer `*compilation*' in one window
6542 and the buffer in which the next error occurred in another window.
6543 Point in that buffer is moved to the line where the error was found.
6544 The corresponding error message is scrolled to the top of the window in
6545 which `*compilation*' is displayed.
6546
6547    The first time you use `C-x `' after the start of a compilation, it
6548 parses all the error messages, visits all the files that have error
6549 messages, and creates markers pointing at the lines the error messages
6550 refer to.  It then moves to the first error message location.
6551 Subsequent uses of `C-x `' advance down the data set up by the first
6552 use.  When the preparsed error messages are exhausted, the next `C-x `'
6553 checks for any more error messages that have come in; this is useful if
6554 you start editing compiler errors while compilation is still going on.
6555 If no additional error messages have come in, `C-x `' reports an error.
6556
6557    `C-u C-x `' discards the preparsed error message data and parses the
6558 `*compilation*' buffer again, then displays the first error.  This way,
6559 you can process the same set of errors again.
6560
6561    Instead of running a compiler, you can run `grep' and see the lines
6562 on which matches were found.  To do this, type `M-x grep' with an
6563 argument line that contains the same arguments you would give to
6564 `grep': a `grep'-style regexp (usually in single quotes to quote the
6565 shell's special characters) followed by filenames, which may use
6566 wildcard characters.  The output from `grep' goes in the
6567 `*compilation*' buffer.  You can use `C-x `' to find the lines that
6568 match as if they were compilation errors.
6569
6570    Note: a shell is used to run the compile command, but the shell is
6571 not run in interactive mode.  In particular, this means that the shell
6572 starts up with no prompt.  If you find your usual shell prompt making an
6573 unsightly appearance in the `*compilation*' buffer, it means you have
6574 made a mistake in your shell's initialization file (`.cshrc' or `.shrc'
6575 or ...) by setting the prompt unconditionally.  The shell
6576 initialization file should set the prompt only if there already is a
6577 prompt.  Here's how to do it in `csh':
6578
6579      if ($?prompt) set prompt = ...
6580
6581 \1f
6582 File: xemacs.info,  Node: Lisp Modes,  Next: Lisp Libraries,  Prev: Compilation,  Up: Running
6583
6584 22.2 Major Modes for Lisp
6585 =========================
6586
6587 Emacs has four different major modes for Lisp.  They are the same in
6588 terms of editing commands, but differ in the commands for executing Lisp
6589 expressions.
6590
6591 Emacs-Lisp mode
6592      The mode for editing source files of programs to run in Emacs Lisp.
6593      This mode defines `C-M-x' to evaluate the current defun.  *Note
6594      Lisp Libraries::.
6595
6596 Lisp Interaction mode
6597      The mode for an interactive session with Emacs Lisp.  It defines
6598      <LFD> to evaluate the sexp before point and insert its value in the
6599      buffer.  *Note Lisp Interaction::.
6600
6601 Lisp mode
6602      The mode for editing source files of programs that run in other
6603      dialects of Lisp than Emacs Lisp.  This mode defines `C-M-x' to
6604      send the current defun to an inferior Lisp process.  *Note
6605      External Lisp::.
6606
6607 Inferior Lisp mode
6608      The mode for an interactive session with an inferior Lisp process.
6609      This mode combines the special features of Lisp mode and Shell mode
6610      (*note Shell Mode::).
6611
6612 Scheme mode
6613      Like Lisp mode but for Scheme programs.
6614
6615 Inferior Scheme mode
6616      The mode for an interactive session with an inferior Scheme
6617      process.
6618
6619 \1f
6620 File: xemacs.info,  Node: Lisp Libraries,  Next: Lisp Eval,  Prev: Lisp Modes,  Up: Running
6621
6622 22.3 Libraries of Lisp Code for Emacs
6623 =====================================
6624
6625 Lisp code for Emacs editing commands is stored in files whose names
6626 conventionally end in `.el'.  This ending tells Emacs to edit them in
6627 Emacs-Lisp mode (*note Lisp Modes::).
6628
6629 * Menu:
6630
6631 * Loading::             Loading libraries of Lisp code into Emacs for use.
6632 * Compiling Libraries:: Compiling a library makes it load and run faster.
6633 * Mocklisp::            Converting Mocklisp to Lisp so XEmacs can run it.
6634
6635 \1f
6636 File: xemacs.info,  Node: Loading,  Next: Compiling Libraries,  Prev: Lisp Libraries,  Up: Lisp Libraries
6637
6638 22.3.1 Loading Libraries
6639 ------------------------
6640
6641 `M-x load-file FILE'
6642      Load the file FILE of Lisp code.
6643
6644 `M-x load-library LIBRARY'
6645      Load the library named LIBRARY.
6646
6647 `M-x locate-library LIBRARY &optional NOSUFFIX'
6648      Show the full path name of Emacs library LIBRARY.
6649
6650    To execute a file of Emacs Lisp, use `M-x load-file'.  This command
6651 reads the file name you provide in the minibuffer, then executes the
6652 contents of that file as Lisp code.  It is not necessary to visit the
6653 file first; in fact, this command reads the file as found on disk, not
6654 the text in an Emacs buffer.
6655
6656    Once a file of Lisp code is installed in the Emacs Lisp library
6657 directories, users can load it using `M-x load-library'.  Programs can
6658 load it by calling `load-library', or with `load', a more primitive
6659 function that is similar but accepts some additional arguments.
6660
6661    `M-x load-library' differs from `M-x load-file' in that it searches
6662 a sequence of directories and tries three file names in each directory.
6663 The three names are: first, the specified name with `.elc' appended;
6664 second, the name with `.el' appended; third, the specified name alone.
6665 A `.elc' file would be the result of compiling the Lisp file into byte
6666 code;  if possible, it is loaded in preference to the Lisp file itself
6667 because the compiled file loads and runs faster.
6668
6669    Because the argument to `load-library' is usually not in itself a
6670 valid file name, file name completion is not available.  In fact, when
6671 using this command, you usually do not know exactly what file name will
6672 be used.
6673
6674    The sequence of directories searched by `M-x load-library' is
6675 specified by the variable `load-path', a list of strings that are
6676 directory names.  The elements of this list may not begin with "`~'",
6677 so you must call `expand-file-name' on them before adding them to the
6678 list.  The default value of the list contains the directory where the
6679 Lisp code for Emacs itself is stored.  If you have libraries of your
6680 own, put them in a single directory and add that directory to
6681 `load-path'.  `nil' in this list stands for the current default
6682 directory, but it is probably not a good idea to put `nil' in the list.
6683 If you start wishing that `nil' were in the list, you should probably
6684 use `M-x load-file' for this case.
6685
6686    The variable is initialized by the EMACSLOADPATH environment
6687 variable. If no value is specified, the variable takes the default value
6688 specified in the file `paths.h' when Emacs was built. If a path isn't
6689 specified in `paths.h', a default value is obtained from the file
6690 system, near the directory in which the Emacs executable resides.
6691
6692    Like `M-x load-library', `M-x locate-library' searches the
6693 directories in `load-path' to find the file that `M-x load-library'
6694 would load.  If the optional second argument NOSUFFIX is non-`nil', the
6695 suffixes `.elc' or `.el' are not added to the specified name LIBRARY
6696 (like calling `load' instead of `load-library').
6697
6698    You often do not have to give any command to load a library, because
6699 the commands defined in the library are set up to "autoload" that
6700 library.  Running any of those commands causes `load' to be called to
6701 load the library; this replaces the autoload definitions with the real
6702 ones from the library.
6703
6704    If autoloading a file does not finish, either because of an error or
6705 because of a `C-g' quit, all function definitions made by the file are
6706 undone automatically.  So are any calls to `provide'.  As a
6707 consequence, the entire file is loaded a second time if you use one of
6708 the autoloadable commands again.  This prevents problems when the
6709 command is no longer autoloading but is working incorrectly because the
6710 file was only partially loaded.  Function definitions are undone only
6711 for autoloading; explicit calls to `load' do not undo anything if
6712 loading is not completed.
6713
6714    The variable `after-load-alist' takes an alist of expressions to be
6715 evaluated when particular files are loaded.  Each element has the form
6716 `(FILENAME forms...)'.  When `load' is run and the filename argument is
6717 FILENAME, the forms in the corresponding element are executed at the
6718 end of loading.
6719
6720    FILENAME must match exactly.  Normally FILENAME is the name of a
6721 library, with no directory specified, since that is how load is
6722 normally called.  An error in `forms' does not undo the load, but it
6723 does prevent execution of the rest of the `forms'.
6724
6725 \1f
6726 File: xemacs.info,  Node: Compiling Libraries,  Next: Mocklisp,  Prev: Loading,  Up: Lisp Libraries
6727
6728 22.3.2 Compiling Libraries
6729 --------------------------
6730
6731 Emacs Lisp code can be compiled into byte-code which loads faster,
6732 takes up less space when loaded, and executes faster.
6733
6734 `M-x batch-byte-compile'
6735      Run byte-compile-file on the files remaining on the command line.
6736
6737 `M-x byte-compile-buffer &optional BUFFER'
6738      Byte-compile and evaluate contents of BUFFER (default is current
6739      buffer).
6740
6741 `M-x byte-compile-file'
6742      Compile a file of Lisp code named FILENAME into a file of byte
6743      code.
6744
6745 `M-x byte-compile-and-load-file FILENAME'
6746      Compile a file of Lisp code named FILENAME into a file of byte
6747      code and load it.
6748
6749 `M-x byte-recompile-directory DIRECTORY'
6750      Recompile every `.el' file in DIRECTORY that needs recompilation.
6751
6752 `M-x disassemble'
6753      Print disassembled code for OBJECT on (optional) STREAM.  
6754
6755 `M-x make-obsolete FUNCTION NEW'
6756      Make the byte-compiler warn that FUNCTION is obsolete and NEW
6757      should be used instead.
6758
6759    `byte-compile-file' creates a byte-code compiled file from an
6760 Emacs-Lisp source file.  The default argument for this function is the
6761 file visited in the current buffer.  The function reads the specified
6762 file, compiles it into byte code, and writes an output file whose name
6763 is made by appending `c' to the input file name.  Thus, the file
6764 `rmail.el' would be compiled into `rmail.elc'. To compile a file of
6765 Lisp code named FILENAME into a file of byte code and then load it, use
6766 `byte-compile-and-load-file'. To compile and evaluate Lisp code in a
6767 given buffer, use `byte-compile-buffer'.
6768
6769    To recompile all changed Lisp files in a directory, use `M-x
6770 byte-recompile-directory'.  Specify just the directory name as an
6771 argument.  Each `.el' file that has been byte-compiled before is
6772 byte-compiled again if it has changed since the previous compilation.
6773 A numeric argument to this command tells it to offer to compile each
6774 `.el' file that has not been compiled yet.  You must answer `y' or `n'
6775 to each offer.
6776
6777    You can use the function `batch-byte-compile' to invoke Emacs
6778 non-interactively from the shell to do byte compilation.  When you use
6779 this function, the files to be compiled are specified with command-line
6780 arguments.  Use a shell command of the form:
6781
6782      emacs -batch -f batch-byte-compile FILES...
6783
6784    Directory names may also be given as arguments; in that case,
6785 `byte-recompile-directory' is invoked on each such directory.
6786 `batch-byte-compile' uses all remaining command-line arguments as file
6787 or directory names, then kills the Emacs process.
6788
6789    `M-x disassemble' explains the result of byte compilation.  Its
6790 argument is a function name.  It displays the byte-compiled code in a
6791 help window in symbolic form, one instruction per line.  If the
6792 instruction refers to a variable or constant, that is shown, too.
6793
6794 \1f
6795 File: xemacs.info,  Node: Mocklisp,  Prev: Compiling Libraries,  Up: Lisp Libraries
6796
6797 22.3.3 Converting Mocklisp to Lisp
6798 ----------------------------------
6799
6800 XEmacs can run Mocklisp files by converting them to Emacs Lisp first.
6801 To convert a Mocklisp file, visit it and then type `M-x
6802 convert-mocklisp-buffer'.  Then save the resulting buffer of Lisp file
6803 in a file whose name ends in `.el' and use the new file as a Lisp
6804 library.
6805
6806    You cannot currently byte-compile converted Mocklisp code.  The
6807 reason is that converted Mocklisp code uses some special Lisp features
6808 to deal with Mocklisp's incompatible ideas of how arguments are
6809 evaluated and which values signify "true" or "false".
6810