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