annotate man/xemacs/files.texi @ 5797:a1808d52a34a

If the position of a window's cached point is deleted, use buffer point instead src/ChangeLog addition: 2014-06-17 Aidan Kehoe <kehoea@parhasard.net> * extents.h: * window.c: * window.c (unshow_buffer): * window.c (Fset_window_buffer): Use extents, rather than markers, for the window buffer point cache, so that when the text containing that window buffer point is deleted, the window display code uses the buffer's actual point instead of the position that the marker had been moved to. Fixes Michael Heinrich's problem of http://mid.gmane.org/6zr42uxtf5.fsf@elektra.science-computing.de , introduced by Ben's patch of https://bitbucket.org/xemacs/xemacs/commits/047d37eb70d70f43803 .
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 17 Jun 2014 20:55:45 +0100
parents 182d01410b8d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 @node Files, Buffers, Fixit, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 @chapter File Handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 @cindex files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 The basic unit of stored data in Unix is the @dfn{file}. To edit a file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 you must tell Emacs to examine the file and prepare a buffer containing a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 copy of the file's text. This is called @dfn{visiting} the file. Editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 commands apply directly to text in the buffer; that is, to the copy inside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Emacs. Your changes appear in the file itself only when you @dfn{save} the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 buffer back into the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
741
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
13 @cindex files, remote
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
14 @cindex remote files
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
15 Emacs is also able to handle ``remote files'' which are stored on
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
16 other hosts. Not only is Emacs somewhat aware of the special issues
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
17 involved with network file systems, but it can also use FTP and ssh (or
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
18 rsh) to make local copies of the files, and refresh them on the remote
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
19 host automatically when you save the buffer. The FTP interface is
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
20 provided by the standard @samp{efs} package @ref{Top, EFS, , efs}. The
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
21 ssh/rsh interface is provided by the optional @samp{tramp} package
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
22 @ref{Top, TRAMP, , tramp}. These packages attempt to implement all of
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
23 the operations described below, making remote file use transparent
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
24 (except for unavoidable network delays).
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
25
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 In addition to visiting and saving files, Emacs can delete, copy, rename,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 and append to files, and operate on file directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * File Names:: How to type and edit file name arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * Visiting:: Visiting a file prepares Emacs to edit the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 * Saving:: Saving makes your changes permanent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * Reverting:: Reverting cancels all the changes not saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 * Auto Save:: Auto Save periodically protects against loss of data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 * Version Control:: Version control systems (RCS and SCCS).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 * ListDir:: Listing the contents of a file directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 * Comparing Files:: Finding where two files differ.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 * Dired:: ``Editing'' a directory to delete, rename, etc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 the files in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 * Misc File Ops:: Other things you can do on files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 @node File Names, Visiting, Files, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 @section File Names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 @cindex file names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 Most Emacs commands that operate on a file require you to specify the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 file name. (Saving and reverting are exceptions; the buffer knows which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 file name to use for them.) File names are specified in the minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (@pxref{Minibuffer}). @dfn{Completion} is available, to make it easier to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 specify long file names. @xref{Completion}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 There is always a @dfn{default file name} which is used if you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 enter an empty argument by typing just @key{RET}. Normally the default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 file name is the name of the file visited in the current buffer; this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 makes it easy to operate on that file with any of the Emacs file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
741
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
59 The syntax for accessing remote files unfortunately varies depending on
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
60 the method used. The syntax for using FTP is
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
61 @samp{/@var{user}@@@var{remote-host}:@var{path-on-remote-host}}. The
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
62 syntax for using ssh is
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
63 @samp{/[@var{user}@@@var{remote-host}]@var{path-on-remote-host}}.
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
64
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
65 In both cases the @samp{@var{user}@@} portion is optional (it defaults
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
66 to your local user name). @var{path-on-remote-host} may use the
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
67 @samp{~} notation to indicate @var{user}'s home directory on the remote
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
68 host. The default file name will reflect the remote host information.
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
69
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 @vindex default-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 Each buffer has a default directory, normally the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 directory of the file visited in that buffer. When Emacs reads a file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 name, the default directory is used if you do not specify a directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 If you specify a directory in a relative fashion, with a name that does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 not start with a slash, it is interpreted with respect to the default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 directory. The default directory of the current buffer is kept in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 variable @code{default-directory}, which has a separate value in every
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 buffer. The value of the variable should end with a slash.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 For example, if the default file name is @file{/u/rms/gnu/gnu.tasks} then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 the default directory is @file{/u/rms/gnu/}. If you type just @samp{foo},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 which does not specify a directory, it is short for @file{/u/rms/gnu/foo}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 @samp{../.login} would stand for @file{/u/rms/.login}. @samp{new/foo}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 would stand for the filename @file{/u/rms/gnu/new/foo}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
741
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
86 When visiting a remote file via EFS or TRAMP, the remote directory
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
87 becomes the default directory (@pxref{Visiting}) for that buffer, just
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
88 as a local directory would.
1d4da9ee6381 [xemacs-hg @ 2002-02-04 10:13:45 by stephent]
stephent
parents: 444
diff changeset
89
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 @vindex default-directory-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 The variable @code{default-directory-alist} takes an alist of major
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 modes and their opinions on @code{default-directory} as a Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 expression to evaluate. A resulting value of @code{nil} is ignored in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 favor of @code{default-directory}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 @findex make-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 @findex remove-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 @cindex creating directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 @cindex removing directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 You can create a new directory with the function @code{make-directory},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 which takes as an argument a file name string. The current directory is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 displayed in the minibuffer when the function is called; you can delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 the old directory name and supply a new directory name. For example, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 the current directory is @file{/u/rms/gnu}, you can delete @file{gnu}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 and type @file{oryx} and @key{RET} to create @file{/u/rms/oryx}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 Removing a directory is similar to creating one. To remove a directory,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 use @code{remove-directory}; it takes one argument, a file name string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 The command @kbd{M-x pwd} prints the current buffer's default directory,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 and the command @kbd{M-x cd} sets it (to a value read using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 minibuffer). A buffer's default directory changes only when the @code{cd}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 command is used. A file-visiting buffer's default directory is initialized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 to the directory of the file that is visited there. If a buffer is created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 with @kbd{C-x b}, its default directory is copied from that of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 buffer that was current at the time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 @vindex insert-default-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 The default directory name actually appears in the minibuffer when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 minibuffer becomes active to read a file name. This serves two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 purposes: it shows you what the default is, so that you can type a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 relative file name and know with certainty what it will mean, and it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 allows you to edit the default to specify a different directory. To
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 inhibit the insertion of the default directory, set the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 @code{insert-default-directory} to @code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 Note that it is legitimate to type an absolute file name after you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 enter the minibuffer, ignoring the presence of the default directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 name. The final minibuffer contents may look invalid, but that is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 so. @xref{Minibuffer File}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 @samp{$} in a file name is used to substitute environment variables. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 example, if you have used the shell command @samp{setenv FOO rms/hacks} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 set up an environment variable named @samp{FOO}, then you can use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 @file{/u/$FOO/test.c} or @file{/u/$@{FOO@}/test.c} as an abbreviation for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 @file{/u/rms/hacks/test.c}. The environment variable name consists of all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 the alphanumeric characters after the @samp{$}; alternatively, it may be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 enclosed in braces after the @samp{$}. Note that the @samp{setenv} command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 affects Emacs only if done before Emacs is started.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 To access a file with @samp{$} in its name, type @samp{$$}. This pair
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 is converted to a single @samp{$} at the same time variable substitution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 is performed for single @samp{$}. The Lisp function that performs the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 substitution is called @code{substitute-in-file-name}. The substitution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 is performed only on filenames read as such using the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 @node Visiting, Saving, File Names, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 @section Visiting Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 @cindex visiting files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 @c WideCommands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 @item C-x C-f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 Visit a file (@code{find-file}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 @item C-x C-v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 Visit a different file instead of the one visited last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (@code{find-alternate-file}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 @item C-x 4 C-f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 Visit a file, in another window (@code{find-file-other-window}). Don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 change this window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 @item C-x 5 C-f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 Visit a file, in another frame (@code{find-file-other-frame}). Don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 change this window or frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 @cindex files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 @cindex visiting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 @cindex saving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 @dfn{Visiting} a file means copying its contents into an Emacs buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 so you can edit it. Emacs creates a new buffer for each file you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 visit. We say that the buffer is visiting the file that it was created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 to hold. Emacs constructs the buffer name from the file name by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 throwing away the directory and keeping just the file name. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 a file named @file{/usr/rms/emacs.tex} is displayed in a buffer named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 @samp{emacs.tex}. If a buffer with that name exists, a unique
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 name is constructed by appending @samp{<2>}, @samp{<3>},and so on, using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 the lowest number that makes a name that is not already in use.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 Each window's mode line shows the name of the buffer that is being displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 in that window, so you can always tell what buffer you are editing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 The changes you make with Emacs are made in the Emacs buffer. They do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 not take effect in the file that you visit, or any other permanent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 place, until you @dfn{save} the buffer. Saving the buffer means that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 Emacs writes the current contents of the buffer into its visited file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 @xref{Saving}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 @cindex modified (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 If a buffer contains changes that have not been saved, the buffer is said
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 to be @dfn{modified}. This is important because it implies that some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 changes will be lost if the buffer is not saved. The mode line displays
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 two stars near the left margin if the buffer is modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 @kindex C-x 5 C-f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 @findex find-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 @findex find-file-other-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 To visit a file, use the command @kbd{C-x C-f} (@code{find-file}). Follow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 the command with the name of the file you wish to visit, terminated by a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 @key{RET}. If you are using XEmacs under X, you can also use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 @b{Open...} command from the @b{File} menu bar item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 The file name is read using the minibuffer (@pxref{Minibuffer}), with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 defaulting and completion in the standard manner (@pxref{File Names}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 While in the minibuffer, you can abort @kbd{C-x C-f} by typing @kbd{C-g}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 @kbd{C-x C-f} has completed successfully when text appears on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 screen and a new buffer name appears in the mode line. If the specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 file does not exist and could not be created or cannot be read, an error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 results. The error message is printed in the echo area, and includes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 the name of the file that Emacs was trying to visit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 If you visit a file that is already in Emacs, @kbd{C-x C-f} does not make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 another copy. It selects the existing buffer containing that file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 However, before doing so, it checks that the file itself has not changed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 since you visited or saved it last. If the file has changed, Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 prints a warning message. @xref{Interlocking,,Simultaneous Editing}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 @findex find-this-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 You can switch to a specific file called out in the current buffer by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 calling the function @code{find-this-file}. By providing a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 argument, this function calls @code{filename-at-point} and switches to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 buffer visiting the file @var{filename}. It creates one if none already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 exists. You can use this function to edit the file mentioned in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 buffer you are working in or to test if the file exists. You can do that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 by using the minibuffer completion after snatching the all or part of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 the filename.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 @vindex find-file-use-truenames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 @vindex buffer-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 If the variable @code{find-file-use-truenames}'s value is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 non-@code{nil}, a buffer's visited filename will always be traced back
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 to the real file. The filename will never be a symbolic link, and there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 will never be a symbolic link anywhere in its directory path. In other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 words, the @code{buffer-file-name} and @code{buffer-file-truename} will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 be equal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 @vindex find-file-compare-truenames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 @vindex buffer-file-truename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 If the variable @code{find-file-compare-truenames} value is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 non-@code{nil}, the @code{find-file} command will check the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 @code{buffer-file-truename} of all visited files when deciding whether a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 given file is already in a buffer, instead of just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 @code{buffer-file-name}. If you attempt to visit another file which is
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
243 a symbolic link to a file that is already in a buffer, the existing
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
244 buffer will be found instead of a newly created one. This works if any
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
245 component of the pathname (including a non-terminal component) is a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
246 symbolic link as well, but doesn't work with hard links (nothing does).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 @cindex creating files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 If you want to create a file, just visit it. Emacs prints
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 @samp{(New File)} in the echo area, but in other respects behaves as if you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 had visited an existing empty file. If you make any changes and save them,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 the file is created.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 @kindex C-x C-v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 @findex find-alternate-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 If you visit a nonexistent file unintentionally (because you typed the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 wrong file name), use the @kbd{C-x C-v} (@code{find-alternate-file})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 command to visit the file you wanted. @kbd{C-x C-v} is similar to @kbd{C-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 C-f}, but it kills the current buffer (after first offering to save it if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 it is modified). @kbd{C-x C-v} is allowed even if the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 is not visiting a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 @vindex find-file-run-dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 If the file you specify is actually a directory, Dired is called on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 that directory (@pxref{Dired}). To inhibit this, set the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 @code{find-file-run-dired} to @code{nil}; then it is an error to try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 visit a directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 @kindex C-x 4 f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 @findex find-file-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 @kbd{C-x 4 f} (@code{find-file-other-window}) is like @kbd{C-x C-f}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 except that the buffer containing the specified file is selected in another
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 window. The window that was selected before @kbd{C-x 4 f} continues to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 show the same buffer it was already showing. If you use this command when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 only one window is being displayed, that window is split in two, with one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 window showing the same buffer as before, and the other one showing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 newly requested file. @xref{Windows}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 @kindex C-x 5 C-f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 @findex find-file-other-frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 @kbd{C-x 5 C-f} (@code{find-file-other-frame}) is like @kbd{C-x C-f}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 except that it creates a new frame in which the file is displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 @findex find-this-file-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 Use the function @code{find-this-file-other-window} to edit a file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 mentioned in the buffer you are editing or to test if that file exists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 To do this, use the minibuffer completion after snatching the part or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 all of the filename. By providing a prefix argument, the function calls
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 @code{filename-at-point} and switches you to a buffer visiting the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 @var{filename} in another window. The function creates a buffer if none
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 already exists. This function is similar to @code{find-file-other-window}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 @vindex find-file-hooks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 @vindex find-file-not-found-hooks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 There are two hook variables that allow extensions to modify the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 operation of visiting files. Visiting a file that does not exist runs the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 functions in the list @code{find-file-not-found-hooks}; the value of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 variable is expected to be a list of functions which are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 called one by one until one of them returns non-@code{nil}. Any visiting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 of a file, whether extant or not, expects @code{find-file-hooks} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 contain list of functions and calls them all, one by one. In both cases
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 the functions receive no arguments. Visiting a nonexistent file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 runs the @code{find-file-not-found-hooks} first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 @node Saving, Reverting, Visiting, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 @section Saving Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 @dfn{Saving} a buffer in Emacs means writing its contents back into the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 that was visited in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 @item C-x C-s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 Save the current buffer in its visited file (@code{save-buffer}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 @item C-x s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 Save any or all buffers in their visited files (@code{save-some-buffers}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 @item M-~
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Forget that the current buffer has been changed (@code{not-modified}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 @item C-x C-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 Save the current buffer in a specified file, and record that file as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 the one visited in the buffer (@code{write-file}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 @item M-x set-visited-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 Change file the name under which the current buffer will be saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 @kindex C-x C-s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 @findex save-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 To save a file and make your changes permanent, type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 @kbd{C-x C-s} (@code{save-buffer}). After saving is finished, @kbd{C-x C-s}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 prints a message such as:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 Wrote /u/rms/gnu/gnu.tasks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 If the selected buffer is not modified (no changes have been made in it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 since the buffer was created or last saved), Emacs does not save it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 because it would have no effect. Instead, @kbd{C-x C-s} prints a message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 in the echo area saying:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (No changes need to be saved)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 @kindex C-x s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 @findex save-some-buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 The command @kbd{C-x s} (@code{save-some-buffers}) can save any or all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 modified buffers. First it asks, for each modified buffer, whether to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 save it. The questions should be answered with @kbd{y} or @kbd{n}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 @kbd{C-x C-c}, the key that kills Emacs, invokes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 @code{save-some-buffers} and therefore asks the same questions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 @kindex M-~
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 @findex not-modified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 If you have changed a buffer and do not want the changes to be saved,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 you should take some action to prevent it. Otherwise, you are liable to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 save it by mistake each time you use @code{save-some-buffers} or a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 related command. One thing you can do is type @kbd{M-~}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (@code{not-modified}), which removes the indication that the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 is modified. If you do this, none of the save commands will believe
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 that the buffer needs to be saved. (@samp{~} is often used as a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 mathematical symbol for `not'; thus @kbd{Meta-~} is `not', metafied.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 You could also use @code{set-visited-file-name} (see below) to mark the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 buffer as visiting a different file name, not in use for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 anything important.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 You can also undo all the changes made since the file was visited or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 saved, by reading the text from the file again. This is called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 @dfn{reverting}. @xref{Reverting}. Alternatively, you can undo all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 changes by repeating the undo command @kbd{C-x u}; but this only works
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 if you have not made more changes than the undo mechanism can remember.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 @findex set-visited-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 @kbd{M-x set-visited-file-name} alters the name of the file that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 current buffer is visiting. It prompts you for the new file name in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 minibuffer. You can also use @code{set-visited-file-name} on a buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 that is not visiting a file. The buffer's name is changed to correspond
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 to the file it is now visiting unless the new name is already used by a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 different buffer; in that case, the buffer name is not changed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 @code{set-visited-file-name} does not save the buffer in the newly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 visited file; it just alters the records inside Emacs so that it will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 save the buffer in that file. It also marks the buffer as ``modified''
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 so that @kbd{C-x C-s} @i{will} save.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 @kindex C-x C-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 @findex write-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 If you wish to mark a buffer as visiting a different file and save it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 right away, use @kbd{C-x C-w} (@code{write-file}). It is precisely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 @kbd{C-x C-s} used on a buffer that is not visiting a file has the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 buffer as visiting that file, and saves it there. The default file name in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 a buffer that is not visiting a file is made by combining the buffer name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 with the buffer's default directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 If Emacs is about to save a file and sees that the date of the latest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 version on disk does not match what Emacs last read or wrote, Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 notifies you of this fact, because it probably indicates a problem caused
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 by simultaneous editing and requires your immediate attention.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 @xref{Interlocking,, Simultaneous Editing}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 @vindex require-final-newline
5766
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
403 If the value of the variable @code{require-final-newline} is
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
404 @code{t}, saving or writing a file silently puts a newline at the end
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
405 if there isn't already one there. If the value is @code{visit}, Emacs
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
406 adds a newline at the end of any file that doesn't have one, just
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
407 after it visits the file. (This marks the buffer as modified, and you
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
408 can undo it.) If the value is @code{visit-save}, Emacs adds such
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
409 newlines both on visiting and on saving. If the value is @code{nil},
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
410 Emacs leaves the end of the file unchanged; any other non-@code{nil}
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
411 value means to asks you whether to add a newline. The default is
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
412 @code{nil}.
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
413
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
414 @vindex mode-require-final-newline
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
415 Some major modes are designed for specific kinds of files that are
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
416 always supposed to end in newlines. Such major modes set the variable
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
417 @code{require-final-newline} to the value of
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
418 @code{mode-require-final-newline}, which defaults to @code{t}. By
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
419 setting the latter variable, you can control how these modes handle
182d01410b8d Add mode-require-final-newline from GNU. Thanks GNU.
Mats Lidell <mats.lidell@cag.se>
parents: 741
diff changeset
420 final newlines.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 @vindex write-file-hooks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 @vindex after-save-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 Use the hook variable @code{write-file-hooks} to implement other ways
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 to write files, and specify things to be done before files are written. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 value of this variable should be a list of Lisp functions. When a file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 is to be written, the functions in the list are called, one by one, with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 no arguments. If one of them returns a non-@code{nil} value, Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 takes this to mean that the file has been written in some suitable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 fashion; the rest of the functions are not called, and normal writing is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 not done. Use the hook variable @code{after-save-hook} to list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 all the functions to be called after writing out a buffer to a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 * Backup:: How Emacs saves the old version of your file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 * Interlocking:: How Emacs protects against simultaneous editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 of one file by two users.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 @node Backup, Interlocking, Saving, Saving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 @subsection Backup Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 @cindex backup file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 @vindex make-backup-files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 Because Unix does not provide version numbers in file names, rewriting a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 file in Unix automatically destroys all record of what the file used to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 contain. Thus, saving a file from Emacs throws away the old contents of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 the file---or it would, except that Emacs carefully copies the old contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 to another file, called the @dfn{backup} file, before actually saving.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (Make sure that the variable @code{make-backup-files} is non-@code{nil}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 Backup files are not written if this variable is @code{nil}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 At your option, Emacs can keep either a single backup file or a series of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 numbered backup files for each file you edit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 Emacs makes a backup for a file only the first time a file is saved
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 from one buffer. No matter how many times you save a file, its backup file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 continues to contain the contents from before the file was visited.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 Normally this means that the backup file contains the contents from before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 the current editing session; however, if you kill the buffer and then visit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 the file again, a new backup file is made by the next save.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 * Names: Backup Names. How backup files are named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 Choosing single or numbered backup files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 * Deletion: Backup Deletion. Emacs deletes excess numbered backups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 * Copying: Backup Copying. Backups can be made by copying or renaming.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 @node Backup Names, Backup Deletion, Backup, Backup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 @subsubsection Single or Numbered Backups
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 If you choose to have a single backup file (the default),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 the backup file's name is constructed by appending @samp{~} to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 file name being edited; thus, the backup file for @file{eval.c} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 @file{eval.c~}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 If you choose to have a series of numbered backup files, backup file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 names are made by appending @samp{.~}, the number, and another @samp{~} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 the original file name. Thus, the backup files of @file{eval.c} would be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 called @file{eval.c.~1~}, @file{eval.c.~2~}, and so on, through names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 like @file{eval.c.~259~} and beyond.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 If protection stops you from writing backup files under the usual names,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 the backup file is written as @file{%backup%~} in your home directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 Only one such file can exist, so only the most recently made backup is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 available.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 @vindex version-control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 The choice of single backup or numbered backups is controlled by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 variable @code{version-control}. Its possible values are:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 @item t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 Make numbered backups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 @item nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 Make numbered backups for files that have numbered backups already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 Otherwise, make single backups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 @item never
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 Never make numbered backups; always make single backups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 @code{version-control} may be set locally in an individual buffer to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 control the making of backups for that buffer's file. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 Rmail mode locally sets @code{version-control} to @code{never} to make sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 that there is only one backup for an Rmail file. @xref{Locals}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 @node Backup Deletion, Backup Copying, Backup Names, Backup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 @subsubsection Automatic Deletion of Backups
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 @vindex kept-old-versions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 @vindex kept-new-versions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 To prevent unlimited consumption of disk space, Emacs can delete numbered
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 backup versions automatically. Generally Emacs keeps the first few backups
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 and the latest few backups, deleting any in between. This happens every
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 time a new backup is made. The two variables that control the deletion are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 @code{kept-old-versions} and @code{kept-new-versions}. Their values are, respectively
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 the number of oldest (lowest-numbered) backups to keep and the number of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 newest (highest-numbered) ones to keep, each time a new backup is made.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 The values are used just after a new backup version is made;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 that newly made backup is included in the count in @code{kept-new-versions}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 By default, both variables are 2.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
525 @vindex delete-old-versions
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
526 If @code{delete-old-versions} is non-@code{nil}, excess
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 middle versions are deleted without notification. If it is @code{nil}, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 default, you are asked whether the excess middle versions should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 really be deleted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 You can also use Dired's @kbd{.} (Period) command to delete old versions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 @xref{Dired}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 @node Backup Copying, , Backup Deletion, Backup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 @subsubsection Copying vs.@: Renaming
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 You can make backup files by copying the old file or by renaming it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 This makes a difference when the old file has multiple names. If you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 rename the old file into the backup file, the alternate names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 become names for the backup file. If you copy the old file instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 the alternate names remain names for the file that you are editing,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 and the contents accessed by those names will be the new contents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 How you make a backup file may also affect the file's owner
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 and group. If you use copying, they do not change. If renaming is used,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 you become the file's owner, and the file's group becomes the default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 (different operating systems have different defaults for the group).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 Having the owner change is usually a good idea, because then the owner
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 is always the person who last edited the file. Occasionally there is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 file whose owner should not change. Since most files should change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 owners, it is a good idea to use local variable lists to set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 @code{backup-by-copying-when-mismatch} for the special cases where the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 owner should not change (@pxref{File Variables}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 @vindex backup-by-copying
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 @vindex backup-by-copying-when-linked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 @vindex backup-by-copying-when-mismatch
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 Three variables control the choice of renaming or copying.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 Normally, renaming is done. If the variable @code{backup-by-copying} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 non-@code{nil}, copying is used. Otherwise, if the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 @code{backup-by-copying-when-linked} is non-@code{nil}, copying is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 done for files that have multiple names, but renaming may still be done when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 the file being edited has only one name. If the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 @code{backup-by-copying-when-mismatch} is non-@code{nil}, copying is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 done if renaming would cause the file's owner or group to change. @refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 @node Interlocking, , Backup, Saving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 @subsection Protection Against Simultaneous Editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 @cindex file dates
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 @cindex simultaneous editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 Simultaneous editing occurs when two users visit the same file, both
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 make changes, and both save their changes. If no one was informed that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 this was happening, and you saved first, you would later find that your
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 changes were lost. On some systems, Emacs notices immediately when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 second user starts to change a file already being edited, and issues a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 warning. When this is not possible, or if the second user has started
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 to change the file despite the warning, Emacs checks when the file is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 saved, and issues a second warning when a user is about to overwrite a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 file containing another user's changes. If you are the user editing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 file, you can take corrective action at this point and prevent actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 loss of work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 @findex ask-user-about-lock
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 When you make the first modification in an Emacs buffer that is visiting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 a file, Emacs records that you have locked the file. (It does this by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 writing another file in a directory reserved for this purpose.) The lock
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 is removed when you save the changes. The idea is that the file is locked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 whenever the buffer is modified. If you begin to modify the buffer while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 the visited file is locked by someone else, this constitutes a collision,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 and Emacs asks you what to do. It does this by calling the Lisp function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 @code{ask-user-about-lock}, which you can redefine to customize what it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 does. The standard definition of this function asks you a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 question and accepts three possible answers:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 @item s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 Steal the lock. Whoever was already changing the file loses the lock,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 and you get the lock.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 @item p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 Proceed. Go ahead and edit the file despite its being locked by someone else.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 @item q
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 Quit. This causes an error (@code{file-locked}) and the modification you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 were trying to make in the buffer does not actually take place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Note that locking works on the basis of a file name; if a file has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 multiple names, Emacs does not realize that the two names are the same file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 and cannot prevent two users from editing it simultaneously under different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 names. However, basing locking on names means that Emacs can interlock the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 editing of new files that do not really exist until they are saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 Some systems are not configured to allow Emacs to make locks. On
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 these systems, Emacs cannot detect trouble in advance, but it can still
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 detect it in time to prevent you from overwriting someone else's changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 Every time Emacs saves a buffer, it first checks the last-modification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 date of the existing file on disk to see that it has not changed since the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 file was last visited or saved. If the date does not match, it implies
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 that changes were made in the file in some other way, and these changes are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 about to be lost if Emacs actually does save. To prevent this, Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 prints a warning message and asks for confirmation before saving.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 Occasionally you will know why the file was changed and know that it does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 not matter; then you can answer @kbd{yes} and proceed. Otherwise, you should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 cancel the save with @kbd{C-g} and investigate the situation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 The first thing you should do when notified that simultaneous editing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 has already taken place is to list the directory with @kbd{C-u C-x C-d}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 (@pxref{ListDir,,Directory Listing}). This will show the file's current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 author. You should attempt to contact that person and ask him not to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 continue editing. Often the next step is to save the contents of your
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 Emacs buffer under a different name, and use @code{diff} to compare the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 two files.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 Simultaneous editing checks are also made when you visit a file that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 is already visited with @kbd{C-x C-f} and when you start to modify a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 file. This is not strictly necessary, but it is useful to find out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 about such a problem as early as possible, when corrective action takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 less work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 @findex set-default-file-modes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 @cindex file protection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 Another way to protect your file is to set the read, write, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 executable permissions for the file. Use the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 @code{set-default-file-modes} to set the UNIX @code{umask} value to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 @var{nmask} argument. The @code{umask} value is the default protection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 mode for new files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 @node Reverting, Auto Save, Saving, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 @section Reverting a Buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 @findex revert-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 @cindex drastic changes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 If you have made extensive changes to a file and then change your mind
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 about them, you can get rid of all changes by reading in the previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 version of the file. To do this, use @kbd{M-x revert-buffer}, which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 operates on the current buffer. Since reverting a buffer can result in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 very extensive changes, you must confirm it with @kbd{yes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 If the current buffer has been auto-saved more recently than it has been
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 saved explicitly, @code{revert-buffer} offers to read the auto save file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 instead of the visited file (@pxref{Auto Save}). Emacs asks you about
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 the auto-save file before the request for confirmation of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 @kbd{revert-buffer} operation, and demands @kbd{y} or @kbd{n}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 as an answer. If you have started to type @kbd{yes} for confirmation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 without realizing that the auto-save question was going to be asked, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 @kbd{y} will answer that question, but the @kbd{es} will not be valid
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 confirmation. This gives you a chance to cancel the operation with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 @kbd{C-g} and try again with the answers you really intend.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 @code{revert-buffer} keeps point at the same distance (measured in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 characters) from the beginning of the file. If the file was edited only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 slightly, you will be at approximately the same piece of text after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 reverting as before. If you have made more extensive changes, the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 point in the old file may bring you to a totally different piece of text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 than your last editing point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 A buffer reverted from its visited file is marked ``not modified'' until
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 you make a change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 Some kinds of buffers whose contents reflect data bases other than files,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 such as Dired buffers, can also be reverted. For them, reverting means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 recalculating their contents from the appropriate data. Buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 created randomly with @kbd{C-x b} cannot be reverted; @code{revert-buffer}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 reports an error when asked to do so.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 @node Auto Save, Version Control, Reverting, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 @section Auto-Saving: Protection Against Disasters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 @cindex Auto-Save mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 @cindex crashes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 Emacs saves all the visited files from time to time (based on counting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 your keystrokes) without being asked. This is called @dfn{auto-saving}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 It prevents you from losing more than a limited amount of work if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 system crashes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 When Emacs determines it is time for auto-saving, each buffer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 considered and is auto-saved if auto-saving is turned on for it and it has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 changed since the last time it was auto-saved. If any auto-saving is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 done, the message @samp{Auto-saving...} is displayed in the echo area until
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 auto-saving is finished. Errors occurring during auto-saving are caught
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 so that they do not interfere with the execution of commands you have been
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 typing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 * Files: Auto Save Files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 * Control: Auto Save Control.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 * Recover:: Recovering text from auto-save files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 @node Auto Save Files, Auto Save Control, Auto Save, Auto Save
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 @subsection Auto-Save Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 Auto-saving does not normally write to the files you visited, because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 it can be undesirable to save a program that is in an inconsistent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 state when you have made only half of a planned change. Instead, auto-saving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 is done in a different file called the @dfn{auto-save file}, and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 visited file is changed only when you save explicitly, for example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 with @kbd{C-x C-s}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 Normally, the name of the auto-save file is generated by appending
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 @samp{#} to the front and back of the visited file name. Thus, a buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 visiting file @file{foo.c} would be auto-saved in a file @file{#foo.c#}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 Most buffers that are not visiting files are auto-saved only if you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 request it explicitly; when they are auto-saved, the auto-save file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 is generated by appending @samp{#%} to the front and @samp{#} to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 back of buffer name. For example, the @samp{*mail*} buffer in which you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 compose messages to be sent is auto-saved in a file named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 @file{#%*mail*#}. Names of auto-save files are generated this way
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 unless you customize the functions @code{make-auto-save-file-name} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 @code{auto-save-file-name-p} to do something different. The file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 to be used for auto-saving a buffer is calculated at the time auto-saving is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 turned on in that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 @vindex auto-save-visited-file-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 If you want auto-saving to be done in the visited file, set the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 @code{auto-save-visited-file-name} to be non-@code{nil}. In this mode,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 there is really no difference between auto-saving and explicit saving.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 @vindex delete-auto-save-files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 Emacs deletes a buffer's auto-save file when you explicitly save the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 buffer. To inhibit the deletion, set the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 @code{delete-auto-save-files} to @code{nil}. Changing the visited file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 name with @kbd{C-x C-w} or @code{set-visited-file-name} renames any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 auto-save file to correspond to the new visited name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 @node Auto Save Control, Recover, Auto Save Files, Auto Save
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 @subsection Controlling Auto-Saving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 @vindex auto-save-default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 @findex auto-save-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 Each time you visit a file, auto-saving is turned on for that file's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 buffer if the variable @code{auto-save-default} is non-@code{nil} (but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 not in batch mode; @pxref{Entering Emacs}). The default for this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 variable is @code{t}, so Emacs auto-saves buffers that visit files by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 default. You can use the command @kbd{M-x auto-save-mode} to turn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 auto-saving for a buffer on or off. Like other minor mode commands,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 @kbd{M-x auto-save-mode} turns auto-saving on with a positive argument,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 off with a zero or negative argument; with no argument, it toggles.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 @vindex auto-save-interval
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 @findex do-auto-save
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 Emacs performs auto-saving periodically based on counting how many
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 characters you have typed since the last time auto-saving happened. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 variable @code{auto-save-interval} specifies the number of characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 between auto-saves. By default, it is 300. Emacs also auto-saves
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 whenever you call the function @code{do-auto-save}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 Emacs also does auto-saving whenever it gets a fatal error. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 includes killing the Emacs job with a shell command such as @code{kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 -emacs}, or disconnecting a phone line or network connection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 @vindex auto-save-timeout
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 You can set the number of seconds of idle time before an auto-save is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 done. Setting the value of the variable @code{auto-save-timeout} to zero or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 @code{nil} will disable auto-saving due to idleness.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 The actual amount of idle time between auto-saves is logarithmically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 related to the size of the current buffer. This variable is the number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 of seconds after which an auto-save will happen when the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 For this variable to have any effect, you must do @code{(require 'timer)}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 @node Recover, , Auto Save Control, Auto Save
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 @subsection Recovering Data from Auto-Saves
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 @findex recover-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 If you want to use the contents of an auto-save file to recover from a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 loss of data, use the command @kbd{M-x recover-file @key{RET} @var{file}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 @key{RET}}. Emacs visits @var{file} and then (after your confirmation)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 restores the contents from the auto-save file @file{#@var{file}#}. You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 can then save the file with @kbd{C-x C-s} to put the recovered text into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 @var{file} itself. For example, to recover file @file{foo.c} from its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 auto-save file @file{#foo.c#}, do:@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 M-x recover-file @key{RET} foo.c @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 C-x C-s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 Before asking for confirmation, @kbd{M-x recover-file} displays a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 directory listing describing the specified file and the auto-save file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 so you can compare their sizes and dates. If the auto-save file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 is older, @kbd{M-x recover-file} does not offer to read it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 Auto-saving is disabled by @kbd{M-x recover-file} because using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 this command implies that the auto-save file contains valuable data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 from a past session. If you save the data in the visited file and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 then go on to make new changes, turn auto-saving back on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 with @kbd{M-x auto-save-mode}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 @node Version Control, ListDir, Auto Save, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 @section Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 @cindex version control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 @dfn{Version control systems} are packages that can record multiple
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 versions of a source file, usually storing the unchanged parts of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 file just once. Version control systems also record history information
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 such as the creation time of each version, who created it, and a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 description of what was changed in that version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 The GNU project recommends the version control system known as RCS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 which is free software and available from the Free Software Foundation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 Emacs supports use of either RCS or SCCS (a proprietary, but widely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 used, version control system that is not quite as powerful as RCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 through a facility called VC. The same Emacs commands work with either
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 RCS or SCCS, so you hardly have to know which one of them you are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 using.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 * Concepts of VC:: Basic version control information;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 checking files in and out.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 * Editing with VC:: Commands for editing a file maintained
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 with version control.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 * Variables for Check-in/out:: Variables that affect the commands used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 to check files in or out.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 * Log Entries:: Logging your changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 * Change Logs and VC:: Generating a change log file from log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 entries.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 * Old Versions:: Examining and comparing old versions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 * VC Status:: Commands to view the VC status of files and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 look at log entries.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 * Renaming and VC:: A command to rename both the source and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 master file correctly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 * Snapshots:: How to make and use snapshots, a set of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 file versions that can be treated as a unit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 * Version Headers:: Inserting version control headers into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 working files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 @node Concepts of VC, Editing with VC, Version Control, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 @subsection Concepts of Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 @cindex RCS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 @cindex SCCS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 @cindex master file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 @cindex registered file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 @cindex work file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 When a file is under version control, we also say that it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 @dfn{registered} in the version control system. Each registered file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 has a corresponding @dfn{master file} which represents the file's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 present state plus its change history, so that you can reconstruct from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 it either the current version or any specified earlier version. Usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 the master file also records a @dfn{log entry} for each version describing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 what was changed in that version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 The file that is maintained under version control is sometimes called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 the @dfn{work file} corresponding to its master file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 @cindex checking out files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 @cindex checking in files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 @cindex locking and version control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 To examine a file, you @dfn{check it out}. This extracts a version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 of the source file (typically, the most recent) from the master file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 If you want to edit the file, you must check it out @dfn{locked}. Only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 one user can do this at a time for any given source file. (This kind
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 of locking is completely unrelated to the locking that Emacs uses to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 detect simultaneous editing of a file.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 When you are done with your editing, you must @dfn{check in} the new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 version. This records the new version in the master file, and unlocks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 the source file so that other people can lock it and thus modify it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 Checkin and checkout are the basic operations of version control. You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 can do both of them with a single Emacs command: @w{@kbd{C-x C-q}}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (@code{vc-toggle-read-only}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 A @dfn{snapshot} is a coherent collection of versions of the various
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 files that make up a program. @xref{Snapshots}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 @node Editing with VC, Variables for Check-in/out, Concepts of VC, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 @subsection Editing with Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 When you visit a file that is maintained using version control, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 mode line displays @samp{RCS} or @samp{SCCS} to inform you that version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 control is in use, and also (in case you care) which low-level system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 the file is actually stored in. Normally, such a source file is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 read-only, and the mode line indicates this with @samp{%%}. With RCS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 the mode line also indicates the number of the head version, which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 normally also the version you are looking at.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 These are the commands for editing a file maintained with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 version control:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 @item C-x C-q
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 Check the visited file in or out.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 @item C-x v u
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 Revert the buffer and the file to the last checked in version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 @item C-x v c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 Remove the last-entered change from the master for the visited file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 This undoes your last check-in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 @item C-x v i
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 Register the visited file in version control.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 (@kbd{C-x v} is the prefix key for version control commands; all of these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 commands except for @kbd{C-x C-q} start with @kbd{C-x v}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 @kindex C-x C-q @r{(version control)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 When you want to modify a file maintained with version control, type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 @kbd{C-x C-q} (@code{vc-toggle-read-only}). This @dfn{checks out} the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 file, and tells RCS or SCCS to lock the file. This means making the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 file writable for you (but not for anyone else).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 @cindex log entry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 When you are finished editing the file, type @kbd{C-x C-q} again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 When used on a file that is checked out, this command checks the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 in. But check-in does not start immediately; first, you must enter the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 @dfn{log entry}---a description of the changes in the new version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 @kbd{C-x C-q} pops up a buffer for you to enter this in. When you are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 finished typing in the log entry, type @kbd{C-c C-c} to terminate it; this is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 when actual check-in takes place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 Once you have checked in your changes, the file is unlocked, so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 other users can lock it and modify it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 @vindex vc-make-backup-files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 Emacs does not save backup files for source files that are maintained
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 with version control. If you want to make backup files despite version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 control, set the variable @code{vc-make-backup-files} to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 non-@code{nil} value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 @vindex vc-keep-workfiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 Normally the work file exists all the time, whether it is locked or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 not. If you set @code{vc-keep-workfiles} to @code{nil}, then checking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 in a new version with @kbd{C-x C-q} deletes the work file; but any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 attempt to visit the file with Emacs creates it again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 It is not impossible to lock a file that someone else has locked. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 you try to check out a file that is locked, @kbd{C-x C-q} asks you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 whether you want to ``steal the lock.'' If you say yes, the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 becomes locked by you, but a message is sent to the person who had
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 formerly locked the file, to inform him of what has happened. The mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 line indicates that a file is locked by someone else by displaying the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 login name of that person, before the version number.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 @kindex C-x v u
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 @findex vc-revert-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 If you want to discard your current set of changes and revert to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 last version checked in, use @kbd{C-x v u} (@code{vc-revert-buffer}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 This cancels your last check-out, leaving the file unlocked. If you want
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 to make a different set of changes, you must first check the file out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 again. @kbd{C-x v u} requires confirmation, unless it sees that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 you haven't made any changes since the last checked-in version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 @kbd{C-x v u} is also the command to use if you lock a file and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 don't actually change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 @kindex C-x v c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 @findex vc-cancel-version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 You can cancel a change after checking it in, with @kbd{C-x v c}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 (@code{vc-cancel-version}). This command discards all record of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 most recent checked in version, so be careful about using it. It
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 requires confirmation with @kbd{yes}. By default, @kbd{C-x v c} reverts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 your workfile and buffer to the previous version (the one that precedes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 the version that is deleted), but you can prevent the reversion by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 giving the command a prefix argument. Then the buffer does not change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 This command with a prefix argument is useful when you have checked in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 a change and then discover a trivial error in it; you can cancel the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 erroneous check-in, fix the error, and repeat the check-in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 Be careful when invoking @kbd{C-x v c}, as it is easy to throw away a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 lot of work with it. To help you be careful, this command always
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 requires confirmation with @samp{yes}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 @kindex C-x v i
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 @findex vc-register
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 @vindex vc-default-back-end
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 You can register the visited file for version control using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 @w{@kbd{C-x v i}} (@code{vc-register}). If the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 @code{vc-default-back-end} is non-@code{nil}, it specifies which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 version control system to use; otherwise, this uses RCS if it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 installed on your system and SCCS if not. After @kbd{C-x v i},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 the file is unlocked and read-only. Type @kbd{C-x C-q} if you wish to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 edit it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 By default, the initial version number is 1.1. If you want to use a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 different number, give @kbd{C-x v i} a prefix argument; then it reads
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 the initial version number using the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 @vindex vc-initial-comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 If @code{vc-initial-comment} is non-@code{nil}, @kbd{C-x v i} reads
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 an initial comment (much like a log entry) to describe the purpose of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 this source file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 @kindex C-u C-x v v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 @findex vc-next-action
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 To specify the version number for a subsequent checkin, use the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 command @kbd{C-u C-x v v}. @kbd{C-x v v} (@code{vc-next-action}) is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 command that @kbd{C-x C-q} uses to do the ``real work'' when the visited
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 file uses version control. When used for checkin, and given a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 argument, it reads the version number with the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 @node Variables for Check-in/out, Log Entries, Editing with VC, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 @subsection Variables Affecting Check-in and Check-out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 @c There is no need to tell users about vc-master-templates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 @vindex vc-suppress-confirm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 If @code{vc-suppress-confirm} is non-@code{nil}, then @kbd{C-x C-q}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 and @kbd{C-x v i} can save the current buffer without asking, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 @kbd{C-x v u} also operates without asking for confirmation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 (This variable does not affect @kbd{C-x v c}; that is so drastic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 that it should always ask for confirmation.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 @vindex vc-command-messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 VC mode does much of its work by running the shell commands for RCS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 and SCCS. If @code{vc-command-messages} is non-@code{nil}, VC displays
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 messages to indicate which shell commands it runs, and additional
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 messages when the commands finish.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 Normally, VC assumes that it can deduce the locked/unlocked state of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 files by looking at the file permissions of the work file; this is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 fast. However, if the @file{RCS} or @file{SCCS} subdirectory is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 actually a symbolic link, then VC does not trust the file permissions to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 reflect this status.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 @vindex vc-mistrust-permissions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 You can specify the criterion for whether to trust the file permissions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 by setting the variable @code{vc-mistrust-permissions}. Its value may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 be @code{t} (always mistrust the file permissions and check the master
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 file), @code{nil} (always trust the file permissions), or a function of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 one argument which makes the decision. The argument is the directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 name of the @file{RCS} or @file{SCCS} subdirectory. A non-@code{nil}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 value from the function says to mistrust the file permissions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 If you find that the file permissions of work files are changed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 erroneously, set @code{vc-mistrust-permissions} to @code{t}. Then VC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 always checks the master file to determine the file's status.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 @vindex vc-path
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 You can specify additional directories to search for version control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 programs by setting the variable @code{vc-path}. These directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 are searched before the usual search path. The proper result usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 happens automatically.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 @node Log Entries, Change Logs and VC, Variables for Check-in/out, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 @subsection Log Entries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 When you're editing an initial comment or log entry for inclusion in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 master file, finish your entry by typing @kbd{C-c C-c}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 @item C-c C-c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 Finish the comment edit normally (@code{vc-finish-logentry}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 This finishes check-in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 To abort check-in, just don't type @kbd{C-c C-c} in that buffer. You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 can switch buffers and do other editing. As long as you don't try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 check in another file, the entry you were editing remains in its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 buffer, and you can go back to that buffer at any time to complete the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 check-in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 If you change several source files for the same reason, it is often
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 convenient to specify the same log entry for many of the files. To do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 this, use the history of previous log entries. The commands @kbd{M-n},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 @kbd{M-p}, @kbd{M-s} and @kbd{M-r} for doing this work just like the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 minibuffer history commands (except that these versions are used outside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 the minibuffer).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 @vindex vc-log-mode-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 Each time you check in a file, the log entry buffer is put into VC Log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 mode, which involves running two hooks: @code{text-mode-hook} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 @code{vc-log-mode-hook}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 @node Change Logs and VC, Old Versions, Log Entries, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 @subsection Change Logs and VC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 If you use RCS for a program and also maintain a change log file for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 it (@pxref{Change Log}), you can generate change log entries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 automatically from the version control log entries:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 @item C-x v a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 @kindex C-x v a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 @findex vc-update-change-log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 Visit the current directory's change log file and create new entries for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 versions checked in since the most recent entry in the change log file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 (@code{vc-update-change-log}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 This command works with RCS only; it does not work with SCCS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 For example, suppose the first line of @file{ChangeLog} is dated 10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 April 1992, and that the only check-in since then was by Nathaniel
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 Bowditch to @file{rcs2log} on 8 May 1992 with log text @samp{Ignore log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 messages that start with `#'.}. Then @kbd{C-x v a} visits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 @file{ChangeLog} and inserts text like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 Fri May 8 21:45:00 1992 Nathaniel Bowditch (nat@@apn.org)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 * rcs2log: Ignore log messages that start with `#'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 You can then edit the new change log entry further as you wish.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 Normally, the log entry for file @file{foo} is displayed as @samp{*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 foo: @var{text of log entry}}. The @samp{:} after @file{foo} is omitted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 if the text of the log entry starts with @w{@samp{(@var{functionname}):
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 }}. For example, if the log entry for @file{vc.el} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 @samp{(vc-do-command): Check call-process status.}, then the text in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 @file{ChangeLog} looks like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 Wed May 6 10:53:00 1992 Nathaniel Bowditch (nat@@apn.org)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 * vc.el (vc-do-command): Check call-process status.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 When @kbd{C-x v a} adds several change log entries at once, it groups
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 related log entries together if they all are checked in by the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 author at nearly the same time. If the log entries for several such
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 files all have the same text, it coalesces them into a single entry.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 For example, suppose the most recent checkins have the following log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 entries:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 @exdent For @file{vc.texinfo}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 Fix expansion typos.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 @exdent For @file{vc.el}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 @exdent For @file{vc-hooks.el}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 They appear like this in @file{ChangeLog}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 Wed Apr 1 08:57:59 1992 Nathaniel Bowditch (nat@@apn.org)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 * vc.texinfo: Fix expansion typos.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 * vc.el, vc-hooks.el: Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 Normally, @kbd{C-x v a} separates log entries by a blank line, but you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 can mark several related log entries to be clumped together (without an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 intervening blank line) by starting the text of each related log entry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 with a label of the form @w{@samp{@{@var{clumpname}@} }}. The label
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 itself is not copied to @file{ChangeLog}. For example, suppose the log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 entries are:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 @exdent For @file{vc.texinfo}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 @{expand@} Fix expansion typos.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 @exdent For @file{vc.el}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 @{expand@} Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 @exdent For @file{vc-hooks.el}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 @{expand@} Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 Then the text in @file{ChangeLog} looks like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 Wed Apr 1 08:57:59 1992 Nathaniel Bowditch (nat@@apn.org)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 * vc.texinfo: Fix expansion typos.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 * vc.el, vc-hooks.el: Don't call expand-file-name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 A log entry whose text begins with @samp{#} is not copied to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 @file{ChangeLog}. For example, if you merely fix some misspellings in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 comments, you can log the change with an entry beginning with @samp{#}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 to avoid putting such trivia into @file{ChangeLog}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 @node Old Versions, VC Status, Change Logs and VC, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 @subsection Examining And Comparing Old Versions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 @item C-x v ~ @var{version} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 Examine version @var{version} of the visited file, in a buffer of its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 own (@code{vc-version-other-window}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 @item C-x v =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 Compare the current buffer contents with the latest checked-in version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 of the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 @item C-u C-x v = @var{file} @key{RET} @var{oldvers} @key{RET} @var{newvers} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 Compare the specified two versions of @var{file}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 @findex vc-version-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 @kindex C-x v ~
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 You can examine any version of a file by first visiting it, and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 using @kbd{C-x v ~ @var{version} @key{RET}}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 (@code{vc-version-other-window}). This puts the text of version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 @var{version} in a file named @file{@var{filename}.~@var{version}~},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 then visits it in a separate window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 @findex vc-diff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 @kindex C-x v =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 To compare two versions of a file, use the command @kbd{C-x v =}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 (@code{vc-diff}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 Plain @kbd{C-x v =} compares the current buffer contents (saving them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 in the file if necessary) with the last checked-in version of the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 With a prefix argument, @kbd{C-x v =} reads a file name and two version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 numbers, then compares those versions of the specified file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 If you supply a directory name instead of the name of a work file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 this command compares the two specified versions of all registered files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 in that directory and its subdirectories. You can also specify a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 snapshot name (@pxref{Snapshots}) instead of one or both version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 numbers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 You can specify a checked-in version by its number; you can specify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 the most recent checked-in version with an empty version number.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 This command works by running the @code{vcdiff} utility, getting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 options from the variable @code{diff-switches}. It displays the output
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 in a special buffer in another window. Unlike the @kbd{M-x diff}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 command, @kbd{C-x v =} does not try to find the changes in the old and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 new versions. This is because one or both versions normally do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 exist as files. They exist only in the records of the master file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 @xref{Comparing Files}, for more information about @kbd{M-x diff}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 @node VC Status, Renaming and VC, Old Versions, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 @subsection VC Status Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 @kindex C-x v l
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 @findex vc-print-log
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 To view the detailed version control status and history of a file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 type @kbd{C-x v l} (@code{vc-print-log}). It displays the history of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 changes to the current file, including the text of the log entries. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 output appears in a separate window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 @kindex C-x v d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 @findex vc-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 When you are working on a large program, it's often useful to find all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 the files that are currently locked, or all the files maintained in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 version control at all. You can use @kbd{C-x v d} (@code{vc-directory})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 to show all the locked files in or beneath the current directory. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 includes all files that are locked by any user. @kbd{C-u C-x v d} lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 all files in or beneath the current directory that are maintained with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 version control.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 The list of files is displayed as a buffer that uses an augmented
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 Dired mode. The names of the users locking various files are shown (in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 parentheses) in place of the owner and group. All the normal Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 commands work in this buffer. Most interactive VC commands work also,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 and apply to the file name on the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 The @kbd{C-x v v} command (@code{vc-next-action}), when used in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 augmented Dired buffer, operates on all the marked files (or the file on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 the current line). If it operates on more than one file, it handles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 each file according to its current state; thus, it may check out one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 file and check in another (because it is already checked out). If it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 has to check in any files, it reads a single log entry, then uses that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 text for all the files being checked in. This can be convenient for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 registering or checking in several files at once, as part of the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 @node Renaming and VC, Snapshots, VC Status, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 @subsection Renaming VC Work Files and Master Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 @findex vc-rename-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 When you rename a registered file, you must also rename its master
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 file correspondingly to get proper results. Use @code{vc-rename-file}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 to rename the source file as you specify, and rename its master file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 accordingly. It also updates any snapshots (@pxref{Snapshots}) that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 mention the file, so that they use the new name; despite this, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 snapshot thus modified may not completely work (@pxref{Snapshot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 Caveats}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 You cannot use @code{vc-rename-file} on a file that is locked by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 someone else.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 @node Snapshots, Version Headers, Renaming and VC, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 @subsection Snapshots
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 @cindex snapshots and version control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 A @dfn{snapshot} is a named set of file versions (one for each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 registered file) that you can treat as a unit. One important kind of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 snapshot is a @dfn{release}, a (theoretically) stable version of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 system that is ready for distribution to users.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 * Making Snapshots:: The snapshot facilities.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 * Snapshot Caveats:: Things to be careful of when using snapshots.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 @node Making Snapshots, Snapshot Caveats, Snapshots, Snapshots
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 @subsubsection Making and Using Snapshots
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 There are two basic commands for snapshots; one makes a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 snapshot with a given name, the other retrieves a named snapshot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 @kindex C-x v s
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 @findex vc-create-snapshot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 @item C-x v s @var{name} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 Define the last saved versions of every registered file in or under the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 current directory as a snapshot named @var{name}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 (@code{vc-create-snapshot}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 @kindex C-x v r
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 @findex vc-retrieve-snapshot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 @item C-x v r @var{name} @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 Check out all registered files at or below the current directory level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 using whatever versions correspond to the snapshot @var{name}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 (@code{vc-retrieve-snapshot}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 This command reports an error if any files are locked at or below the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 current directory, without changing anything; this is to avoid
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 overwriting work in progress.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 A snapshot uses a very small amount of resources---just enough to record
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 the list of file names and which version belongs to the snapshot. Thus,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 you need not hesitate to create snapshots whenever they are useful.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 You can give a snapshot name as an argument to @kbd{C-x v =} or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 @kbd{C-x v ~} (@pxref{Old Versions}). Thus, you can use it to compare a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 snapshot against the current files, or two snapshots against each other,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 or a snapshot against a named version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 @node Snapshot Caveats, , Making Snapshots, Snapshots
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 @subsubsection Snapshot Caveats
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 @cindex named configurations (RCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 VC's snapshot facilities are modeled on RCS's named-configuration
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 support. They use RCS's native facilities for this, so under VC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 snapshots made using RCS are visible even when you bypass VC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 @c worded verbosely to avoid overfull hbox.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 For SCCS, VC implements snapshots itself. The files it uses contain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 name/file/version-number triples. These snapshots are visible only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 through VC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 A snapshot is a set of checked-in versions. So make sure that all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 files are checked in and not locked when you make a snapshot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 File renaming and deletion can create some difficulties with snapshots.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 This is not a VC-specific problem, but a general design issue in version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 control systems that no one has solved very well yet.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 If you rename a registered file, you need to rename its master along
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 with it (the command @code{vc-rename-file} does this automatically). If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 you are using SCCS, you must also update the records of the snapshot, to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 mention the file by its new name (@code{vc-rename-file} does this,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 too). An old snapshot that refers to a master file that no longer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 exists under the recorded name is invalid; VC can no longer retrieve
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 it. It would be beyond the scope of this manual to explain enough about
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 RCS and SCCS to explain how to update the snapshots by hand.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 Using @code{vc-rename-file} makes the snapshot remain valid for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 retrieval, but it does not solve all problems. For example, some of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 files in the program probably refer to others by name. At the very
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 least, the makefile probably mentions the file that you renamed. If you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 retrieve an old snapshot, the renamed file is retrieved under its new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 name, which is not the name that the makefile expects. So the program
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 won't really work as retrieved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 @node Version Headers, , Snapshots, Version Control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 @subsection Inserting Version Control Headers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 Sometimes it is convenient to put version identification strings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 directly into working files. Certain special strings called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 @dfn{version headers} are replaced in each successive version by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 number of that version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 @kindex C-x v h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 @findex vc-insert-headers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 insert a suitable header string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 @item C-x v h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 Insert headers in a file for use with your version-control system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 @vindex vc-header-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 The default header string is @samp{\$Id\$} for RCS and @samp{\%W\%}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 for SCCS. (The actual strings inserted do not have the backslashes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 in them. They were placed in the Info source file so that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 strings don't get interpreted as version-control headers when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 Info source files are maintained under version control.) You can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 specify other headers to insert by setting the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 @code{vc-header-alist}. Its value is a list of elements of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 @code{(@var{program} . @var{string})} where @var{program} is @code{RCS}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 or @code{SCCS} and @var{string} is the string to use.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 Instead of a single string, you can specify a list of strings; then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 each string in the list is inserted as a separate header on a line of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 its own.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 It is often necessary to use ``superfluous'' backslashes when writing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 the strings that you put in this variable. This is to prevent the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 string in the constant from being interpreted as a header itself if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 Emacs Lisp file containing it is maintained with version control.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 @vindex vc-comment-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 Each header is inserted surrounded by tabs, inside comment delimiters,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 on a new line at the start of the buffer. Normally the ordinary comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 start and comment end strings of the current mode are used, but for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 certain modes, there are special comment delimiters for this purpose;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 the variable @code{vc-comment-alist} specifies them. Each element of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 this list has the form @code{(@var{mode} @var{starter} @var{ender})}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 @vindex vc-static-header-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 The variable @code{vc-static-header-alist} specifies further strings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 to add based on the name of the buffer. Its value should be a list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 elements of the form @code{(@var{regexp} . @var{format})}. Whenever
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 @var{regexp} matches the buffer name, @var{format} is inserted as part
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 of the header. A header line is inserted for each element that matches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 the buffer name, and for each string specified by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 @code{vc-header-alist}. The header line is made by processing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 string from @code{vc-header-alist} with the format taken from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 element. The default value for @code{vc-static-header-alist} is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 (("\\.c$" .
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 #endif /* lint */\n"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 which specifies insertion of a string of this form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 @group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 #ifndef lint
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 static char vcid[] = "@var{string}";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 #endif /* lint */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 @end group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 @node ListDir, Comparing Files, Version Control, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 @section Listing a File Directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 @cindex file directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 @cindex directory listing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 Files are organized by Unix into @dfn{directories}. A @dfn{directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 listing} is a list of all the files in a directory. Emacs provides
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 directory listings in brief format (file names only) and verbose format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 (sizes, dates, and authors included).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 @item C-x C-d @var{dir-or-pattern}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 Print a brief directory listing (@code{list-directory}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 @item C-u C-x C-d @var{dir-or-pattern}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 Print a verbose directory listing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 @findex list-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 @kindex C-x C-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 To print a directory listing, use @kbd{C-x C-d}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 (@code{list-directory}). This command prompts in the minibuffer for a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 file name which is either a directory to be listed or pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 containing wildcards for the files to be listed. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 C-x C-d /u2/emacs/etc @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 lists all the files in directory @file{/u2/emacs/etc}. An example of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 specifying a file name pattern is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 C-x C-d /u2/emacs/src/*.c @key{RET}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 Normally, @kbd{C-x C-d} prints a brief directory listing containing just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 file names. A numeric argument (regardless of value) tells it to print a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 verbose listing (like @code{ls -l}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 @vindex list-directory-brief-switches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 @vindex list-directory-verbose-switches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 Emacs obtains the text of a directory listing by running @code{ls} in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 an inferior process. Two Emacs variables control the switches passed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 @code{ls}: @code{list-directory-brief-switches} is a string giving the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 switches to use in brief listings (@code{"-CF"} by default).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 @code{list-directory-verbose-switches} is a string giving the switches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 to use in a verbose listing (@code{"-l"} by default).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 The variable @code{directory-abbrev-alist} is an alist of abbreviations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 for file directories. The list consists of elements of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 @code{(FROM . TO)}, each meaning to replace @code{FROM} with @code{TO}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 when it appears in a directory name. This replacement is done when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 setting up the default directory of a newly visited file. Every @code{FROM}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 string should start with `@samp{^}'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 Use this feature when you have directories which you normally refer to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 via absolute symbolic links. Make @code{TO} the name of the link, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 @code{FROM} the name it is linked to.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 @node Comparing Files, Dired, ListDir, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 @section Comparing Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 @cindex comparing files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 @findex diff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 @vindex diff-switches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 The command @kbd{M-x diff} compares two files, displaying the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 differences in an Emacs buffer named @samp{*Diff*}. It works by running
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 the @code{diff} program, using options taken from the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 @code{diff-switches}, whose value should be a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 The buffer @samp{*Diff*} has Compilation mode as its major mode, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 you can use @kbd{C-x `} to visit successive changed locations in the two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 source files. You can also move to a particular hunk of changes and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 type @kbd{C-c C-c} to find the corresponding source location. You can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 also use the other special commands of Compilation mode: @key{SPC} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 @key{DEL} for scrolling, and @kbd{M-p} and @kbd{M-n} for cursor motion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 @xref{Compilation}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 @findex diff-backup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 The command @kbd{M-x diff-backup} compares a specified file with its most
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 recent backup. If you specify the name of a backup file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 @code{diff-backup} compares it with the source file that it is a backup
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 of.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 @findex compare-windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 @cindex comparing files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 The command @kbd{M-x compare-windows} compares the text in the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 window with that in the next window. Comparison starts at point in each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 window. Point moves forward in each window, a character at a time in each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 window, until the next characters in the two windows are different. Then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 the command is finished. For more information about windows in Emacs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 @ref{Windows}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 @vindex compare-ignore-case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 With a numeric argument, @code{compare-windows} ignores changes in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 whitespace. If the variable @code{compare-ignore-case} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 non-@code{nil}, it ignores differences in case as well.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 @node Dired, Misc File Ops, Comparing Files, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 @section Dired, the Directory Editor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 @cindex Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 @cindex deletion (of files)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 Dired makes it easy to delete or visit many of the files in a single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 directory at once. It creates an Emacs buffer containing a listing of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 directory. You can use the normal Emacs commands to move around in this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 buffer and special Dired commands to operate on the files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 * Enter: Dired Enter. How to invoke Dired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 * Edit: Dired Edit. Editing the Dired buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 * Deletion: Dired Deletion. Deleting files with Dired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 * Immed: Dired Immed. Other file operations through Dired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 @node Dired Enter, Dired Edit, Dired, Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 @subsection Entering Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 @findex dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 @kindex C-x d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 @vindex dired-listing-switches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 To invoke dired, type @kbd{C-x d} or @kbd{M-x dired}. The command reads a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 directory name or wildcard file name pattern as a minibuffer argument just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 like the @code{list-directory} command, @kbd{C-x C-d}. Where @code{dired}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 differs from @code{list-directory} is in naming the buffer after the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 directory name or the wildcard pattern used for the listing, and putting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 the buffer into Dired mode so that the special commands of Dired are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 available in it. The variable @code{dired-listing-switches} is a string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 used as an argument to @code{ls} in making the directory; this string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 @i{must} contain @samp{-l}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 @findex dired-other-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 @kindex C-x 4 d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 To display the Dired buffer in another window rather than in the selected
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 window, use @kbd{C-x 4 d} (@code{dired-other-window)} instead of @kbd{C-x d}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 @node Dired Edit, Dired Deletion, Dired Enter, Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 @subsection Editing in Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 Once the Dired buffer exists, you can switch freely between it and other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 Emacs buffers. Whenever the Dired buffer is selected, certain special
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 commands are provided that operate on files that are listed. The Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 buffer is ``read-only'', and inserting text in it is not useful, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 ordinary printing characters such as @kbd{d} and @kbd{x} are used for Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 commands. Most Dired commands operate on the file described by the line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 that point is on. Some commands perform operations immediately; others
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 ``flag'' a file to be operated on later.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 Most Dired commands that operate on the current line's file also treat a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 numeric argument as a repeat count, meaning to act on the files of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 next few lines. A negative argument means to operate on the files of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 preceding lines, and leave point on the first of those lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 All the usual Emacs cursor motion commands are available in Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 buffers. Some special purpose commands are also provided. The keys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 @kbd{C-n} and @kbd{C-p} are redefined so that they try to position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 the cursor at the beginning of the filename on the line, rather than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 at the beginning of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 For extra convenience, @key{SPC} and @kbd{n} in Dired are equivalent to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 @kbd{C-n}. @kbd{p} is equivalent to @kbd{C-p}. Moving by lines is done so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 often in Dired that it deserves to be easy to type. @key{DEL} (move up and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 unflag) is often useful simply for moving up.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 The @kbd{g} command in Dired runs @code{revert-buffer} to reinitialize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 the buffer from the actual disk directory and show any changes made in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 directory by programs other than Dired. All deletion flags in the Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 buffer are lost when this is done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 @node Dired Deletion, Dired Immed, Dired Edit, Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 @subsection Deleting Files With Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 The primary use of Dired is to flag files for deletion and then delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 @item d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 Flag this file for deletion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 @item u
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 Remove deletion-flag on this line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 @item @key{DEL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 Remove deletion-flag on previous line, moving point to that line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 @item x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 Delete the files that are flagged for deletion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 @item #
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 Flag all auto-save files (files whose names start and end with @samp{#})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 for deletion (@pxref{Auto Save}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 @item ~
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 Flag all backup files (files whose names end with @samp{~}) for deletion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 (@pxref{Backup}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 @item .@: @r{(Period)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 Flag excess numeric backup files for deletion. The oldest and newest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 few backup files of any one file are exempt; the middle ones are flagged.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 You can flag a file for deletion by moving to the line describing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 file and typing @kbd{d} or @kbd{C-d}. The deletion flag is visible as a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 @samp{D} at the beginning of the line. Point is moved to the beginning of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 the next line, so that repeated @kbd{d} commands flag successive files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 The files are flagged for deletion rather than deleted immediately to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 avoid the danger of deleting a file accidentally. Until you direct Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 to delete the flagged files, you can remove deletion flags using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 commands @kbd{u} and @key{DEL}. @kbd{u} works just like @kbd{d}, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 removes flags rather than making flags. @key{DEL} moves upward, removing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 flags; it is like @kbd{u} with numeric argument automatically negated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 To delete the flagged files, type @kbd{x}. This command first displays a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 list of all the file names flagged for deletion, and requests confirmation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 with @kbd{yes}. Once you confirm, all the flagged files are deleted, and their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 lines are deleted from the text of the Dired buffer. The shortened Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 buffer remains selected. If you answer @kbd{no} or quit with @kbd{C-g}, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 return immediately to Dired, with the deletion flags still present and no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 files actually deleted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 The @kbd{#}, @kbd{~}, and @kbd{.} commands flag many files for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 deletion, based on their names. These commands are useful precisely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 because they do not actually delete any files; you can remove the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 deletion flags from any flagged files that you really wish to keep.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 @kbd{#} flags for deletion all files that appear to have been made by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 auto-saving (that is, files whose names begin and end with @samp{#}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 @kbd{~} flags for deletion all files that appear to have been made as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 backups for files that were edited (that is, files whose names end with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 @samp{~}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 @vindex dired-kept-versions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 @kbd{.} (Period) flags just some of the backup files for deletion: only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 numeric backups that are not among the oldest few nor the newest few
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 backups of any one file. Normally @code{dired-kept-versions} (not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 @code{kept-new-versions}; that applies only when saving) specifies the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 number of newest versions of each file to keep, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 @code{kept-old-versions} specifies the number of oldest versions to keep.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 Period with a positive numeric argument, as in @kbd{C-u 3 .}, specifies the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 number of newest versions to keep, overriding @code{dired-kept-versions}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 A negative numeric argument overrides @code{kept-old-versions}, using minus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 the value of the argument to specify the number of oldest versions of each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 file to keep.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 @node Dired Immed, , Dired Deletion, Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 @subsection Immediate File Operations in Dired
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 Some file operations in Dired take place immediately when they are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 requested.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 @item C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 Copies the file described on the current line. You must supply a file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 to copy to, using the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 @item f
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 Visits the file described on the current line. It is just like typing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 @kbd{C-x C-f} and supplying that file name. If the file on this line is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 subdirectory, @kbd{f} actually causes Dired to be invoked on that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 subdirectory. @xref{Visiting}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 @item o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 Like @kbd{f}, but uses another window to display the file's buffer. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 Dired buffer remains visible in the first window. This is like using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 @kbd{C-x 4 C-f} to visit the file. @xref{Windows}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 @item R
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 Renames the file described on the current line. You must supply a file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 name to rename to, using the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 @item v
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 Views the file described on this line using @kbd{M-x view-file}. Viewing a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 file is like visiting it, but is slanted toward moving around in the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 conveniently and does not allow changing the file. @xref{Misc File
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 Ops,View File}. Viewing a file that is a directory runs Dired on that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 directory.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 @node Misc File Ops, , Dired, Files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 @section Miscellaneous File Operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 Emacs has commands for performing many other operations on files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 All operate on one file; they do not accept wildcard file names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 @findex add-name-to-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 You can use the command @kbd{M-x add-name-to-file} to add a name to an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 existing file without removing the old name. The new name must belong
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 on the file system that the file is on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 @findex append-to-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 @kbd{M-x append-to-file} adds the text of the region to the end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 specified file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 @findex copy-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 @cindex copying files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 @kbd{M-x copy-file} reads the file @var{old} and writes a new file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 named @var{new} with the same contents. Confirmation is required if a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 file named @var{new} already exists, because copying overwrites the old
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 contents of the file @var{new}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 @findex delete-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 @cindex deletion (of files)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 @kbd{M-x delete-file} deletes a specified file, like the @code{rm}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 command in the shell. If you are deleting many files in one directory, it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 may be more convenient to use Dired (@pxref{Dired}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 @findex insert-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 @kbd{M-x insert-file} inserts a copy of the contents of a specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 file into the current buffer at point, leaving point unchanged before the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 contents and the mark after them. @xref{Mark}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 @findex make-symbolic-link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 @kbd{M-x make-symbolic-link} reads two file names @var{old} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 @var{linkname}, and then creates a symbolic link named @var{linkname}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 and pointing at @var{old}. Future attempts to open file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 @var{linkname} will then refer to the file named @var{old} at the time
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 the opening is done, or will result in an error if the name @var{old} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 not in use at that time. Confirmation is required if you create the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 link while @var{linkname} is in use. Note that not all systems support
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 symbolic links.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 @findex rename-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 @kbd{M-x rename-file} reads two file names @var{old} and @var{new} using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 the minibuffer, then renames file @var{old} as @var{new}. If a file named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 @var{new} already exists, you must confirm with @kbd{yes} or renaming is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 done; this is because renaming causes the previous meaning of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 name @var{new} to be lost. If @var{old} and @var{new} are on different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 file systems, the file @var{old} is copied and deleted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 @findex view-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 @cindex viewing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 @kbd{M-x view-file} allows you to scan or read a file by sequential
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 screenfuls. It reads a file name argument using the minibuffer. After
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 reading the file into an Emacs buffer, @code{view-file} reads and displays
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 one windowful. You can then type @key{SPC} to scroll forward one window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 or @key{DEL} to scroll backward. Various other commands are provided for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 moving around in the file, but none for changing it; type @kbd{C-h} while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 viewing a file for a list of them. Most commands are the default Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 cursor motion commands. To exit from viewing, type @kbd{C-c}.