This commit was manufactured by cvs2svn to create branch 'utf-2000'.
[chise/xemacs-chise.git-] / info / xemacs.info-7
1 This is ../info/xemacs.info, produced by makeinfo version 4.0 from
2 xemacs/xemacs.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * XEmacs: (xemacs).             XEmacs Editor.
7 END-INFO-DIR-ENTRY
8
9    This file documents the XEmacs editor.
10
11    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
12 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
13 Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
14
15    Permission is granted to make and distribute verbatim copies of this
16 manual provided the copyright notice and this permission notice are
17 preserved on all copies.
18
19    Permission is granted to copy and distribute modified versions of
20 this manual under the conditions for verbatim copying, provided also
21 that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
22 General Public License" are included exactly as in the original, and
23 provided that the entire resulting derived work is distributed under the
24 terms of a permission notice identical to this one.
25
26    Permission is granted to copy and distribute translations of this
27 manual into another language, under the above conditions for modified
28 versions, except that the sections entitled "The GNU Manifesto",
29 "Distribution" and "GNU General Public License" may be included in a
30 translation approved by the author instead of in the original English.
31
32 \1f
33 File: xemacs.info,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
34
35 Transposing Text
36 ================
37
38 `C-t'
39      Transpose two characters (`transpose-chars').
40
41 `M-t'
42      Transpose two words (`transpose-words').
43
44 `C-M-t'
45      Transpose two balanced expressions (`transpose-sexps').
46
47 `C-x C-t'
48      Transpose two lines (`transpose-lines').
49
50    The common error of transposing two adjacent characters can be fixed
51 with the `C-t' command (`transpose-chars').  Normally, `C-t' transposes
52 the two characters on either side of point.  When given at the end of a
53 line, `C-t' transposes the last two characters on the line, rather than
54 transposing the last character of the line with the newline, which
55 would be useless.  If you catch a transposition error right away, you
56 can fix it with just `C-t'.  If you catch the error later,  move the
57 cursor back to between the two transposed characters.  If you
58 transposed a space with the last character of the word before it, the
59 word motion commands are a good way of getting there.  Otherwise, a
60 reverse search (`C-r') is often the best way.  *Note Search::.
61
62    `Meta-t' (`transpose-words') transposes the word before point with
63 the word after point.  It moves point forward over a word, dragging the
64 word preceding or containing point forward as well.  The punctuation
65 characters between the words do not move.  For example, `FOO, BAR'
66 transposes into `BAR, FOO' rather than `BAR FOO,'.
67
68    `C-M-t' (`transpose-sexps') is a similar command for transposing two
69 expressions (*note Lists::), and `C-x C-t' (`transpose-lines')
70 exchanges lines.  It works like `M-t' but in determines the division of
71 the text into syntactic units differently.
72
73    A numeric argument to a transpose command serves as a repeat count:
74 it tells the transpose command to move the character (word, sexp, line)
75 before or containing point across several other characters (words,
76 sexps, lines).  For example, `C-u 3 C-t' moves the character before
77 point forward across three other characters.  This is equivalent to
78 repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
79 backward across four words.  `C-u - C-M-t' would cancel the effect of
80 plain `C-M-t'.
81
82    A numeric argument of zero transposes the character (word, sexp,
83 line) ending after point with the one ending after the mark (otherwise a
84 command with a repeat count of zero would do nothing).
85
86 \1f
87 File: xemacs.info,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
88
89 Case Conversion
90 ===============
91
92 `M-- M-l'
93      Convert last word to lower case.  Note that `Meta--' is
94      "Meta-minus."
95
96 `M-- M-u'
97      Convert last word to all upper case.
98
99 `M-- M-c'
100      Convert last word to lower case with capital initial.
101
102    A  common error is to type words in the wrong case.  Because of this,
103 the word case-conversion commands `M-l', `M-u', and `M-c' do not move
104 the cursor when used with a negative argument.  As soon as you see you
105 have mistyped the last word, you can simply case-convert it and
106 continue typing.  *Note Case::.
107
108 \1f
109 File: xemacs.info,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
110
111 Checking and Correcting Spelling
112 ================================
113
114 `M-$'
115      Check and correct spelling of word (`spell-word').
116
117 `M-x spell-buffer'
118      Check and correct spelling of each word in the buffer.
119
120 `M-x spell-region'
121      Check and correct spelling of each word in the region.
122
123 `M-x spell-string'
124      Check spelling of specified word.
125
126    To check the spelling of the word before point, and optionally
127 correct it, use the command `M-$' (`spell-word').  This command runs an
128 inferior process containing the `spell' program to see whether the word
129 is correct English.  If it is not, it asks you to edit the word (in the
130 minibuffer) into a corrected spelling, and then performs a
131 `query-replace' to substitute the corrected spelling for the old one
132 throughout the buffer.
133
134    If you exit the minibuffer without altering the original spelling, it
135 means you do not want to do anything to that word.  In that case, the
136 `query-replace' is not done.
137
138    `M-x spell-buffer' checks each word in the buffer the same way that
139 `spell-word' does, doing a `query-replace' for every incorrect word if
140 appropriate.
141
142    `M-x spell-region' is similar to `spell-buffer' but operates only on
143 the region, not the entire buffer.
144
145    `M-x spell-string' reads a string as an argument and checks whether
146 that is a correctly spelled English word.  It prints a message giving
147 the answer in the echo area.
148
149 \1f
150 File: xemacs.info,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
151
152 File Handling
153 *************
154
155    The basic unit of stored data in Unix is the "file".  To edit a file,
156 you must tell Emacs to examine the file and prepare a buffer containing
157 a copy of the file's text.  This is called "visiting" the file.  Editing
158 commands apply directly to text in the buffer; that is, to the copy
159 inside Emacs.  Your changes appear in the file itself only when you
160 "save" the buffer back into the file.
161
162    In addition to visiting and saving files, Emacs can delete, copy,
163 rename, and append to files, and operate on file directories.
164
165 * Menu:
166
167 * File Names::       How to type and edit file name arguments.
168 * Visiting::         Visiting a file prepares Emacs to edit the file.
169 * Saving::           Saving makes your changes permanent.
170 * Reverting::        Reverting cancels all the changes not saved.
171 * Auto Save::        Auto Save periodically protects against loss of data.
172 * Version Control::  Version control systems (RCS and SCCS).
173 * ListDir::          Listing the contents of a file directory.
174 * Comparing Files::  Finding where two files differ.
175 * Dired::            ``Editing'' a directory to delete, rename, etc.
176                      the files in it.
177 * Misc File Ops::    Other things you can do on files.
178
179 \1f
180 File: xemacs.info,  Node: File Names,  Next: Visiting,  Prev: Files,  Up: Files
181
182 File Names
183 ==========
184
185    Most Emacs commands that operate on a file require you to specify the
186 file name.  (Saving and reverting are exceptions; the buffer knows which
187 file name to use for them.)  File names are specified in the minibuffer
188 (*note Minibuffer::).  "Completion" is available, to make it easier to
189 specify long file names.  *Note Completion::.
190
191    There is always a "default file name" which is used if you enter an
192 empty argument by typing just <RET>.  Normally the default file name is
193 the name of the file visited in the current buffer; this makes it easy
194 to operate on that file with any of the Emacs file commands.
195
196    Each buffer has a default directory, normally the same as the
197 directory of the file visited in that buffer.  When Emacs reads a file
198 name, the default directory is used if you do not specify a directory.
199 If you specify a directory in a relative fashion, with a name that does
200 not start with a slash, it is interpreted with respect to the default
201 directory.  The default directory of the current buffer is kept in the
202 variable `default-directory', which has a separate value in every
203 buffer.  The value of the variable should end with a slash.
204
205    For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
206 the default directory is `/u/rms/gnu/'.  If you type just `foo', which
207 does not specify a directory, it is short for `/u/rms/gnu/foo'.
208 `../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
209 the filename `/u/rms/gnu/new/foo'.
210
211    The variable `default-directory-alist' takes an alist of major modes
212 and their opinions on `default-directory' as a Lisp expression to
213 evaluate.  A resulting value of `nil' is ignored in favor of
214 `default-directory'.
215
216    You can create a new directory with the function `make-directory',
217 which takes as an argument a file name string. The current directory is
218 displayed in the minibuffer when the function is called; you can delete
219 the old directory name and supply a new directory name. For example, if
220 the current directory is `/u/rms/gnu', you can delete `gnu' and type
221 `oryx' and <RET> to create `/u/rms/oryx'.  Removing a directory is
222 similar to creating one.  To remove a directory, use
223 `remove-directory'; it takes one argument, a file name string.
224
225    The command `M-x pwd' prints the current buffer's default directory,
226 and the command `M-x cd' sets it (to a value read using the
227 minibuffer).  A buffer's default directory changes only when the `cd'
228 command is used.  A file-visiting buffer's default directory is
229 initialized to the directory of the file that is visited there.  If a
230 buffer is created with `C-x b', its default directory is copied from
231 that of the buffer that was current at the time.
232
233    The default directory name actually appears in the minibuffer when
234 the minibuffer becomes active to read a file name.  This serves two
235 purposes: it shows you what the default is, so that you can type a
236 relative file name and know with certainty what it will mean, and it
237 allows you to edit the default to specify a different directory.  To
238 inhibit the insertion of the default directory, set the variable
239 `insert-default-directory' to `nil'.
240
241    Note that it is legitimate to type an absolute file name after you
242 enter the minibuffer, ignoring the presence of the default directory
243 name.  The final minibuffer contents may look invalid, but that is not
244 so.  *Note Minibuffer File::.
245
246    `$' in a file name is used to substitute environment variables.  For
247 example, if you have used the shell command `setenv FOO rms/hacks' to
248 set up an environment variable named `FOO', then you can use
249 `/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
250 `/u/rms/hacks/test.c'.  The environment variable name consists of all
251 the alphanumeric characters after the `$'; alternatively, it may be
252 enclosed in braces after the `$'.  Note that the `setenv' command
253 affects Emacs only if done before Emacs is started.
254
255    To access a file with `$' in its name, type `$$'.  This pair is
256 converted to a single `$' at the same time variable substitution is
257 performed for single `$'.  The Lisp function that performs the
258 substitution is called `substitute-in-file-name'.  The substitution is
259 performed only on filenames read as such using the minibuffer.
260
261 \1f
262 File: xemacs.info,  Node: Visiting,  Next: Saving,  Prev: File Names,  Up: Files
263
264 Visiting Files
265 ==============
266
267 `C-x C-f'
268      Visit a file (`find-file').
269
270 `C-x C-v'
271      Visit a different file instead of the one visited last
272      (`find-alternate-file').
273
274 `C-x 4 C-f'
275      Visit a file, in another window (`find-file-other-window').  Don't
276      change this window.
277
278 `C-x 5 C-f'
279      Visit a file, in another frame (`find-file-other-frame').  Don't
280      change this window or frame.
281
282    "Visiting" a file means copying its contents into an Emacs buffer so
283 you can edit it.  Emacs creates a new buffer for each file you visit.
284 We say that the buffer is visiting the file that it was created to
285 hold.  Emacs constructs the buffer name from the file name by throwing
286 away the directory and keeping just the file name.  For example, a file
287 named `/usr/rms/emacs.tex' is displayed in a buffer named `emacs.tex'.
288 If a buffer with that name exists, a unique name is constructed by
289 appending `<2>', `<3>',and so on, using the lowest number that makes a
290 name that is not already in use.
291
292    Each window's mode line shows the name of the buffer that is being
293 displayed in that window, so you can always tell what buffer you are
294 editing.
295
296    The changes you make with Emacs are made in the Emacs buffer.  They
297 do not take effect in the file that you visit, or any other permanent
298 place, until you "save" the buffer.  Saving the buffer means that Emacs
299 writes the current contents of the buffer into its visited file.  *Note
300 Saving::.
301
302    If a buffer contains changes that have not been saved, the buffer is
303 said to be "modified".  This is important because it implies that some
304 changes will be lost if the buffer is not saved.  The mode line displays
305 two stars near the left margin if the buffer is modified.
306
307    To visit a file, use the command `C-x C-f' (`find-file').  Follow
308 the command with the name of the file you wish to visit, terminated by a
309 <RET>.  If you are using XEmacs under X, you can also use the Open...
310 command from the File menu bar item.
311
312    The file name is read using the minibuffer (*note Minibuffer::), with
313 defaulting and completion in the standard manner (*note File Names::).
314 While in the minibuffer, you can abort `C-x C-f' by typing `C-g'.
315
316    `C-x C-f' has completed successfully when text appears on the screen
317 and a new buffer name appears in the mode line.  If the specified file
318 does not exist and could not be created or cannot be read, an error
319 results.  The error message is printed in the echo area, and includes
320 the name of the file that Emacs was trying to visit.
321
322    If you visit a file that is already in Emacs, `C-x C-f' does not make
323 another copy.  It selects the existing buffer containing that file.
324 However, before doing so, it checks that the file itself has not changed
325 since you visited or saved it last.  If the file has changed, Emacs
326 prints a warning message.  *Note Simultaneous Editing: Interlocking.
327
328    You can switch to a specific file called out in the current buffer by
329 calling the function `find-this-file'. By providing a prefix argument,
330 this function calls `filename-at-point' and switches to a buffer
331 visiting the file FILENAME. It creates one if none already exists. You
332 can use this function to edit the file mentioned in the buffer you are
333 working in or to test if the file exists. You can do that by using the
334 minibuffer completion after snatching the all or part of the filename.
335
336    If the variable `find-file-use-truenames''s value is non-`nil', a
337 buffer's visited filename will always be traced back to the real file.
338 The filename will never be a symbolic link, and there will never be a
339 symbolic link anywhere in its directory path. In other words, the
340 `buffer-file-name' and `buffer-file-truename' will be equal.
341
342    If the variable `find-file-compare-truenames' value is non-`nil',
343 the `find-file' command will check the `buffer-file-truename' of all
344 visited files when deciding whether a given file is already in a
345 buffer, instead of just `buffer-file-name'.  If you attempt to visit
346 another file which is a hard-link or symbolic-link to a file that is
347 already in a buffer, the existing buffer will be found instead of a
348 newly created one.
349
350    If you want to create a file, just visit it.  Emacs prints `(New
351 File)' in the echo area, but in other respects behaves as if you had
352 visited an existing empty file.  If you make any changes and save them,
353 the file is created.
354
355    If you visit a nonexistent file unintentionally (because you typed
356 the wrong file name), use the `C-x C-v' (`find-alternate-file') command
357 to visit the file you wanted.  `C-x C-v' is similar to `C-x C-f', but
358 it kills the current buffer (after first offering to save it if it is
359 modified).  `C-x C-v' is allowed even if the current buffer is not
360 visiting a file.
361
362    If the file you specify is actually a directory, Dired is called on
363 that directory (*note Dired::).  To inhibit this, set the variable
364 `find-file-run-dired' to `nil'; then it is an error to try to visit a
365 directory.
366
367    `C-x 4 f' (`find-file-other-window') is like `C-x C-f' except that
368 the buffer containing the specified file is selected in another window.
369 The window that was selected before `C-x 4 f' continues to show the
370 same buffer it was already showing.  If you use this command when only
371 one window is being displayed, that window is split in two, with one
372 window showing the same buffer as before, and the other one showing the
373 newly requested file.  *Note Windows::.
374
375    `C-x 5 C-f' (`find-file-other-frame') is like `C-x C-f' except that
376 it creates a new frame in which the file is displayed.
377
378    Use the function `find-this-file-other-window' to edit a file
379 mentioned in the buffer you are editing or to test if that file exists.
380 To do this, use the minibuffer completion after snatching the part or
381 all of the filename. By providing a prefix argument, the function calls
382 `filename-at-point' and switches you to a buffer visiting the file
383 FILENAME in another window. The function creates a buffer if none
384 already exists. This function is similar to `find-file-other-window'.
385
386    There are two hook variables that allow extensions to modify the
387 operation of visiting files.  Visiting a file that does not exist runs
388 the functions in the list `find-file-not-found-hooks'; the value of this
389 variable is expected to be a list of functions which are called one by
390 one until one of them returns non-`nil'.  Any visiting of a file,
391 whether extant or not, expects `find-file-hooks' to contain list of
392 functions and calls them all, one by one.  In both cases the functions
393 receive no arguments.  Visiting a nonexistent file runs the
394 `find-file-not-found-hooks' first.
395
396 \1f
397 File: xemacs.info,  Node: Saving,  Next: Reverting,  Prev: Visiting,  Up: Files
398
399 Saving Files
400 ============
401
402    "Saving" a buffer in Emacs means writing its contents back into the
403 file that was visited in the buffer.
404
405 `C-x C-s'
406      Save the current buffer in its visited file (`save-buffer').
407
408 `C-x s'
409      Save any or all buffers in their visited files
410      (`save-some-buffers').
411
412 `M-~'
413      Forget that the current buffer has been changed (`not-modified').
414
415 `C-x C-w'
416      Save the current buffer in a specified file, and record that file
417      as the one visited in the buffer (`write-file').
418
419 `M-x set-visited-file-name'
420      Change file the name under which the current buffer will be saved.
421
422    To save a file and make your changes permanent, type `C-x C-s'
423 (`save-buffer').  After saving is finished, `C-x C-s' prints a message
424 such as:
425
426      Wrote /u/rms/gnu/gnu.tasks
427
428 If the selected buffer is not modified (no changes have been made in it
429 since the buffer was created or last saved), Emacs does not save it
430 because it would have no effect.  Instead, `C-x C-s' prints a message
431 in the echo area saying:
432
433      (No changes need to be saved)
434
435    The command `C-x s' (`save-some-buffers') can save any or all
436 modified buffers.  First it asks, for each modified buffer, whether to
437 save it.  The questions should be answered with `y' or `n'.  `C-x C-c',
438 the key that kills Emacs, invokes `save-some-buffers' and therefore
439 asks the same questions.
440
441    If you have changed a buffer and do not want the changes to be saved,
442 you should take some action to prevent it.  Otherwise, you are liable to
443 save it by mistake each time you use `save-some-buffers' or a related
444 command.  One thing you can do is type `M-~' (`not-modified'), which
445 removes the indication that the buffer is modified.  If you do this,
446 none of the save commands will believe that the buffer needs to be
447 saved.  (`~' is often used as a mathematical symbol for `not'; thus
448 `Meta-~' is `not', metafied.)  You could also use
449 `set-visited-file-name' (see below) to mark the buffer as visiting a
450 different file name, not in use for anything important.
451
452    You can also undo all the changes made since the file was visited or
453 saved, by reading the text from the file again.  This is called
454 "reverting".  *Note Reverting::.  Alternatively, you can undo all the
455 changes by repeating the undo command `C-x u'; but this only works if
456 you have not made more changes than the undo mechanism can remember.
457
458    `M-x set-visited-file-name' alters the name of the file that the
459 current buffer is visiting.  It prompts you for the new file name in the
460 minibuffer.  You can also use `set-visited-file-name' on a buffer that
461 is not visiting a file.  The buffer's name is changed to correspond to
462 the file it is now visiting unless the new name is already used by a
463 different buffer; in that case, the buffer name is not changed.
464 `set-visited-file-name' does not save the buffer in the newly visited
465 file; it just alters the records inside Emacs so that it will save the
466 buffer in that file.  It also marks the buffer as "modified" so that
467 `C-x C-s' will save.
468
469    If you wish to mark a buffer as visiting a different file and save it
470 right away, use `C-x C-w' (`write-file').  It is precisely equivalent
471 to `set-visited-file-name' followed by `C-x C-s'.  `C-x C-s' used on a
472 buffer that is not visiting  a file has the same effect as `C-x C-w';
473 that is, it reads a file name, marks the buffer as visiting that file,
474 and saves it there.  The default file name in a buffer that is not
475 visiting a file is made by combining the buffer name with the buffer's
476 default directory.
477
478    If Emacs is about to save a file and sees that the date of the latest
479 version on disk does not match what Emacs last read or wrote, Emacs
480 notifies you of this fact, because it probably indicates a problem
481 caused by simultaneous editing and requires your immediate attention.
482 *Note Simultaneous Editing: Interlocking.
483
484    If the variable `require-final-newline' is non-`nil', Emacs puts a
485 newline at the end of any file that doesn't already end in one, every
486 time a file is saved or written.
487
488    Use the hook variable `write-file-hooks' to implement other ways to
489 write files, and specify things to be done before files are written.
490 The value of this variable should be a list of Lisp functions.  When a
491 file is to be written, the functions in the list are called, one by
492 one, with no arguments.  If one of them returns a non-`nil' value, Emacs
493 takes this to mean that the file has been written in some suitable
494 fashion; the rest of the functions are not called, and normal writing is
495 not done. Use the hook variable `after-save-hook' to list all the
496 functions to be called after writing out a buffer to a file.
497
498 * Menu:
499
500 * Backup::       How Emacs saves the old version of your file.
501 * Interlocking:: How Emacs protects against simultaneous editing
502                   of one file by two users.
503
504 \1f
505 File: xemacs.info,  Node: Backup,  Next: Interlocking,  Prev: Saving,  Up: Saving
506
507 Backup Files
508 ------------
509
510    Because Unix does not provide version numbers in file names,
511 rewriting a file in Unix automatically destroys all record of what the
512 file used to contain.  Thus, saving a file from Emacs throws away the
513 old contents of the file--or it would, except that Emacs carefully
514 copies the old contents to another file, called the "backup" file,
515 before actually saving.  (Make sure that the variable
516 `make-backup-files' is non-`nil'.  Backup files are not written if this
517 variable is `nil').
518
519    At your option, Emacs can keep either a single backup file or a
520 series of numbered backup files for each file you edit.
521
522    Emacs makes a backup for a file only the first time a file is saved
523 from one buffer.  No matter how many times you save a file, its backup
524 file continues to contain the contents from before the file was visited.
525 Normally this means that the backup file contains the contents from
526 before the current editing session; however, if you kill the buffer and
527 then visit the file again, a new backup file is made by the next save.
528
529 * Menu:
530
531 * Names: Backup Names.          How backup files are named;
532                                 Choosing single or numbered backup files.
533 * Deletion: Backup Deletion.    Emacs deletes excess numbered backups.
534 * Copying: Backup Copying.      Backups can be made by copying or renaming.
535
536 \1f
537 File: xemacs.info,  Node: Backup Names,  Next: Backup Deletion,  Prev: Backup,  Up: Backup
538
539 Single or Numbered Backups
540 ..........................
541
542    If you choose to have a single backup file (the default), the backup
543 file's name is constructed by appending `~' to the file name being
544 edited; thus, the backup file for `eval.c' is `eval.c~'.
545
546    If you choose to have a series of numbered backup files, backup file
547 names are made by appending `.~', the number, and another `~' to the
548 original file name.  Thus, the backup files of `eval.c' would be called
549 `eval.c.~1~', `eval.c.~2~', and so on, through names like
550 `eval.c.~259~' and beyond.
551
552    If protection stops you from writing backup files under the usual
553 names, the backup file is written as `%backup%~' in your home directory.
554 Only one such file can exist, so only the most recently made backup is
555 available.
556
557    The choice of single backup or numbered backups is controlled by the
558 variable `version-control'.  Its possible values are:
559
560 `t'
561      Make numbered backups.
562
563 `nil'
564      Make numbered backups for files that have numbered backups already.
565      Otherwise, make single backups.
566
567 `never'
568      Never make numbered backups; always make single backups.
569
570 `version-control' may be set locally in an individual buffer to control
571 the making of backups for that buffer's file.  For example, Rmail mode
572 locally sets `version-control' to `never' to make sure that there is
573 only one backup for an Rmail file.  *Note Locals::.
574
575 \1f
576 File: xemacs.info,  Node: Backup Deletion,  Next: Backup Copying,  Prev: Backup Names,  Up: Backup
577
578 Automatic Deletion of Backups
579 .............................
580
581    To prevent unlimited consumption of disk space, Emacs can delete
582 numbered backup versions automatically.  Generally Emacs keeps the
583 first few backups and the latest few backups, deleting any in between.
584 This happens every time a new backup is made.  The two variables that
585 control the deletion are `kept-old-versions' and `kept-new-versions'.
586 Their values are, respectively the number of oldest (lowest-numbered)
587 backups to keep and the number of newest (highest-numbered) ones to
588 keep, each time a new backup is made.  The values are used just after a
589 new backup version is made; that newly made backup is included in the
590 count in `kept-new-versions'.  By default, both variables are 2.
591
592    If `delete-old-versions' is non-`nil',  excess middle versions are
593 deleted without notification.  If it is `nil', the default, you are
594 asked whether the excess middle versions should really be deleted.
595
596    You can also use Dired's `.' (Period) command to delete old versions.
597 *Note Dired::.
598
599 \1f
600 File: xemacs.info,  Node: Backup Copying,  Prev: Backup Deletion,  Up: Backup
601
602 Copying vs. Renaming
603 ....................
604
605    You can make backup files by copying the old file or by renaming it.
606 This makes a difference when the old file has multiple names.  If you
607 rename the old file into the backup file, the alternate names become
608 names for the backup file.  If you copy the old file instead, the
609 alternate names remain names for the file that you are editing, and the
610 contents accessed by those names will be the new contents.
611
612    How you make a backup file may also affect the file's owner and
613 group.  If you use copying, they do not change.  If renaming is used,
614 you become the file's owner, and the file's group becomes the default
615 (different operating systems have different defaults for the group).
616
617    Having the owner change is usually a good idea, because then the
618 owner is always the person who last edited the file.  Occasionally
619 there is a file whose owner should not change.  Since most files should
620 change owners, it is a good idea to use local variable lists to set
621 `backup-by-copying-when-mismatch' for the special cases where the owner
622 should not change (*note File Variables::).
623
624    Three variables control the choice of renaming or copying.
625 Normally, renaming is done.  If the variable `backup-by-copying' is
626 non-`nil', copying is used.  Otherwise, if the variable
627 `backup-by-copying-when-linked' is non-`nil', copying is done for files
628 that have multiple names, but renaming may still be done when the file
629 being edited has only one name.  If the variable
630 `backup-by-copying-when-mismatch' is non-`nil', copying is done if
631 renaming would cause the file's owner or group to change.
632
633 \1f
634 File: xemacs.info,  Node: Interlocking,  Prev: Backup,  Up: Saving
635
636 Protection Against Simultaneous Editing
637 ---------------------------------------
638
639    Simultaneous editing occurs when two users visit the same file, both
640 make changes, and both save their changes.  If no one was informed that
641 this was happening, and you saved first, you would later find that your
642 changes were lost.  On some systems, Emacs notices immediately when the
643 second user starts to change a file already being edited, and issues a
644 warning.  When this is not possible, or if the second user has started
645 to change the file despite the warning, Emacs checks when the file is
646 saved, and issues a second warning when a user is about to overwrite a
647 file containing another user's changes.  If you are the user editing the
648 file, you can take corrective action at this point and prevent actual
649 loss of work.
650
651    When you make the first modification in an Emacs buffer that is
652 visiting a file, Emacs records that you have locked the file.  (It does
653 this by writing another file in a directory reserved for this purpose.)
654 The lock is removed when you save the changes.  The idea is that the
655 file is locked whenever the buffer is modified.  If you begin to modify
656 the buffer while the visited file is locked by someone else, this
657 constitutes a collision, and Emacs asks you what to do.  It does this
658 by calling the Lisp function `ask-user-about-lock', which you can
659 redefine to customize what it does.  The standard definition of this
660 function asks you a question and accepts three possible answers:
661
662 `s'
663      Steal the lock.  Whoever was already changing the file loses the
664      lock, and you get the lock.
665
666 `p'
667      Proceed.  Go ahead and edit the file despite its being locked by
668      someone else.
669
670 `q'
671      Quit.  This causes an error (`file-locked') and the modification
672      you were trying to make in the buffer does not actually take place.
673
674    Note that locking works on the basis of a file name; if a file has
675 multiple names, Emacs does not realize that the two names are the same
676 file and cannot prevent two users from editing it simultaneously under
677 different names.  However, basing locking on names means that Emacs can
678 interlock the editing of new files that do not really exist until they
679 are saved.
680
681    Some systems are not configured to allow Emacs to make locks.  On
682 these systems, Emacs cannot detect trouble in advance, but it can still
683 detect it in time to prevent you from overwriting someone else's
684 changes.
685
686    Every time Emacs saves a buffer, it first checks the
687 last-modification date of the existing file on disk to see that it has
688 not changed since the file was last visited or saved.  If the date does
689 not match, it implies that changes were made in the file in some other
690 way, and these changes are about to be lost if Emacs actually does
691 save.  To prevent this, Emacs prints a warning message and asks for
692 confirmation before saving.  Occasionally you will know why the file
693 was changed and know that it does not matter; then you can answer `yes'
694 and proceed.  Otherwise, you should cancel the save with `C-g' and
695 investigate the situation.
696
697    The first thing you should do when notified that simultaneous editing
698 has already taken place is to list the directory with `C-u C-x C-d'
699 (*note Directory Listing: ListDir.).  This will show the file's current
700 author.  You should attempt to contact that person and ask him not to
701 continue editing.  Often the next step is to save the contents of your
702 Emacs buffer under a different name, and use `diff' to compare the two
703 files.
704
705    Simultaneous editing checks are also made when you visit a file that
706 is already visited with `C-x C-f' and when you start to modify a file.
707 This is not strictly necessary, but it is useful to find out about such
708 a problem as early as possible, when corrective action takes less work.
709
710    Another way to protect your file is to set the read, write, and
711 executable permissions for the file. Use the function
712 `set-default-file-modes' to set the UNIX `umask' value to the NMASK
713 argument. The `umask' value is the default protection mode for new
714 files.
715
716 \1f
717 File: xemacs.info,  Node: Reverting,  Next: Auto Save,  Prev: Saving,  Up: Files
718
719 Reverting a Buffer
720 ==================
721
722    If you have made extensive changes to a file and then change your
723 mind about them, you can get rid of all changes by reading in the
724 previous version of the file.  To do this, use `M-x revert-buffer',
725 which operates on the current buffer.  Since reverting a buffer can
726 result in very extensive changes, you must confirm it with `yes'.
727
728    If the current buffer has been auto-saved more recently than it has
729 been saved explicitly, `revert-buffer' offers to read the auto save file
730 instead of the visited file (*note Auto Save::).  Emacs asks you about
731 the auto-save file before the request for confirmation of the
732 `revert-buffer' operation, and demands `y' or `n' as an answer.  If you
733 have started to type `yes' for confirmation without realizing that the
734 auto-save question was going to be asked, the `y' will answer that
735 question, but the `es' will not be valid confirmation.  This gives you
736 a chance to cancel the operation with `C-g' and try again with the
737 answers you really intend.
738
739    `revert-buffer' keeps point at the same distance (measured in
740 characters) from the beginning of the file.  If the file was edited only
741 slightly, you will be at approximately the same piece of text after
742 reverting as before.  If you have made more extensive changes, the
743 value of point in the old file may bring you to a totally different
744 piece of text than your last editing point.
745
746    A buffer reverted from its visited file is marked "not modified"
747 until you make a change.
748
749    Some kinds of buffers whose contents reflect data bases other than
750 files, such as Dired buffers, can also be reverted.  For them,
751 reverting means recalculating their contents from the appropriate data.
752 Buffers created randomly with `C-x b' cannot be reverted;
753 `revert-buffer' reports an error when asked to do so.
754
755 \1f
756 File: xemacs.info,  Node: Auto Save,  Next: Version Control,  Prev: Reverting,  Up: Files
757
758 Auto-Saving: Protection Against Disasters
759 =========================================
760
761    Emacs saves all the visited files from time to time (based on
762 counting your keystrokes) without being asked.  This is called
763 "auto-saving".  It prevents you from losing more than a limited amount
764 of work if the system crashes.
765
766    When Emacs determines it is time for auto-saving, each buffer is
767 considered and is auto-saved if auto-saving is turned on for it and it
768 has changed since the last time it was auto-saved.  If any auto-saving
769 is done, the message `Auto-saving...' is displayed in the echo area
770 until auto-saving is finished.  Errors occurring during auto-saving are
771 caught so that they do not interfere with the execution of commands you
772 have been typing.
773
774 * Menu:
775
776 * Files: Auto Save Files.
777 * Control: Auto Save Control.
778 * Recover::             Recovering text from auto-save files.
779
780 \1f
781 File: xemacs.info,  Node: Auto Save Files,  Next: Auto Save Control,  Prev: Auto Save,  Up: Auto Save
782
783 Auto-Save Files
784 ---------------
785
786    Auto-saving does not normally write to the files you visited, because
787 it can be undesirable to save a program that is in an inconsistent
788 state when you have made only half of a planned change.  Instead,
789 auto-saving is done in a different file called the "auto-save file",
790 and the visited file is changed only when you save explicitly, for
791 example, with `C-x C-s'.
792
793    Normally, the name of the auto-save file is generated by appending
794 `#' to the front and back of the visited file name.  Thus, a buffer
795 visiting file `foo.c' would be auto-saved in a file `#foo.c#'.  Most
796 buffers that are not visiting files are auto-saved only if you request
797 it explicitly; when they are auto-saved, the auto-save file name is
798 generated by appending `#%' to the front and `#' to the back of buffer
799 name.  For example, the `*mail*' buffer in which you compose messages
800 to be sent is auto-saved in a file named `#%*mail*#'.  Names of
801 auto-save files are generated this way unless you customize the
802 functions `make-auto-save-file-name' and `auto-save-file-name-p' to do
803 something different.  The file name to be used for auto-saving a buffer
804 is calculated at the time auto-saving is turned on in that buffer.
805
806    If you want auto-saving to be done in the visited file, set the
807 variable `auto-save-visited-file-name' to be non-`nil'.  In this mode,
808 there is really no difference between auto-saving and explicit saving.
809
810    Emacs deletes a buffer's auto-save file when you explicitly save the
811 buffer.  To inhibit the deletion, set the variable
812 `delete-auto-save-files' to `nil'.  Changing the visited file name with
813 `C-x C-w' or `set-visited-file-name' renames any auto-save file to
814 correspond to the new visited name.
815
816 \1f
817 File: xemacs.info,  Node: Auto Save Control,  Next: Recover,  Prev: Auto Save Files,  Up: Auto Save
818
819 Controlling Auto-Saving
820 -----------------------
821
822    Each time you visit a file, auto-saving is turned on for that file's
823 buffer if the variable `auto-save-default' is non-`nil' (but not in
824 batch mode; *note Entering Emacs::).  The default for this variable is
825 `t', so Emacs auto-saves buffers that visit files by default.  You can
826 use the command `M-x auto-save-mode' to turn auto-saving for a buffer
827 on or off.  Like other minor mode commands, `M-x auto-save-mode' turns
828 auto-saving on with a positive argument, off with a zero or negative
829 argument; with no argument, it toggles.
830
831    Emacs performs auto-saving periodically based on counting how many
832 characters you have typed since the last time auto-saving happened.  The
833 variable `auto-save-interval' specifies the number of characters
834 between auto-saves.  By default, it is 300.  Emacs also auto-saves
835 whenever you call the function `do-auto-save'.
836
837    Emacs also does auto-saving whenever it gets a fatal error.  This
838 includes killing the Emacs job with a shell command such as `kill
839 -emacs', or disconnecting a phone line or network connection.
840
841    You can set the number of seconds of idle time before an auto-save is
842 done. Setting the value of the variable `auto-save-timeout' to zero or
843 `nil' will  disable auto-saving due to idleness.
844
845    The actual amount of idle time between auto-saves is logarithmically
846 related to the size of the current buffer.  This variable is the number
847 of seconds after which an auto-save will happen when the current buffer
848 is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3
849 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k
850 buffer.
851
852    For this variable to have any effect, you must do `(require 'timer)'.
853
854 \1f
855 File: xemacs.info,  Node: Recover,  Prev: Auto Save Control,  Up: Auto Save
856
857 Recovering Data from Auto-Saves
858 -------------------------------
859
860    If you want to use the contents of an auto-save file to recover from
861 a loss of data, use the command `M-x recover-file <RET> FILE <RET>'.
862 Emacs visits FILE and then (after your confirmation) restores the
863 contents from the auto-save file `#FILE#'.  You can then save the file
864 with `C-x C-s' to put the recovered text into FILE itself.  For
865 example, to recover file `foo.c' from its auto-save file `#foo.c#', do:
866
867      M-x recover-file <RET> foo.c <RET>
868      C-x C-s
869
870    Before asking for confirmation, `M-x recover-file' displays a
871 directory listing describing the specified file and the auto-save file,
872 so you can compare their sizes and dates.  If the auto-save file is
873 older, `M-x recover-file' does not offer to read it.
874
875    Auto-saving is disabled by `M-x recover-file' because using this
876 command implies that the auto-save file contains valuable data from a
877 past session.  If you save the data in the visited file and then go on
878 to make new changes, turn auto-saving back on with `M-x auto-save-mode'.
879
880 \1f
881 File: xemacs.info,  Node: Version Control,  Next: ListDir,  Prev: Auto Save,  Up: Files
882
883 Version Control
884 ===============
885
886    "Version control systems" are packages that can record multiple
887 versions of a source file, usually storing the unchanged parts of the
888 file just once.  Version control systems also record history information
889 such as the creation time of each version, who created it, and a
890 description of what was changed in that version.
891
892    The GNU project recommends the version control system known as RCS,
893 which is free software and available from the Free Software Foundation.
894 Emacs supports use of either RCS or SCCS (a proprietary, but widely
895 used, version control system that is not quite as powerful as RCS)
896 through a facility called VC.  The same Emacs commands work with either
897 RCS or SCCS, so you hardly have to know which one of them you are using.
898
899 * Menu:
900
901 * Concepts of VC::              Basic version control information;
902                                   checking files in and out.
903 * Editing with VC::             Commands for editing a file maintained
904                                   with version control.
905 * Variables for Check-in/out::  Variables that affect the commands used
906                                   to check files in or out.
907 * Log Entries::                 Logging your changes.
908 * Change Logs and VC::          Generating a change log file from log
909                                   entries.
910 * Old Versions::                Examining and comparing old versions.
911 * VC Status::                   Commands to view the VC status of files and
912                                   look at log entries.
913 * Renaming and VC::             A command to rename both the source and
914                                   master file correctly.
915 * Snapshots::                   How to make and use snapshots, a set of
916                                   file versions that can be treated as a unit.
917 * Version Headers::             Inserting version control headers into
918                                   working files.
919
920 \1f
921 File: xemacs.info,  Node: Concepts of VC,  Next: Editing with VC,  Prev: Version Control,  Up: Version Control
922
923 Concepts of Version Control
924 ---------------------------
925
926    When a file is under version control, we also say that it is
927 "registered" in the version control system.  Each registered file has a
928 corresponding "master file" which represents the file's present state
929 plus its change history, so that you can reconstruct from it either the
930 current version or any specified earlier version.  Usually the master
931 file also records a "log entry" for each version describing what was
932 changed in that version.
933
934    The file that is maintained under version control is sometimes called
935 the "work file" corresponding to its master file.
936
937    To examine a file, you "check it out".  This extracts a version of
938 the source file (typically, the most recent) from the master file.  If
939 you want to edit the file, you must check it out "locked".  Only one
940 user can do this at a time for any given source file.  (This kind of
941 locking is completely unrelated to the locking that Emacs uses to
942 detect simultaneous editing of a file.)
943
944    When you are done with your editing, you must "check in" the new
945 version.  This records the new version in the master file, and unlocks
946 the source file so that other people can lock it and thus modify it.
947
948    Checkin and checkout are the basic operations of version control.
949 You can do both of them with a single Emacs command: `C-x C-q'
950 (`vc-toggle-read-only').
951
952    A "snapshot" is a coherent collection of versions of the various
953 files that make up a program.  *Note Snapshots::.
954
955 \1f
956 File: xemacs.info,  Node: Editing with VC,  Next: Variables for Check-in/out,  Prev: Concepts of VC,  Up: Version Control
957
958 Editing with Version Control
959 ----------------------------
960
961    When you visit a file that is maintained using version control, the
962 mode line displays `RCS' or `SCCS' to inform you that version control
963 is in use, and also (in case you care) which low-level system the file
964 is actually stored in.  Normally, such a source file is read-only, and
965 the mode line indicates this with `%%'.  With RCS, the mode line also
966 indicates the number of the head version, which is normally also the
967 version you are looking at.
968
969    These are the commands for editing a file maintained with version
970 control:
971
972 `C-x C-q'
973      Check the visited file in or out.
974
975 `C-x v u'
976      Revert the buffer and the file to the last checked in version.
977
978 `C-x v c'
979      Remove the last-entered change from the master for the visited
980      file.  This undoes your last check-in.
981
982 `C-x v i'
983      Register the visited file in version control.
984
985 (`C-x v' is the prefix key for version control commands; all of these
986 commands except for `C-x C-q' start with `C-x v'.)
987
988    When you want to modify a file maintained with version control, type
989 `C-x C-q' (`vc-toggle-read-only').  This "checks out" the file, and
990 tells RCS or SCCS to lock the file.  This means making the file
991 writable for you (but not for anyone else).
992
993    When you are finished editing the file, type `C-x C-q' again.  When
994 used on a file that is checked out, this command checks the file in.
995 But check-in does not start immediately; first, you must enter the "log
996 entry"--a description of the changes in the new version.  `C-x C-q'
997 pops up a buffer for you to enter this in.  When you are finished
998 typing in the log entry, type `C-c C-c' to terminate it; this is when
999 actual check-in takes place.
1000
1001    Once you have checked in your changes, the file is unlocked, so that
1002 other users can lock it and modify it.
1003
1004    Emacs does not save backup files for source files that are maintained
1005 with version control.  If you want to make backup files despite version
1006 control, set the variable `vc-make-backup-files' to a non-`nil' value.
1007
1008    Normally the work file exists all the time, whether it is locked or
1009 not.  If you set `vc-keep-workfiles' to `nil', then checking in a new
1010 version with `C-x C-q' deletes the work file; but any attempt to visit
1011 the file with Emacs creates it again.
1012
1013    It is not impossible to lock a file that someone else has locked.  If
1014 you try to check out a file that is locked, `C-x C-q' asks you whether
1015 you want to "steal the lock."  If you say yes, the file becomes locked
1016 by you, but a message is sent to the person who had formerly locked the
1017 file, to inform him of what has happened.  The mode line indicates that
1018 a file is locked by someone else by displaying the login name of that
1019 person, before the version number.
1020
1021    If you want to discard your current set of changes and revert to the
1022 last version checked in, use `C-x v u' (`vc-revert-buffer').  This
1023 cancels your last check-out, leaving the file unlocked.  If you want to
1024 make a different set of changes, you must first check the file out
1025 again.  `C-x v u' requires confirmation, unless it sees that you
1026 haven't made any changes since the last checked-in version.
1027
1028    `C-x v u' is also the command to use if you lock a file and then
1029 don't actually change it.
1030
1031    You can cancel a change after checking it in, with `C-x v c'
1032 (`vc-cancel-version').  This command discards all record of the most
1033 recent checked in version, so be careful about using it.  It requires
1034 confirmation with `yes'.  By default, `C-x v c' reverts your workfile
1035 and buffer to the previous version (the one that precedes the version
1036 that is deleted), but you can prevent the reversion by giving the
1037 command a prefix argument.  Then the buffer does not change.
1038
1039    This command with a prefix argument is useful when you have checked
1040 in a change and then discover a trivial error in it; you can cancel the
1041 erroneous check-in, fix the error, and repeat the check-in.
1042
1043    Be careful when invoking `C-x v c', as it is easy to throw away a
1044 lot of work with it.  To help you be careful, this command always
1045 requires confirmation with `yes'.
1046
1047    You can register the visited file for version control using
1048 `C-x v i' (`vc-register').  If the variable `vc-default-back-end' is
1049 non-`nil', it specifies which version control system to use; otherwise,
1050 this uses RCS if it is installed on your system and SCCS if not.  After
1051 `C-x v i', the file is unlocked and read-only.  Type `C-x C-q' if you
1052 wish to edit it.
1053
1054    By default, the initial version number is 1.1.  If you want to use a
1055 different number, give `C-x v i' a prefix argument; then it reads the
1056 initial version number using the minibuffer.
1057
1058    If `vc-initial-comment' is non-`nil', `C-x v i' reads an initial
1059 comment (much like a log entry) to describe the purpose of this source
1060 file.
1061
1062    To specify the version number for a subsequent checkin, use the
1063 command `C-u C-x v v'.  `C-x v v' (`vc-next-action') is the command
1064 that `C-x C-q' uses to do the "real work" when the visited file uses
1065 version control.  When used for checkin, and given a prefix argument,
1066 it reads the version number with the minibuffer.
1067