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