25829
|
1 @c This is part of the Emacs manual.
|
|
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
|
|
3 @c See file emacs.texi for copying conditions.
|
|
4 @node Files, Buffers, Fixit, Top
|
|
5 @chapter File Handling
|
|
6 @cindex files
|
|
7
|
|
8 The operating system stores data permanently in named @dfn{files}. So
|
|
9 most of the text you edit with Emacs comes from a file and is ultimately
|
|
10 stored in a file.
|
|
11
|
|
12 To edit a file, you must tell Emacs to read the file and prepare a
|
|
13 buffer containing a copy of the file's text. This is called
|
|
14 @dfn{visiting} the file. Editing commands apply directly to text in the
|
|
15 buffer; that is, to the copy inside Emacs. Your changes appear in the
|
|
16 file itself only when you @dfn{save} the buffer back into the file.
|
|
17
|
|
18 In addition to visiting and saving files, Emacs can delete, copy,
|
|
19 rename, and append to files, keep multiple versions of them, and operate
|
|
20 on file directories.
|
|
21
|
|
22 @menu
|
|
23 * File Names:: How to type and edit file-name arguments.
|
|
24 * Visiting:: Visiting a file prepares Emacs to edit the file.
|
|
25 * Saving:: Saving makes your changes permanent.
|
|
26 * Reverting:: Reverting cancels all the changes not saved.
|
|
27 * Auto Save:: Auto Save periodically protects against loss of data.
|
|
28 * File Aliases:: Handling multiple names for one file.
|
|
29 * Version Control:: Version control systems (RCS, CVS and SCCS).
|
|
30 * Directories:: Creating, deleting, and listing file directories.
|
|
31 * Comparing Files:: Finding where two files differ.
|
|
32 * Misc File Ops:: Other things you can do on files.
|
|
33 * Compressed Files:: Accessing compressed files.
|
|
34 * Remote Files:: Accessing files on other sites.
|
|
35 * Quoted File Names:: Quoting special characters in file names.
|
|
36 @end menu
|
|
37
|
|
38 @node File Names
|
|
39 @section File Names
|
|
40 @cindex file names
|
|
41
|
|
42 Most Emacs commands that operate on a file require you to specify the
|
|
43 file name. (Saving and reverting are exceptions; the buffer knows which
|
|
44 file name to use for them.) You enter the file name using the
|
|
45 minibuffer (@pxref{Minibuffer}). @dfn{Completion} is available, to make
|
|
46 it easier to specify long file names. @xref{Completion}.
|
|
47
|
|
48 For most operations, there is a @dfn{default file name} which is used
|
|
49 if you type just @key{RET} to enter an empty argument. Normally the
|
|
50 default file name is the name of the file visited in the current buffer;
|
|
51 this makes it easy to operate on that file with any of the Emacs file
|
|
52 commands.
|
|
53
|
|
54 @vindex default-directory
|
|
55 Each buffer has a default directory, normally the same as the
|
|
56 directory of the file visited in that buffer. When you enter a file
|
|
57 name without a directory, the default directory is used. If you specify
|
|
58 a directory in a relative fashion, with a name that does not start with
|
|
59 a slash, it is interpreted with respect to the default directory. The
|
|
60 default directory is kept in the variable @code{default-directory},
|
|
61 which has a separate value in every buffer.
|
|
62
|
|
63 For example, if the default file name is @file{/u/rms/gnu/gnu.tasks} then
|
|
64 the default directory is @file{/u/rms/gnu/}. If you type just @samp{foo},
|
|
65 which does not specify a directory, it is short for @file{/u/rms/gnu/foo}.
|
|
66 @samp{../.login} would stand for @file{/u/rms/.login}. @samp{new/foo}
|
|
67 would stand for the file name @file{/u/rms/gnu/new/foo}.
|
|
68
|
|
69 @findex cd
|
|
70 @findex pwd
|
|
71 The command @kbd{M-x pwd} prints the current buffer's default
|
|
72 directory, and the command @kbd{M-x cd} sets it (to a value read using
|
|
73 the minibuffer). A buffer's default directory changes only when the
|
|
74 @code{cd} command is used. A file-visiting buffer's default directory
|
|
75 is initialized to the directory of the file that is visited there. If
|
|
76 you create a buffer with @kbd{C-x b}, its default directory is copied
|
|
77 from that of the buffer that was current at the time.
|
|
78
|
|
79 @vindex insert-default-directory
|
|
80 The default directory actually appears in the minibuffer when the
|
|
81 minibuffer becomes active to read a file name. This serves two
|
|
82 purposes: it @emph{shows} you what the default is, so that you can type
|
|
83 a relative file name and know with certainty what it will mean, and it
|
|
84 allows you to @emph{edit} the default to specify a different directory.
|
|
85 This insertion of the default directory is inhibited if the variable
|
|
86 @code{insert-default-directory} is set to @code{nil}.
|
|
87
|
|
88 Note that it is legitimate to type an absolute file name after you
|
|
89 enter the minibuffer, ignoring the presence of the default directory
|
|
90 name as part of the text. The final minibuffer contents may look
|
|
91 invalid, but that is not so. For example, if the minibuffer starts out
|
|
92 with @samp{/usr/tmp/} and you add @samp{/x1/rms/foo}, you get
|
|
93 @samp{/usr/tmp//x1/rms/foo}; but Emacs ignores everything through the
|
|
94 first slash in the double slash; the result is @samp{/x1/rms/foo}.
|
|
95 @xref{Minibuffer File}.
|
|
96
|
|
97 @samp{$} in a file name is used to substitute environment variables.
|
|
98 For example, if you have used the shell command @samp{export
|
|
99 FOO=rms/hacks} to set up an environment variable named @code{FOO}, then
|
|
100 you can use @file{/u/$FOO/test.c} or @file{/u/$@{FOO@}/test.c} as an
|
|
101 abbreviation for @file{/u/rms/hacks/test.c}. The environment variable
|
|
102 name consists of all the alphanumeric characters after the @samp{$};
|
|
103 alternatively, it may be enclosed in braces after the @samp{$}. Note
|
|
104 that shell commands to set environment variables affect Emacs only if
|
|
105 done before Emacs is started.
|
|
106
|
|
107 To access a file with @samp{$} in its name, type @samp{$$}. This pair
|
|
108 is converted to a single @samp{$} at the same time as variable
|
|
109 substitution is performed for single @samp{$}. Alternatively, quote the
|
|
110 whole file name with @samp{/:} (@pxref{Quoted File Names}).
|
|
111
|
|
112 @findex substitute-in-file-name
|
|
113 The Lisp function that performs the substitution is called
|
|
114 @code{substitute-in-file-name}. The substitution is performed only on
|
|
115 file names read as such using the minibuffer.
|
|
116
|
|
117 You can include non-ASCII characters in file names if you set the
|
|
118 variable @code{file-name-coding-system} to a non-@code{nil} value.
|
|
119 @xref{Specify Coding}.
|
|
120
|
|
121 @node Visiting
|
|
122 @section Visiting Files
|
|
123 @cindex visiting files
|
|
124
|
|
125 @c WideCommands
|
|
126 @table @kbd
|
|
127 @item C-x C-f
|
|
128 Visit a file (@code{find-file}).
|
|
129 @item C-x C-r
|
|
130 Visit a file for viewing, without allowing changes to it
|
|
131 (@code{find-file-read-only}).
|
|
132 @item C-x C-v
|
|
133 Visit a different file instead of the one visited last
|
|
134 (@code{find-alternate-file}).
|
|
135 @item C-x 4 f
|
|
136 Visit a file, in another window (@code{find-file-other-window}). Don't
|
|
137 alter what is displayed in the selected window.
|
|
138 @item C-x 5 f
|
|
139 Visit a file, in a new frame (@code{find-file-other-frame}). Don't
|
|
140 alter what is displayed in the selected frame.
|
|
141 @item M-x find-file-literally
|
|
142 Visit a file with no conversion of the contents.
|
|
143 @end table
|
|
144
|
|
145 @cindex files, visiting and saving
|
|
146 @cindex visiting files
|
|
147 @cindex saving files
|
|
148 @dfn{Visiting} a file means copying its contents into an Emacs buffer
|
|
149 so you can edit them. Emacs makes a new buffer for each file that you
|
|
150 visit. We say that this buffer is visiting the file that it was created
|
|
151 to hold. Emacs constructs the buffer name from the file name by
|
|
152 throwing away the directory, keeping just the name proper. For example,
|
|
153 a file named @file{/usr/rms/emacs.tex} would get a buffer named
|
|
154 @samp{emacs.tex}. If there is already a buffer with that name, a unique
|
|
155 name is constructed by appending @samp{<2>}, @samp{<3>}, or so on, using
|
|
156 the lowest number that makes a name that is not already in use.
|
|
157
|
|
158 Each window's mode line shows the name of the buffer that is being displayed
|
|
159 in that window, so you can always tell what buffer you are editing.
|
|
160
|
|
161 The changes you make with editing commands are made in the Emacs
|
|
162 buffer. They do not take effect in the file that you visited, or any
|
|
163 place permanent, until you @dfn{save} the buffer. Saving the buffer
|
|
164 means that Emacs writes the current contents of the buffer into its
|
|
165 visited file. @xref{Saving}.
|
|
166
|
|
167 @cindex modified (buffer)
|
|
168 If a buffer contains changes that have not been saved, we say the
|
|
169 buffer is @dfn{modified}. This is important because it implies that
|
|
170 some changes will be lost if the buffer is not saved. The mode line
|
|
171 displays two stars near the left margin to indicate that the buffer is
|
|
172 modified.
|
|
173
|
|
174 @kindex C-x C-f
|
|
175 @findex find-file
|
|
176 To visit a file, use the command @kbd{C-x C-f} (@code{find-file}). Follow
|
|
177 the command with the name of the file you wish to visit, terminated by a
|
|
178 @key{RET}.
|
|
179
|
|
180 The file name is read using the minibuffer (@pxref{Minibuffer}), with
|
|
181 defaulting and completion in the standard manner (@pxref{File Names}).
|
|
182 While in the minibuffer, you can abort @kbd{C-x C-f} by typing @kbd{C-g}.
|
|
183
|
|
184 Your confirmation that @kbd{C-x C-f} has completed successfully is the
|
|
185 appearance of new text on the screen and a new buffer name in the mode
|
|
186 line. If the specified file does not exist and could not be created, or
|
|
187 cannot be read, then you get an error, with an error message displayed
|
|
188 in the echo area.
|
|
189
|
|
190 If you visit a file that is already in Emacs, @kbd{C-x C-f} does not make
|
|
191 another copy. It selects the existing buffer containing that file.
|
|
192 However, before doing so, it checks that the file itself has not changed
|
|
193 since you visited or saved it last. If the file has changed, a warning
|
|
194 message is printed. @xref{Interlocking,,Simultaneous Editing}.
|
|
195
|
|
196 @cindex creating files
|
|
197 What if you want to create a new file? Just visit it. Emacs prints
|
|
198 @samp{(New File)} in the echo area, but in other respects behaves as if
|
|
199 you had visited an existing empty file. If you make any changes and
|
|
200 save them, the file is created.
|
|
201
|
|
202 Emacs recognizes from the contents of a file which convention it uses
|
|
203 to separate lines---newline (used on GNU/Linux and on Unix),
|
|
204 carriage-return linefeed (used on Microsoft systems), or just
|
|
205 carriage-return (used on the Macintosh)---and automatically converts the
|
|
206 contents to the normal Emacs convention, which is that the newline
|
|
207 character separates lines. This is a part of the general feature of
|
|
208 coding system conversion (@pxref{Coding Systems}), and makes it possible
|
|
209 to edit files imported from various different operating systems with
|
|
210 equal convenience. If you change the text and save the file, Emacs
|
|
211 performs the inverse conversion, changing newlines back into
|
|
212 carriage-return linefeed or just carriage-return if appropriate.
|
|
213
|
|
214 @vindex find-file-run-dired
|
|
215 If the file you specify is actually a directory, @kbd{C-x C-f} invokes
|
|
216 Dired, the Emacs directory browser, so that you can ``edit'' the contents
|
|
217 of the directory (@pxref{Dired}). Dired is a convenient way to delete,
|
|
218 look at, or operate on the files in the directory. However, if the
|
|
219 variable @code{find-file-run-dired} is @code{nil}, then it is an error
|
|
220 to try to visit a directory.
|
|
221
|
|
222 If the file name you specify contains wildcard characters, Emacs
|
|
223 visits all the files that match it. @xref{Quoted File Names}, if you
|
|
224 want to visit a file whose name actually contains wildcard characters.
|
|
225
|
|
226 If you visit a file that the operating system won't let you modify,
|
|
227 Emacs makes the buffer read-only, so that you won't go ahead and make
|
|
228 changes that you'll have trouble saving afterward. You can make the
|
|
229 buffer writable with @kbd{C-x C-q} (@code{vc-toggle-read-only}).
|
|
230 @xref{Misc Buffer}.
|
|
231
|
|
232 @kindex C-x C-r
|
|
233 @findex find-file-read-only
|
|
234 Occasionally you might want to visit a file as read-only in order to
|
|
235 protect yourself from entering changes accidentally; do so by visiting
|
|
236 the file with the command @kbd{C-x C-r} (@code{find-file-read-only}).
|
|
237
|
|
238 @kindex C-x C-v
|
|
239 @findex find-alternate-file
|
|
240 If you visit a nonexistent file unintentionally (because you typed the
|
|
241 wrong file name), use the @kbd{C-x C-v} command
|
|
242 (@code{find-alternate-file}) to visit the file you really wanted.
|
|
243 @kbd{C-x C-v} is similar to @kbd{C-x C-f}, but it kills the current
|
|
244 buffer (after first offering to save it if it is modified). When it
|
|
245 reads the file name to visit, it inserts the entire default file name in
|
|
246 the buffer, with point just after the directory part; this is convenient
|
|
247 if you made a slight error in typing the name.
|
|
248
|
|
249 If you find a file which exists but cannot be read, @kbd{C-x C-f}
|
|
250 signals an error.
|
|
251
|
|
252 @kindex C-x 4 f
|
|
253 @findex find-file-other-window
|
|
254 @kbd{C-x 4 f} (@code{find-file-other-window}) is like @kbd{C-x C-f}
|
|
255 except that the buffer containing the specified file is selected in another
|
|
256 window. The window that was selected before @kbd{C-x 4 f} continues to
|
|
257 show the same buffer it was already showing. If this command is used when
|
|
258 only one window is being displayed, that window is split in two, with one
|
|
259 window showing the same buffer as before, and the other one showing the
|
|
260 newly requested file. @xref{Windows}.
|
|
261
|
|
262 @kindex C-x 5 f
|
|
263 @findex find-file-other-frame
|
|
264 @kbd{C-x 5 f} (@code{find-file-other-frame}) is similar, but opens a
|
|
265 new frame, or makes visible any existing frame showing the file you
|
|
266 seek. This feature is available only when you are using a window
|
|
267 system. @xref{Frames}.
|
|
268
|
|
269 @findex find-file-literally
|
|
270 If you wish to edit a file as a sequence of characters with no special
|
|
271 encoding or conversion, use the @kbd{M-x find-file-literally} command.
|
|
272 It visits a file, like @kbd{C-x C-f}, but does not do format conversion
|
|
273 (@pxref{Formatted Text}), character code conversion (@pxref{Coding
|
|
274 Systems}), or automatic uncompression (@pxref{Compressed Files}).
|
|
275 If you already have visited the same file in the usual (non-literal)
|
|
276 manner, this command asks you whether to visit it literally instead.
|
|
277
|
|
278 @vindex find-file-hooks
|
|
279 @vindex find-file-not-found-hooks
|
|
280 Two special hook variables allow extensions to modify the operation of
|
|
281 visiting files. Visiting a file that does not exist runs the functions
|
|
282 in the list @code{find-file-not-found-hooks}; this variable holds a list
|
|
283 of functions, and the functions are called one by one (with no
|
|
284 arguments) until one of them returns non-@code{nil}. This is not a
|
|
285 normal hook, and the name ends in @samp{-hooks} rather than @samp{-hook}
|
|
286 to indicate that fact.
|
|
287
|
|
288 Any visiting of a file, whether extant or not, expects
|
|
289 @code{find-file-hooks} to contain a list of functions, and calls them
|
|
290 all, one by one, with no arguments. This variable is really a normal
|
|
291 hook, but it has an abnormal name for historical compatibility. In the
|
|
292 case of a nonexistent file, the @code{find-file-not-found-hooks} are run
|
|
293 first. @xref{Hooks}.
|
|
294
|
|
295 There are several ways to specify automatically the major mode for
|
|
296 editing the file (@pxref{Choosing Modes}), and to specify local
|
|
297 variables defined for that file (@pxref{File Variables}).
|
|
298
|
|
299 @node Saving
|
|
300 @section Saving Files
|
|
301
|
|
302 @dfn{Saving} a buffer in Emacs means writing its contents back into the file
|
|
303 that was visited in the buffer.
|
|
304
|
|
305 @table @kbd
|
|
306 @item C-x C-s
|
|
307 Save the current buffer in its visited file (@code{save-buffer}).
|
|
308 @item C-x s
|
|
309 Save any or all buffers in their visited files (@code{save-some-buffers}).
|
|
310 @item M-~
|
|
311 Forget that the current buffer has been changed (@code{not-modified}).
|
|
312 @item C-x C-w
|
|
313 Save the current buffer in a specified file (@code{write-file}).
|
|
314 @item M-x set-visited-file-name
|
|
315 Change file the name under which the current buffer will be saved.
|
|
316 @end table
|
|
317
|
|
318 @kindex C-x C-s
|
|
319 @findex save-buffer
|
|
320 When you wish to save the file and make your changes permanent, type
|
|
321 @kbd{C-x C-s} (@code{save-buffer}). After saving is finished, @kbd{C-x C-s}
|
|
322 displays a message like this:
|
|
323
|
|
324 @example
|
|
325 Wrote /u/rms/gnu/gnu.tasks
|
|
326 @end example
|
|
327
|
|
328 @noindent
|
|
329 If the selected buffer is not modified (no changes have been made in it
|
|
330 since the buffer was created or last saved), saving is not really done,
|
|
331 because it would have no effect. Instead, @kbd{C-x C-s} displays a message
|
|
332 like this in the echo area:
|
|
333
|
|
334 @example
|
|
335 (No changes need to be saved)
|
|
336 @end example
|
|
337
|
|
338 @kindex C-x s
|
|
339 @findex save-some-buffers
|
|
340 The command @kbd{C-x s} (@code{save-some-buffers}) offers to save any
|
|
341 or all modified buffers. It asks you what to do with each buffer. The
|
|
342 possible responses are analogous to those of @code{query-replace}:
|
|
343
|
|
344 @table @kbd
|
|
345 @item y
|
|
346 Save this buffer and ask about the rest of the buffers.
|
|
347 @item n
|
|
348 Don't save this buffer, but ask about the rest of the buffers.
|
|
349 @item !
|
|
350 Save this buffer and all the rest with no more questions.
|
|
351 @c following generates acceptable underfull hbox
|
|
352 @item @key{RET}
|
|
353 Terminate @code{save-some-buffers} without any more saving.
|
|
354 @item .
|
|
355 Save this buffer, then exit @code{save-some-buffers} without even asking
|
|
356 about other buffers.
|
|
357 @item C-r
|
|
358 View the buffer that you are currently being asked about. When you exit
|
|
359 View mode, you get back to @code{save-some-buffers}, which asks the
|
|
360 question again.
|
|
361 @item C-h
|
|
362 Display a help message about these options.
|
|
363 @end table
|
|
364
|
|
365 @kbd{C-x C-c}, the key sequence to exit Emacs, invokes
|
|
366 @code{save-some-buffers} and therefore asks the same questions.
|
|
367
|
|
368 @kindex M-~
|
|
369 @findex not-modified
|
|
370 If you have changed a buffer but you do not want to save the changes,
|
|
371 you should take some action to prevent it. Otherwise, each time you use
|
|
372 @kbd{C-x s} or @kbd{C-x C-c}, you are liable to save this buffer by
|
|
373 mistake. One thing you can do is type @kbd{M-~} (@code{not-modified}),
|
|
374 which clears out the indication that the buffer is modified. If you do
|
|
375 this, none of the save commands will believe that the buffer needs to be
|
|
376 saved. (@samp{~} is often used as a mathematical symbol for `not'; thus
|
|
377 @kbd{M-~} is `not', metafied.) You could also use
|
|
378 @code{set-visited-file-name} (see below) to mark the buffer as visiting
|
|
379 a different file name, one which is not in use for anything important.
|
|
380 Alternatively, you can cancel all the changes made since the file was
|
|
381 visited or saved, by reading the text from the file again. This is
|
|
382 called @dfn{reverting}. @xref{Reverting}. You could also undo all the
|
|
383 changes by repeating the undo command @kbd{C-x u} until you have undone
|
|
384 all the changes; but reverting is easier.
|
|
385
|
|
386 @findex set-visited-file-name
|
|
387 @kbd{M-x set-visited-file-name} alters the name of the file that the
|
|
388 current buffer is visiting. It reads the new file name using the
|
|
389 minibuffer. Then it specifies the visited file name and changes the
|
|
390 buffer name correspondingly (as long as the new name is not in use).
|
|
391 @code{set-visited-file-name} does not save the buffer in the newly
|
|
392 visited file; it just alters the records inside Emacs in case you do
|
|
393 save later. It also marks the buffer as ``modified'' so that @kbd{C-x
|
|
394 C-s} in that buffer @emph{will} save.
|
|
395
|
|
396 @kindex C-x C-w
|
|
397 @findex write-file
|
|
398 If you wish to mark the buffer as visiting a different file and save it
|
|
399 right away, use @kbd{C-x C-w} (@code{write-file}). It is precisely
|
|
400 equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}.
|
|
401 @kbd{C-x C-s} used on a buffer that is not visiting a file has the
|
|
402 same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the
|
|
403 buffer as visiting that file, and saves it there. The default file name in
|
|
404 a buffer that is not visiting a file is made by combining the buffer name
|
|
405 with the buffer's default directory.
|
|
406
|
|
407 If the new file name implies a major mode, then @kbd{C-x C-w} switches
|
|
408 to that major mode, in most cases. The command
|
|
409 @code{set-visited-file-name} also does this. @xref{Choosing Modes}.
|
|
410
|
|
411 If Emacs is about to save a file and sees that the date of the latest
|
|
412 version on disk does not match what Emacs last read or wrote, Emacs
|
|
413 notifies you of this fact, because it probably indicates a problem caused
|
|
414 by simultaneous editing and requires your immediate attention.
|
|
415 @xref{Interlocking,, Simultaneous Editing}.
|
|
416
|
|
417 @vindex require-final-newline
|
|
418 If the variable @code{require-final-newline} is non-@code{nil}, Emacs
|
|
419 puts a newline at the end of any file that doesn't already end in one,
|
|
420 every time a file is saved or written. The default is @code{nil}.
|
|
421
|
|
422 @menu
|
|
423 * Backup:: How Emacs saves the old version of your file.
|
|
424 * Interlocking:: How Emacs protects against simultaneous editing
|
|
425 of one file by two users.
|
|
426 @end menu
|
|
427
|
|
428 @node Backup
|
|
429 @subsection Backup Files
|
|
430 @cindex backup file
|
|
431 @vindex make-backup-files
|
|
432 @vindex vc-make-backup-files
|
|
433 @vindex backup-enable-predicate
|
|
434
|
|
435 On most operating systems, rewriting a file automatically destroys all
|
|
436 record of what the file used to contain. Thus, saving a file from Emacs
|
|
437 throws away the old contents of the file---or it would, except that
|
|
438 Emacs carefully copies the old contents to another file, called the
|
|
439 @dfn{backup} file, before actually saving.
|
|
440
|
|
441 For most files, the variable @code{make-backup-files} determines
|
|
442 whether to make backup files. On most operating systems, its default
|
|
443 value is @code{t}, so that Emacs does write backup files.
|
|
444
|
|
445 For files managed by a version control system (@pxref{Version
|
|
446 Control}), the variable @code{vc-make-backup-files} determines whether
|
|
447 to make backup files. By default, it is @code{nil}, since backup files
|
|
448 are redundant when you store all the previous versions in a version
|
|
449 control system. @xref{VC Workfile Handling}.
|
|
450
|
|
451 The default value of the @code{backup-enable-predicate} variable
|
|
452 prevents backup files being written for files in @file{/tmp}.
|
|
453
|
|
454 At your option, Emacs can keep either a single backup file or a series of
|
|
455 numbered backup files for each file that you edit.
|
|
456
|
|
457 Emacs makes a backup for a file only the first time the file is saved
|
|
458 from one buffer. No matter how many times you save a file, its backup file
|
|
459 continues to contain the contents from before the file was visited.
|
|
460 Normally this means that the backup file contains the contents from before
|
|
461 the current editing session; however, if you kill the buffer and then visit
|
|
462 the file again, a new backup file will be made by the next save.
|
|
463
|
|
464 You can also explicitly request making another backup file from a
|
|
465 buffer even though it has already been saved at least once. If you save
|
|
466 the buffer with @kbd{C-u C-x C-s}, the version thus saved will be made
|
|
467 into a backup file if you save the buffer again. @kbd{C-u C-u C-x C-s}
|
|
468 saves the buffer, but first makes the previous file contents into a new
|
|
469 backup file. @kbd{C-u C-u C-u C-x C-s} does both things: it makes a
|
|
470 backup from the previous contents, and arranges to make another from the
|
|
471 newly saved contents, if you save again.
|
|
472
|
|
473 @menu
|
|
474 * Names: Backup Names. How backup files are named;
|
|
475 choosing single or numbered backup files.
|
|
476 * Deletion: Backup Deletion. Emacs deletes excess numbered backups.
|
|
477 * Copying: Backup Copying. Backups can be made by copying or renaming.
|
|
478 @end menu
|
|
479
|
|
480 @node Backup Names
|
|
481 @subsubsection Single or Numbered Backups
|
|
482
|
|
483 If you choose to have a single backup file (this is the default),
|
|
484 the backup file's name is constructed by appending @samp{~} to the
|
|
485 file name being edited; thus, the backup file for @file{eval.c} would
|
|
486 be @file{eval.c~}.
|
|
487
|
|
488 If you choose to have a series of numbered backup files, backup file
|
|
489 names are made by appending @samp{.~}, the number, and another @samp{~} to
|
|
490 the original file name. Thus, the backup files of @file{eval.c} would be
|
|
491 called @file{eval.c.~1~}, @file{eval.c.~2~}, and so on, through names
|
|
492 like @file{eval.c.~259~} and beyond.
|
|
493
|
|
494 If protection stops you from writing backup files under the usual names,
|
|
495 the backup file is written as @file{%backup%~} in your home directory.
|
|
496 Only one such file can exist, so only the most recently made such backup is
|
|
497 available.
|
|
498
|
|
499 @vindex version-control
|
|
500 The choice of single backup or numbered backups is controlled by the
|
|
501 variable @code{version-control}. Its possible values are
|
|
502
|
|
503 @table @code
|
|
504 @item t
|
|
505 Make numbered backups.
|
|
506 @item nil
|
|
507 Make numbered backups for files that have numbered backups already.
|
|
508 Otherwise, make single backups.
|
|
509 @item never
|
|
510 Do not in any case make numbered backups; always make single backups.
|
|
511 @end table
|
|
512
|
|
513 @noindent
|
|
514 You can set @code{version-control} locally in an individual buffer to
|
|
515 control the making of backups for that buffer's file. For example,
|
|
516 Rmail mode locally sets @code{version-control} to @code{never} to make sure
|
|
517 that there is only one backup for an Rmail file. @xref{Locals}.
|
|
518
|
|
519 @cindex @code{VERSION_CONTROL} environment variable
|
|
520 If you set the environment variable @code{VERSION_CONTROL}, to tell
|
|
521 various GNU utilities what to do with backup files, Emacs also obeys the
|
|
522 environment variable by setting the Lisp variable @code{version-control}
|
|
523 accordingly at startup. If the environment variable's value is @samp{t}
|
|
524 or @samp{numbered}, then @code{version-control} becomes @code{t}; if the
|
|
525 value is @samp{nil} or @samp{existing}, then @code{version-control}
|
|
526 becomes @code{nil}; if it is @samp{never} or @samp{simple}, then
|
|
527 @code{version-control} becomes @code{never}.
|
|
528
|
|
529 @node Backup Deletion
|
|
530 @subsubsection Automatic Deletion of Backups
|
|
531
|
|
532 To prevent unlimited consumption of disk space, Emacs can delete numbered
|
|
533 backup versions automatically. Generally Emacs keeps the first few backups
|
|
534 and the latest few backups, deleting any in between. This happens every
|
|
535 time a new backup is made.
|
|
536
|
|
537 @vindex kept-old-versions
|
|
538 @vindex kept-new-versions
|
|
539 The two variables @code{kept-old-versions} and
|
|
540 @code{kept-new-versions} control this deletion. Their values are,
|
|
541 respectively the number of oldest (lowest-numbered) backups to keep and
|
|
542 the number of newest (highest-numbered) ones to keep, each time a new
|
|
543 backup is made. Recall that these values are used just after a new
|
|
544 backup version is made; that newly made backup is included in the count
|
|
545 in @code{kept-new-versions}. By default, both variables are 2.
|
|
546
|
|
547 @vindex delete-old-versions
|
|
548 If @code{delete-old-versions} is non-@code{nil}, the excess
|
|
549 middle versions are deleted without a murmur. If it is @code{nil}, the
|
|
550 default, then you are asked whether the excess middle versions should
|
|
551 really be deleted.
|
|
552
|
|
553 Dired's @kbd{.} (Period) command can also be used to delete old versions.
|
|
554 @xref{Dired Deletion}.
|
|
555
|
|
556 @node Backup Copying
|
|
557 @subsubsection Copying vs.@: Renaming
|
|
558
|
|
559 Backup files can be made by copying the old file or by renaming it. This
|
|
560 makes a difference when the old file has multiple names. If the old file
|
|
561 is renamed into the backup file, then the alternate names become names for
|
|
562 the backup file. If the old file is copied instead, then the alternate
|
|
563 names remain names for the file that you are editing, and the contents
|
|
564 accessed by those names will be the new contents.
|
|
565
|
|
566 The method of making a backup file may also affect the file's owner
|
|
567 and group. If copying is used, these do not change. If renaming is used,
|
|
568 you become the file's owner, and the file's group becomes the default
|
|
569 (different operating systems have different defaults for the group).
|
|
570
|
|
571 Having the owner change is usually a good idea, because then the owner
|
|
572 always shows who last edited the file. Also, the owners of the backups
|
|
573 show who produced those versions. Occasionally there is a file whose
|
|
574 owner should not change; it is a good idea for such files to contain
|
|
575 local variable lists to set @code{backup-by-copying-when-mismatch}
|
|
576 locally (@pxref{File Variables}).
|
|
577
|
|
578 @vindex backup-by-copying
|
|
579 @vindex backup-by-copying-when-linked
|
|
580 @vindex backup-by-copying-when-mismatch
|
|
581 The choice of renaming or copying is controlled by three variables.
|
|
582 Renaming is the default choice. If the variable
|
|
583 @code{backup-by-copying} is non-@code{nil}, copying is used. Otherwise,
|
|
584 if the variable @code{backup-by-copying-when-linked} is non-@code{nil},
|
|
585 then copying is used for files that have multiple names, but renaming
|
|
586 may still be used when the file being edited has only one name. If the
|
|
587 variable @code{backup-by-copying-when-mismatch} is non-@code{nil}, then
|
|
588 copying is used if renaming would cause the file's owner or group to
|
|
589 change. @code{backup-by-copying-when-mismatch} is @code{t} by default
|
|
590 if you start Emacs as the superuser.
|
|
591
|
|
592 When a file is managed with a version control system (@pxref{Version
|
|
593 Control}), Emacs does not normally make backups in the usual way for
|
|
594 that file. But check-in and check-out are similar in some ways to
|
|
595 making backups. One unfortunate similarity is that these operations
|
|
596 typically break hard links, disconnecting the file name you visited from
|
|
597 any alternate names for the same file. This has nothing to do with
|
|
598 Emacs---the version control system does it.
|
|
599
|
|
600 @node Interlocking
|
|
601 @subsection Protection against Simultaneous Editing
|
|
602
|
|
603 @cindex file dates
|
|
604 @cindex simultaneous editing
|
|
605 Simultaneous editing occurs when two users visit the same file, both
|
|
606 make changes, and then both save them. If nobody were informed that
|
|
607 this was happening, whichever user saved first would later find that his
|
|
608 changes were lost.
|
|
609
|
|
610 On some systems, Emacs notices immediately when the second user starts
|
|
611 to change the file, and issues an immediate warning. On all systems,
|
|
612 Emacs checks when you save the file, and warns if you are about to
|
|
613 overwrite another user's changes. You can prevent loss of the other
|
|
614 user's work by taking the proper corrective action instead of saving the
|
|
615 file.
|
|
616
|
|
617 @findex ask-user-about-lock
|
|
618 @cindex locking files
|
|
619 When you make the first modification in an Emacs buffer that is
|
|
620 visiting a file, Emacs records that the file is @dfn{locked} by you.
|
|
621 (It does this by creating a symbolic link in the same directory with a
|
|
622 different name.) Emacs removes the lock when you save the changes. The
|
|
623 idea is that the file is locked whenever an Emacs buffer visiting it has
|
|
624 unsaved changes.
|
|
625
|
|
626 @cindex collision
|
|
627 If you begin to modify the buffer while the visited file is locked by
|
|
628 someone else, this constitutes a @dfn{collision}. When Emacs detects a
|
|
629 collision, it asks you what to do, by calling the Lisp function
|
|
630 @code{ask-user-about-lock}. You can redefine this function for the sake
|
|
631 of customization. The standard definition of this function asks you a
|
|
632 question and accepts three possible answers:
|
|
633
|
|
634 @table @kbd
|
|
635 @item s
|
|
636 Steal the lock. Whoever was already changing the file loses the lock,
|
|
637 and you gain the lock.
|
|
638 @item p
|
|
639 Proceed. Go ahead and edit the file despite its being locked by someone else.
|
|
640 @item q
|
|
641 Quit. This causes an error (@code{file-locked}) and the modification you
|
|
642 were trying to make in the buffer does not actually take place.
|
|
643 @end table
|
|
644
|
|
645 Note that locking works on the basis of a file name; if a file has
|
|
646 multiple names, Emacs does not realize that the two names are the same file
|
|
647 and cannot prevent two users from editing it simultaneously under different
|
|
648 names. However, basing locking on names means that Emacs can interlock the
|
|
649 editing of new files that will not really exist until they are saved.
|
|
650
|
|
651 Some systems are not configured to allow Emacs to make locks, and
|
|
652 there are cases where lock files cannot be written. In these cases,
|
|
653 Emacs cannot detect trouble in advance, but it still can detect the
|
|
654 collision when you try to save a file and overwrite someone else's
|
|
655 changes.
|
|
656
|
|
657 If Emacs or the operating system crashes, this may leave behind lock
|
|
658 files which are stale. So you may occasionally get warnings about
|
|
659 spurious collisions. When you determine that the collision is spurious,
|
|
660 just use @kbd{p} to tell Emacs to go ahead anyway.
|
|
661
|
|
662 Every time Emacs saves a buffer, it first checks the last-modification
|
|
663 date of the existing file on disk to verify that it has not changed since the
|
|
664 file was last visited or saved. If the date does not match, it implies
|
|
665 that changes were made in the file in some other way, and these changes are
|
|
666 about to be lost if Emacs actually does save. To prevent this, Emacs
|
|
667 prints a warning message and asks for confirmation before saving.
|
|
668 Occasionally you will know why the file was changed and know that it does
|
|
669 not matter; then you can answer @kbd{yes} and proceed. Otherwise, you should
|
|
670 cancel the save with @kbd{C-g} and investigate the situation.
|
|
671
|
|
672 The first thing you should do when notified that simultaneous editing
|
|
673 has already taken place is to list the directory with @kbd{C-u C-x C-d}
|
|
674 (@pxref{Directories}). This shows the file's current author. You
|
|
675 should attempt to contact him to warn him not to continue editing.
|
|
676 Often the next step is to save the contents of your Emacs buffer under a
|
|
677 different name, and use @code{diff} to compare the two files.@refill
|
|
678
|
|
679 @node Reverting
|
|
680 @section Reverting a Buffer
|
|
681 @findex revert-buffer
|
|
682 @cindex drastic changes
|
|
683
|
|
684 If you have made extensive changes to a file and then change your mind
|
|
685 about them, you can get rid of them by reading in the previous version
|
|
686 of the file. To do this, use @kbd{M-x revert-buffer}, which operates on
|
|
687 the current buffer. Since reverting a buffer unintentionally could lose
|
|
688 a lot of work, you must confirm this command with @kbd{yes}.
|
|
689
|
|
690 @code{revert-buffer} keeps point at the same distance (measured in
|
|
691 characters) from the beginning of the file. If the file was edited only
|
|
692 slightly, you will be at approximately the same piece of text after
|
|
693 reverting as before. If you have made drastic changes, the same value of
|
|
694 point in the old file may address a totally different piece of text.
|
|
695
|
|
696 Reverting marks the buffer as ``not modified'' until another change is
|
|
697 made.
|
|
698
|
|
699 Some kinds of buffers whose contents reflect data bases other than files,
|
|
700 such as Dired buffers, can also be reverted. For them, reverting means
|
|
701 recalculating their contents from the appropriate data base. Buffers
|
|
702 created explicitly with @kbd{C-x b} cannot be reverted; @code{revert-buffer}
|
|
703 reports an error when asked to do so.
|
|
704
|
|
705 @vindex revert-without-query
|
|
706 When you edit a file that changes automatically and frequently---for
|
|
707 example, a log of output from a process that continues to run---it may be
|
|
708 useful for Emacs to revert the file without querying you, whenever you
|
|
709 visit the file again with @kbd{C-x C-f}.
|
|
710
|
|
711 To request this behavior, set the variable @code{revert-without-query}
|
|
712 to a list of regular expressions. When a file name matches one of these
|
|
713 regular expressions, @code{find-file} and @code{revert-buffer} will
|
|
714 revert it automatically if it has changed---provided the buffer itself
|
|
715 is not modified. (If you have edited the text, it would be wrong to
|
|
716 discard your changes.)
|
|
717
|
|
718 @node Auto Save
|
|
719 @section Auto-Saving: Protection Against Disasters
|
|
720 @cindex Auto Save mode
|
|
721 @cindex mode, Auto Save
|
|
722 @cindex crashes
|
|
723
|
|
724 Emacs saves all the visited files from time to time (based on counting
|
|
725 your keystrokes) without being asked. This is called @dfn{auto-saving}.
|
|
726 It prevents you from losing more than a limited amount of work if the
|
|
727 system crashes.
|
|
728
|
|
729 When Emacs determines that it is time for auto-saving, each buffer is
|
|
730 considered, and is auto-saved if auto-saving is turned on for it and it
|
|
731 has been changed since the last time it was auto-saved. The message
|
|
732 @samp{Auto-saving...} is displayed in the echo area during auto-saving,
|
|
733 if any files are actually auto-saved. Errors occurring during
|
|
734 auto-saving are caught so that they do not interfere with the execution
|
|
735 of commands you have been typing.
|
|
736
|
|
737 @menu
|
|
738 * Files: Auto Save Files. The file where auto-saved changes are
|
|
739 actually made until you save the file.
|
|
740 * Control: Auto Save Control. Controlling when and how often to auto-save.
|
|
741 * Recover:: Recovering text from auto-save files.
|
|
742 @end menu
|
|
743
|
|
744 @node Auto Save Files
|
|
745 @subsection Auto-Save Files
|
|
746
|
|
747 Auto-saving does not normally save in the files that you visited, because
|
|
748 it can be very undesirable to save a program that is in an inconsistent
|
|
749 state when you have made half of a planned change. Instead, auto-saving
|
|
750 is done in a different file called the @dfn{auto-save file}, and the
|
|
751 visited file is changed only when you request saving explicitly (such as
|
|
752 with @kbd{C-x C-s}).
|
|
753
|
|
754 Normally, the auto-save file name is made by appending @samp{#} to the
|
|
755 front and rear of the visited file name. Thus, a buffer visiting file
|
|
756 @file{foo.c} is auto-saved in a file @file{#foo.c#}. Most buffers that
|
|
757 are not visiting files are auto-saved only if you request it explicitly;
|
|
758 when they are auto-saved, the auto-save file name is made by appending
|
|
759 @samp{#%} to the front and @samp{#} to the rear of buffer name. For
|
|
760 example, the @samp{*mail*} buffer in which you compose messages to be
|
|
761 sent is auto-saved in a file named @file{#%*mail*#}. Auto-save file
|
|
762 names are made this way unless you reprogram parts of Emacs to do
|
|
763 something different (the functions @code{make-auto-save-file-name} and
|
|
764 @code{auto-save-file-name-p}). The file name to be used for auto-saving
|
|
765 in a buffer is calculated when auto-saving is turned on in that buffer.
|
|
766
|
|
767 When you delete a substantial part of the text in a large buffer, auto
|
|
768 save turns off temporarily in that buffer. This is because if you
|
|
769 deleted the text unintentionally, you might find the auto-save file more
|
|
770 useful if it contains the deleted text. To reenable auto-saving after
|
|
771 this happens, save the buffer with @kbd{C-x C-s}, or use @kbd{C-u 1 M-x
|
|
772 auto-save}.
|
|
773
|
|
774 @vindex auto-save-visited-file-name
|
|
775 If you want auto-saving to be done in the visited file, set the variable
|
|
776 @code{auto-save-visited-file-name} to be non-@code{nil}. In this mode,
|
|
777 there is really no difference between auto-saving and explicit saving.
|
|
778
|
|
779 @vindex delete-auto-save-files
|
|
780 A buffer's auto-save file is deleted when you save the buffer in its
|
|
781 visited file. To inhibit this, set the variable @code{delete-auto-save-files}
|
|
782 to @code{nil}. Changing the visited file name with @kbd{C-x C-w} or
|
|
783 @code{set-visited-file-name} renames any auto-save file to go with
|
|
784 the new visited name.
|
|
785
|
|
786 @node Auto Save Control
|
|
787 @subsection Controlling Auto-Saving
|
|
788
|
|
789 @vindex auto-save-default
|
|
790 @findex auto-save-mode
|
|
791 Each time you visit a file, auto-saving is turned on for that file's
|
|
792 buffer if the variable @code{auto-save-default} is non-@code{nil} (but not
|
|
793 in batch mode; @pxref{Entering Emacs}). The default for this variable is
|
|
794 @code{t}, so auto-saving is the usual practice for file-visiting buffers.
|
|
795 Auto-saving can be turned on or off for any existing buffer with the
|
|
796 command @kbd{M-x auto-save-mode}. Like other minor mode commands, @kbd{M-x
|
|
797 auto-save-mode} turns auto-saving on with a positive argument, off with a
|
|
798 zero or negative argument; with no argument, it toggles.
|
|
799
|
|
800 @vindex auto-save-interval
|
|
801 Emacs does auto-saving periodically based on counting how many characters
|
|
802 you have typed since the last time auto-saving was done. The variable
|
|
803 @code{auto-save-interval} specifies how many characters there are between
|
|
804 auto-saves. By default, it is 300.
|
|
805
|
|
806 @vindex auto-save-timeout
|
|
807 Auto-saving also takes place when you stop typing for a while. The
|
|
808 variable @code{auto-save-timeout} says how many seconds Emacs should
|
|
809 wait before it does an auto save (and perhaps also a garbage
|
|
810 collection). (The actual time period is longer if the current buffer is
|
|
811 long; this is a heuristic which aims to keep out of your way when you
|
|
812 are editing long buffers, in which auto-save takes an appreciable amount
|
|
813 of time.) Auto-saving during idle periods accomplishes two things:
|
|
814 first, it makes sure all your work is saved if you go away from the
|
|
815 terminal for a while; second, it may avoid some auto-saving while you
|
|
816 are actually typing.
|
|
817
|
|
818 Emacs also does auto-saving whenever it gets a fatal error. This
|
|
819 includes killing the Emacs job with a shell command such as @samp{kill
|
|
820 %emacs}, or disconnecting a phone line or network connection.
|
|
821
|
|
822 @findex do-auto-save
|
|
823 You can request an auto-save explicitly with the command @kbd{M-x
|
|
824 do-auto-save}.
|
|
825
|
|
826 @node Recover
|
|
827 @subsection Recovering Data from Auto-Saves
|
|
828
|
|
829 @findex recover-file
|
|
830 You can use the contents of an auto-save file to recover from a loss
|
|
831 of data with the command @kbd{M-x recover-file @key{RET} @var{file}
|
|
832 @key{RET}}. This visits @var{file} and then (after your confirmation)
|
|
833 restores the contents from its auto-save file @file{#@var{file}#}.
|
|
834 You can then save with @kbd{C-x C-s} to put the recovered text into
|
|
835 @var{file} itself. For example, to recover file @file{foo.c} from its
|
|
836 auto-save file @file{#foo.c#}, do:@refill
|
|
837
|
|
838 @example
|
|
839 M-x recover-file @key{RET} foo.c @key{RET}
|
|
840 yes @key{RET}
|
|
841 C-x C-s
|
|
842 @end example
|
|
843
|
|
844 Before asking for confirmation, @kbd{M-x recover-file} displays a
|
|
845 directory listing describing the specified file and the auto-save file,
|
|
846 so you can compare their sizes and dates. If the auto-save file
|
|
847 is older, @kbd{M-x recover-file} does not offer to read it.
|
|
848
|
|
849 @findex recover-session
|
|
850 If Emacs or the computer crashes, you can recover all the files you
|
|
851 were editing from their auto save files with the command @kbd{M-x
|
|
852 recover-session}. This first shows you a list of recorded interrupted
|
|
853 sessions. Move point to the one you choose, and type @kbd{C-c C-c}.
|
|
854
|
|
855 Then @code{recover-session} asks about each of the files that were
|
|
856 being edited during that session, asking whether to recover that file.
|
|
857 If you answer @kbd{y}, it calls @code{recover-file}, which works in its
|
|
858 normal fashion. It shows the dates of the original file and its
|
|
859 auto-save file, and asks once again whether to recover that file.
|
|
860
|
|
861 When @code{recover-session} is done, the files you've chosen to
|
|
862 recover are present in Emacs buffers. You should then save them. Only
|
|
863 this---saving them---updates the files themselves.
|
|
864
|
|
865 @vindex auto-save-list-file-prefix
|
|
866 Interrupted sessions are recorded for later recovery in files named
|
|
867 @file{~/.saves-@var{pid}-@var{hostname}}. The @samp{~/.saves} portion of
|
|
868 these names comes from the value of @code{auto-save-list-file-prefix}.
|
|
869 You can arrange to record sessions in a different place by setting that
|
|
870 variable in your @file{.emacs} file, but you'll have to redefine
|
|
871 @code{recover-session} as well to make it look in the new place. If you
|
|
872 set @code{auto-save-list-file-prefix} to @code{nil} in your
|
|
873 @file{.emacs} file, sessions are not recorded for recovery.
|
|
874
|
|
875 @node File Aliases
|
|
876 @section File Name Aliases
|
|
877
|
|
878 Symbolic links and hard links both make it possible for several file
|
|
879 names to refer to the same file. Hard links are alternate names that
|
|
880 refer directly to the file; all the names are equally valid, and no one
|
|
881 of them is preferred. By contrast, a symbolic link is a kind of defined
|
|
882 alias: when @file{foo} is a symbolic link to @file{bar}, you can use
|
|
883 either name to refer to the file, but @file{bar} is the real name, while
|
|
884 @file{foo} is just an alias. More complex cases occur when symbolic
|
|
885 links point to directories.
|
|
886
|
|
887 If you visit two names for the same file, normally Emacs makes
|
|
888 two different buffers, but it warns you about the situation.
|
|
889
|
|
890 @vindex find-file-existing-other-name
|
|
891 If you wish to avoid visiting the same file in two buffers under
|
|
892 different names, set the variable @code{find-file-existing-other-name}
|
|
893 to a non-@code{nil} value. Then @code{find-file} uses the existing
|
|
894 buffer visiting the file, no matter which of the file's names you
|
|
895 specify.
|
|
896
|
|
897 @vindex find-file-visit-truename
|
|
898 @cindex truenames of files
|
|
899 @cindex file truenames
|
|
900 If the variable @code{find-file-visit-truename} is non-@code{nil},
|
|
901 then the file name recorded for a buffer is the file's @dfn{truename}
|
|
902 (made by replacing all symbolic links with their target names), rather
|
|
903 than the name you specify. Setting @code{find-file-visit-truename} also
|
|
904 implies the effect of @code{find-file-existing-other-name}.
|
|
905
|
|
906 @node Version Control
|
|
907 @section Version Control
|
|
908 @cindex version control
|
|
909
|
|
910 @dfn{Version control systems} are packages that can record multiple
|
|
911 versions of a source file, usually storing the unchanged parts of the
|
|
912 file just once. Version control systems also record history information
|
|
913 such as the creation time of each version, who created it, and a
|
|
914 description of what was changed in that version.
|
|
915
|
|
916 The Emacs version control interface is called VC. Its commands work
|
|
917 with three version control systems---RCS, CVS and SCCS. The GNU project
|
|
918 recommends RCS and CVS, which are free software and available from the
|
|
919 Free Software Foundation.
|
|
920
|
|
921 @menu
|
|
922 * Introduction to VC:: How version control works in general.
|
|
923 * VC Mode Line:: How the mode line shows version control status.
|
|
924 * Basic VC Editing:: How to edit a file under version control.
|
|
925 * Old Versions:: Examining and comparing old versions.
|
|
926 * Secondary VC Commands:: The commands used a little less frequently.
|
|
927 * Branches:: Multiple lines of development.
|
|
928 * Snapshots:: Sets of file versions treated as a unit.
|
|
929 * Miscellaneous VC:: Various other commands and features of VC.
|
|
930 * Customizing VC:: Variables that change VC's behavior.
|
|
931 @end menu
|
|
932
|
|
933 @node Introduction to VC
|
|
934 @subsection Introduction to Version Control
|
|
935
|
|
936 VC allows you to use a version control system from within Emacs,
|
|
937 integrating the version control operations smoothly with editing. VC
|
|
938 provides a uniform interface to version control, so that regardless of
|
|
939 which version control system is in use, you can use it the same way.
|
|
940
|
|
941 This section provides a general overview of version control, and
|
|
942 describes the version control systems that VC supports. You can skip
|
|
943 this section if you are already familiar with the version control system
|
|
944 you want to use.
|
|
945
|
|
946 @menu
|
|
947 * Version Systems:: Supported version control back-end systems.
|
|
948 * VC Concepts:: Words and concepts related to version control.
|
|
949 @end menu
|
|
950
|
|
951 @node Version Systems
|
|
952 @subsubsection Supported Version Control Systems
|
|
953
|
|
954 @cindex RCS
|
|
955 @cindex back end (version control)
|
|
956 VC currently works with three different version control systems or
|
|
957 ``back ends'': RCS, CVS, and SCCS.
|
|
958
|
|
959 RCS is a free version control system that is available from the Free
|
|
960 Software Foundation. It is perhaps the most mature of the supported
|
|
961 back ends, and the VC commands are conceptually closest to RCS. Almost
|
|
962 everything you can do with RCS can be done through VC.
|
|
963
|
|
964 @cindex CVS
|
|
965 CVS is built on top of RCS, and extends the features of RCS, allowing
|
|
966 for more sophisticated release management, and concurrent multi-user
|
|
967 development. VC supports basic editing operations under CVS, but for
|
|
968 some less common tasks you still need to call CVS from the command line.
|
|
969 Note also that before using CVS you must set up a repository, which is a
|
|
970 subject too complex to treat here.
|
|
971
|
|
972 @cindex SCCS
|
|
973 SCCS is a proprietary but widely used version control system. In
|
|
974 terms of capabilities, it is the weakest of the three that VC
|
|
975 supports. VC compensates for certain features missing in SCCS
|
|
976 (snapshots, for example) by implementing them itself, but some other VC
|
|
977 features, such as multiple branches, are not available with SCCS. You
|
|
978 should use SCCS only if for some reason you cannot use RCS.
|
|
979
|
|
980 @node VC Concepts
|
|
981 @subsubsection Concepts of Version Control
|
|
982
|
|
983 @cindex master file
|
|
984 @cindex registered file
|
|
985 When a file is under version control, we also say that it is
|
|
986 @dfn{registered} in the version control system. Each registered file
|
|
987 has a corresponding @dfn{master file} which represents the file's
|
|
988 present state plus its change history---enough to reconstruct the
|
|
989 current version or any earlier version. Usually the master file also
|
|
990 records a @dfn{log entry} for each version, describing in words what was
|
|
991 changed in that version.
|
|
992
|
|
993 @cindex work file
|
|
994 @cindex checking out files
|
|
995 The file that is maintained under version control is sometimes called
|
|
996 the @dfn{work file} corresponding to its master file. You edit the work
|
|
997 file and make changes in it, as you would with an ordinary file. (With
|
|
998 SCCS and RCS, you must @dfn{lock} the file before you start to edit it.)
|
|
999 After you are done with a set of changes, you @dfn{check the file in},
|
|
1000 which records the changes in the master file, along with a log entry for
|
|
1001 them.
|
|
1002
|
|
1003 With CVS, there are usually multiple work files corresponding to a
|
|
1004 single master file---often each user has his own copy. It is also
|
|
1005 possible to use RCS in this way, but this is not the usual way to use
|
|
1006 RCS.
|
|
1007
|
|
1008 @cindex locking and version control
|
|
1009 A version control system typically has some mechanism to coordinate
|
|
1010 between users who want to change the same file. One method is
|
|
1011 @dfn{locking} (analogous to the locking that Emacs uses to detect
|
|
1012 simultaneous editing of a file, but distinct from it). The other method
|
|
1013 is to merge your changes with other people's changes when you check them
|
|
1014 in.
|
|
1015
|
|
1016 With version control locking, work files are normally read-only so
|
|
1017 that you cannot change them. You ask the version control system to make
|
|
1018 a work file writable for you by locking it; only one user can do
|
|
1019 this at any given time. When you check in your changes, that unlocks
|
|
1020 the file, making the work file read-only again. This allows other users
|
|
1021 to lock the file to make further changes. SCCS always uses locking, and
|
|
1022 RCS normally does.
|
|
1023
|
|
1024 The other alternative for RCS is to let each user modify the work file
|
|
1025 at any time. In this mode, locking is not required, but it is
|
|
1026 permitted; check-in is still the way to record a new version.
|
|
1027
|
|
1028 CVS normally allows each user to modify his own copy of the work file
|
|
1029 at any time, but requires merging with changes from other users at
|
|
1030 check-in time. However, CVS can also be set up to require locking.
|
|
1031 (@pxref{Backend Options}).
|
|
1032
|
|
1033 @node VC Mode Line
|
|
1034 @subsection Version Control and the Mode Line
|
|
1035
|
|
1036 When you visit a file that is under version control, Emacs indicates
|
|
1037 this on the mode line. For example, @samp{RCS-1.3} says that RCS is
|
|
1038 used for that file, and the current version is 1.3.
|
|
1039
|
|
1040 The character between the back-end name and the version number
|
|
1041 indicates the version control status of the file. @samp{-} means that
|
|
1042 the work file is not locked (if locking is in use), or not modified (if
|
|
1043 locking is not in use). @samp{:} indicates that the file is locked, or
|
|
1044 that it is modified. If the file is locked by some other user (for
|
|
1045 instance, @samp{jim}), that is displayed as @samp{RCS:jim:1.3}.
|
|
1046
|
|
1047 @node Basic VC Editing
|
|
1048 @subsection Basic Editing under Version Control
|
|
1049
|
|
1050 The principal VC command is an all-purpose command that performs
|
|
1051 either locking or check-in, depending on the situation.
|
|
1052
|
|
1053 @table @kbd
|
|
1054 @item C-x C-q
|
|
1055 @itemx C-x v v
|
|
1056 Perform the next logical version control operation on this file.
|
|
1057 @end table
|
|
1058
|
|
1059 @findex vc-next-action
|
|
1060 @findex vc-toggle-read-only
|
|
1061 @kindex C-x v v
|
|
1062 @kindex C-x C-q @r{(Version Control)}
|
|
1063 Strictly speaking, the command for this job is @code{vc-next-action},
|
|
1064 bound to @kbd{C-x v v}. However, the normal meaning of @kbd{C-x C-q} is
|
|
1065 to make a read-only buffer writable, or vice versa; we have extended it
|
|
1066 to do the same job properly for files managed by version control, by
|
|
1067 performing the appropriate version control operations. When you type
|
|
1068 @kbd{C-x C-q} on a registered file, it acts like @kbd{C-x v v}.
|
|
1069
|
|
1070 The precise action of this command depends on the state of the file,
|
|
1071 and whether the version control system uses locking or not. SCCS and
|
|
1072 RCS normally use locking; CVS normally does not use locking.
|
|
1073
|
|
1074 @menu
|
|
1075 * VC with Locking:: RCS in its default mode, SCCS, and optionally CVS.
|
|
1076 * Without Locking:: Without locking: default mode for CVS.
|
|
1077 * Log Buffer:: Features available in log entry buffers.
|
|
1078 @end menu
|
|
1079
|
|
1080 @node VC with Locking
|
|
1081 @subsubsection Basic Version Control with Locking
|
|
1082
|
|
1083 If locking is used for the file (as with SCCS, and RCS in its default
|
|
1084 mode), @kbd{C-x C-q} can either lock a file or check it in:
|
|
1085
|
|
1086 @itemize @bullet
|
|
1087 @item
|
|
1088 If the file is not locked, @kbd{C-x C-q} locks it, and
|
|
1089 makes it writable so that you can change it.
|
|
1090
|
|
1091 @item
|
|
1092 If the file is locked by you, and contains changes, @kbd{C-x C-q} checks
|
|
1093 in the changes. In order to do this, it first reads the log entry
|
|
1094 for the new version. @xref{Log Buffer}.
|
|
1095
|
|
1096 @item
|
|
1097 If the file is locked by you, but you have not changed it since you
|
|
1098 locked it, @kbd{C-x C-q} releases the lock and makes the file read-only
|
|
1099 again.
|
|
1100
|
|
1101 @item
|
|
1102 If the file is locked by some other user, @kbd{C-x C-q} asks you whether
|
|
1103 you want to ``steal the lock'' from that user. If you say yes, the file
|
|
1104 becomes locked by you, but a message is sent to the person who had
|
|
1105 formerly locked the file, to inform him of what has happened.
|
|
1106 @end itemize
|
|
1107
|
|
1108 These rules also apply when you use CVS in locking mode, except
|
|
1109 that there is no such thing as stealing a lock.
|
|
1110
|
|
1111 @node Without Locking
|
|
1112 @subsubsection Basic Version Control without Locking
|
|
1113
|
|
1114 When there is no locking---the default for CVS---work files are always
|
|
1115 writable; you do not need to do anything before you begin to edit a
|
|
1116 file. The status indicator on the mode line is @samp{-} if the file is
|
|
1117 unmodified; it flips to @samp{:} as soon as you save any changes in the
|
|
1118 work file.
|
|
1119
|
|
1120 Here is what @kbd{C-x C-q} does when using CVS:
|
|
1121
|
|
1122 @itemize @bullet
|
|
1123 @item
|
|
1124 If some other user has checked in changes into the master file,
|
|
1125 Emacs asks you whether you want to merge those changes into your own
|
|
1126 work file (@pxref{Merging}). You must do this before you can check in
|
|
1127 your own changes.
|
|
1128
|
|
1129 @item
|
|
1130 If there are no new changes in the master file, but you have made
|
|
1131 modifications in your work file, @kbd{C-x C-q} checks in your changes.
|
|
1132 In order to do this, it first reads the log entry for the new version.
|
|
1133 @xref{Log Buffer}.
|
|
1134
|
|
1135 @item
|
|
1136 If the file is not modified, the @kbd{C-x C-q} does nothing.
|
|
1137 @end itemize
|
|
1138
|
|
1139 These rules also apply when you use RCS in the mode that does not
|
|
1140 require locking, except that automatic merging of changes from the
|
|
1141 master file is not implemented. Unfortunately, this means that nothing
|
|
1142 informs you if another user has checked in changes in the same file
|
|
1143 since you began editing it, and when this happens, his changes will be
|
|
1144 effectively removed when you check in your version (though they will
|
|
1145 remain in the master file, so they will not be entirely lost). You must
|
|
1146 therefore verify the current version is unchanged, before you check in your
|
|
1147 changes. We hope to eliminate this risk and provide automatic merging
|
|
1148 with RCS in a future Emacs version.
|
|
1149
|
|
1150 In addition, locking is possible with RCS even in this mode, although
|
|
1151 it is not required; @kbd{C-x C-q} with an unmodified file locks the
|
|
1152 file, just as it does with RCS in its normal (locking) mode.
|
|
1153
|
|
1154 @node Log Buffer
|
|
1155 @subsubsection Features of the Log Entry Buffer
|
|
1156
|
|
1157 When you check in changes, @kbd{C-x C-q} first reads a log entry. It
|
|
1158 pops up a buffer called @samp{*VC-Log*} for you to enter the log entry.
|
|
1159 When you are finished, type @kbd{C-c C-c} in the @samp{*VC-Log*} buffer.
|
|
1160 That is when check-in really happens.
|
|
1161
|
|
1162 To abort check-in, just @strong{don't} type @kbd{C-c C-c} in that
|
|
1163 buffer. You can switch buffers and do other editing. As long as you
|
|
1164 don't try to check in another file, the entry you were editing remains
|
|
1165 in the @samp{*VC-Log*} buffer, and you can go back to that buffer at any
|
|
1166 time to complete the check-in.
|
|
1167
|
|
1168 If you change several source files for the same reason, it is often
|
|
1169 convenient to specify the same log entry for many of the files. To do
|
|
1170 this, use the history of previous log entries. The commands @kbd{M-n},
|
|
1171 @kbd{M-p}, @kbd{M-s} and @kbd{M-r} for doing this work just like the
|
|
1172 minibuffer history commands (except that these versions are used outside
|
|
1173 the minibuffer).
|
|
1174
|
|
1175 @vindex vc-log-mode-hook
|
|
1176 Each time you check in a file, the log entry buffer is put into VC Log
|
|
1177 mode, which involves running two hooks: @code{text-mode-hook} and
|
|
1178 @code{vc-log-mode-hook}. @xref{Hooks}.
|
|
1179
|
|
1180 @node Old Versions
|
|
1181 @subsection Examining And Comparing Old Versions
|
|
1182
|
|
1183 One of the convenient features of version control is the ability
|
|
1184 to examine any version of a file, or compare two versions.
|
|
1185
|
|
1186 @table @kbd
|
|
1187 @item C-x v ~ @var{version} @key{RET}
|
|
1188 Examine version @var{version} of the visited file, in a buffer of its
|
|
1189 own.
|
|
1190
|
|
1191 @item C-x v =
|
|
1192 Compare the current buffer contents with the latest checked-in version
|
|
1193 of the file.
|
|
1194
|
|
1195 @item C-u C-x v = @var{file} @key{RET} @var{oldvers} @key{RET} @var{newvers} @key{RET}
|
|
1196 Compare the specified two versions of @var{file}.
|
|
1197
|
|
1198 @item C-x v g
|
|
1199 Display the result of the CVS annotate command using colors.
|
|
1200 @end table
|
|
1201
|
|
1202 @findex vc-version-other-window
|
|
1203 @kindex C-x v ~
|
|
1204 To examine an old version in toto, visit the file and then type
|
|
1205 @kbd{C-x v ~ @var{version} @key{RET}} (@code{vc-version-other-window}).
|
|
1206 This puts the text of version @var{version} in a file named
|
|
1207 @file{@var{filename}.~@var{version}~}, and visits it in its own buffer
|
|
1208 in a separate window. (In RCS, you can also select an old version
|
|
1209 and create a branch from it. @xref{Branches}.)
|
|
1210
|
|
1211 @findex vc-diff
|
|
1212 @kindex C-x v =
|
|
1213 But usually it is more convenient to compare two versions of the file,
|
|
1214 with the command @kbd{C-x v =} (@code{vc-diff}). Plain @kbd{C-x v =}
|
|
1215 compares the current buffer contents (saving them in the file if
|
|
1216 necessary) with the last checked-in version of the file. @kbd{C-u C-x v
|
|
1217 =}, with a numeric argument, reads a file name and two version numbers,
|
|
1218 then compares those versions of the specified file.
|
|
1219
|
|
1220 If you supply a directory name instead of the name of a registered
|
|
1221 file, this command compares the two specified versions of all registered
|
|
1222 files in that directory and its subdirectories.
|
|
1223
|
|
1224 You can specify a checked-in version by its number; an empty input
|
|
1225 specifies the current contents of the work file (which may be different
|
|
1226 from all the checked-in versions). You can also specify a snapshot name
|
|
1227 (@pxref{Snapshots}) instead of one or both version numbers.
|
|
1228
|
|
1229 This command works by running the @code{diff} utility, getting the
|
|
1230 options from the variable @code{diff-switches}. It displays the output
|
|
1231 in a special buffer in another window. Unlike the @kbd{M-x diff}
|
|
1232 command, @kbd{C-x v =} does not try to locate the changes in the old and
|
|
1233 new versions. This is because normally one or both versions do not
|
|
1234 exist as files when you compare them; they exist only in the records of
|
|
1235 the master file. @xref{Comparing Files}, for more information about
|
|
1236 @kbd{M-x diff}.
|
|
1237
|
|
1238 @findex vc-annotate
|
|
1239 @kindex C-x v g
|
|
1240 For CVS-controlled files, you can display the result of the CVS
|
|
1241 annotate command, using colors to enhance the visual appearance. Use
|
|
1242 the command @kbd{M-x vc-annotate} to do this. Red means new, blue means
|
|
1243 old, and intermediate colors indicate intermediate ages. A prefix
|
|
1244 argument @var{n} specifies a stretch factor for the time scale; it makes
|
|
1245 each color cover a period @var{n} times as long.
|
|
1246
|
|
1247 @node Secondary VC Commands
|
|
1248 @subsection The Secondary Commands of VC
|
|
1249
|
|
1250 This section explains the secondary commands of VC; those that you might
|
|
1251 use once a day.
|
|
1252
|
|
1253 @menu
|
|
1254 * Registering:: Putting a file under version control.
|
|
1255 * VC Status:: Viewing the VC status of files.
|
|
1256 * VC Undo:: Cancelling changes before or after check-in.
|
|
1257 * VC Dired Mode:: Listing files managed by version control.
|
|
1258 * VC Dired Commands:: Commands to use in a VC Dired buffer.
|
|
1259 @end menu
|
|
1260
|
|
1261 @node Registering
|
|
1262 @subsubsection Registering a File for Version Control
|
|
1263
|
|
1264 @kindex C-x v i
|
|
1265 @findex vc-register
|
|
1266 You can put any file under version control by simply visiting it, and
|
|
1267 then typing @w{@kbd{C-x v i}} (@code{vc-register}).
|
|
1268
|
|
1269 @table @kbd
|
|
1270 @item C-x v i
|
|
1271 Register the visited file for version control.
|
|
1272 @end table
|
|
1273
|
|
1274 @vindex vc-default-back-end
|
|
1275 To register the file, Emacs must choose which version control system
|
|
1276 to use for it. You can specify your choice explicitly by setting
|
|
1277 @code{vc-default-back-end} to @code{RCS}, @code{CVS} or @code{SCCS}.
|
|
1278 Otherwise, if there is a subdirectory named @file{RCS}, @file{SCCS}, or
|
|
1279 @file{CVS}, Emacs uses the corresponding version control system. In the
|
|
1280 absence of any specification, the default choice is RCS if RCS is
|
|
1281 installed, otherwise SCCS.
|
|
1282
|
|
1283 If locking is in use, @kbd{C-x v i} leaves the file unlocked and
|
|
1284 read-only. Type @kbd{C-x C-q} if you wish to start editing it. After
|
|
1285 registering a file with CVS, you must subsequently commit the initial
|
|
1286 version by typing @kbd{C-x C-q}.
|
|
1287
|
|
1288 @vindex vc-default-init-version
|
|
1289 The initial version number for a newly registered file is 1.1, by
|
|
1290 default. You can specify a different default by setting the variable
|
|
1291 @code{vc-default-init-version}, or you can give @kbd{C-x v i} a numeric
|
|
1292 argument; then it reads the initial version number for this particular
|
|
1293 file using the minibuffer.
|
|
1294
|
|
1295 @vindex vc-initial-comment
|
|
1296 If @code{vc-initial-comment} is non-@code{nil}, @kbd{C-x v i} reads an
|
|
1297 initial comment to describe the purpose of this source file. Reading
|
|
1298 the initial comment works like reading a log entry (@pxref{Log Buffer}).
|
|
1299
|
|
1300 @node VC Status
|
|
1301 @subsubsection VC Status Commands
|
|
1302
|
|
1303 @table @kbd
|
|
1304 @item C-x v l
|
|
1305 Display version control state and change history.
|
|
1306 @end table
|
|
1307
|
|
1308 @kindex C-x v l
|
|
1309 @findex vc-print-log
|
|
1310 To view the detailed version control status and history of a file,
|
|
1311 type @kbd{C-x v l} (@code{vc-print-log}). It displays the history of
|
|
1312 changes to the current file, including the text of the log entries. The
|
|
1313 output appears in a separate window.
|
|
1314
|
|
1315 @node VC Undo
|
|
1316 @subsubsection Undoing Version Control Actions
|
|
1317
|
|
1318 @table @kbd
|
|
1319 @item C-x v u
|
|
1320 Revert the buffer and the file to the last checked-in version.
|
|
1321
|
|
1322 @item C-x v c
|
|
1323 Remove the last-entered change from the master for the visited file.
|
|
1324 This undoes your last check-in.
|
|
1325 @end table
|
|
1326
|
|
1327 @kindex C-x v u
|
|
1328 @findex vc-revert-buffer
|
|
1329 If you want to discard your current set of changes and revert to the
|
|
1330 last version checked in, use @kbd{C-x v u} (@code{vc-revert-buffer}).
|
|
1331 This leaves the file unlocked; if locking is in use, you must first lock
|
|
1332 the file again before you change it again. @kbd{C-x v u} requires
|
|
1333 confirmation, unless it sees that you haven't made any changes since the
|
|
1334 last checked-in version.
|
|
1335
|
|
1336 @kbd{C-x v u} is also the command to unlock a file if you lock it and
|
|
1337 then decide not to change it.
|
|
1338
|
|
1339 @kindex C-x v c
|
|
1340 @findex vc-cancel-version
|
|
1341 To cancel a change that you already checked in, use @kbd{C-x v c}
|
|
1342 (@code{vc-cancel-version}). This command discards all record of the
|
|
1343 most recent checked-in version. @kbd{C-x v c} also offers to revert
|
|
1344 your work file and buffer to the previous version (the one that precedes
|
|
1345 the version that is deleted).
|
|
1346
|
|
1347 If you answer @kbd{no}, VC keeps your changes in the buffer, and locks
|
|
1348 the file. The no-revert option is useful when you have checked in a
|
|
1349 change and then discover a trivial error in it; you can cancel the
|
|
1350 erroneous check-in, fix the error, and check the file in again.
|
|
1351
|
|
1352 When @kbd{C-x v c} does not revert the buffer, it unexpands all
|
|
1353 version control headers in the buffer instead (@pxref{Version Headers}).
|
|
1354 This is because the buffer no longer corresponds to any existing
|
|
1355 version. If you check it in again, the check-in process will expand the
|
|
1356 headers properly for the new version number.
|
|
1357
|
|
1358 However, it is impossible to unexpand the RCS @samp{@w{$}Log$} header
|
|
1359 automatically. If you use that header feature, you have to unexpand it
|
|
1360 by hand---by deleting the entry for the version that you just canceled.
|
|
1361
|
|
1362 Be careful when invoking @kbd{C-x v c}, as it is easy to lose a lot of
|
|
1363 work with it. To help you be careful, this command always requires
|
|
1364 confirmation with @kbd{yes}. Note also that this command is disabled
|
|
1365 under CVS, because canceling versions is very dangerous and discouraged
|
|
1366 with CVS.
|
|
1367
|
|
1368 @node VC Dired Mode
|
|
1369 @subsubsection Dired under VC
|
|
1370
|
|
1371 @kindex C-x v d
|
|
1372 @findex vc-directory
|
|
1373 When you are working on a large program, it is often useful to find
|
|
1374 out which files have changed within an entire directory tree, or to view
|
|
1375 the status of all files under version control at once, and to perform
|
|
1376 version control operations on collections of files. You can use the
|
|
1377 command @kbd{C-x v d} (@code{vc-directory}) to make a directory listing
|
|
1378 that includes only files relevant for version control.
|
|
1379
|
|
1380 @vindex vc-dired-terse-display
|
|
1381 @kbd{C-x v d} creates a buffer which uses VC Dired Mode. This looks
|
|
1382 much like an ordinary Dired buffer (@pxref{Dired}); however, normally it
|
|
1383 shows only the noteworthy files (those locked or not up-to-date). This
|
|
1384 is called @dfn{terse display}. If you set the variable
|
|
1385 @code{vc-dired-terse-display} to @code{nil}, then VC Dired shows all
|
|
1386 relevant files---those managed under version control, plus all
|
|
1387 subdirectories (@dfn{full display}). The command @kbd{v t} in a VC
|
|
1388 Dired buffer toggles between terse display and full display (@pxref{VC
|
|
1389 Dired Commands}).
|
|
1390
|
|
1391 @vindex vc-dired-recurse
|
|
1392 By default, VC Dired produces a recursive listing of noteworthy or
|
|
1393 relevant files at or below the given directory. You can change this by
|
|
1394 setting the variable @code{vc-dired-recurse} to @code{nil}; then VC
|
|
1395 Dired shows only the files in the given directory.
|
|
1396
|
|
1397 The line for an individual file shows the version control state in the
|
|
1398 place of the hard link count, owner, group, and size of the file. If
|
|
1399 the file is unmodified, in sync with the master file, the version
|
|
1400 control state shown is blank. Otherwise it consists of text in
|
|
1401 parentheses. Under RCS and SCCS, the name of the user locking the file
|
|
1402 is shown; under CVS, an abbreviated version of the @samp{cvs status}
|
|
1403 output is used. Here is an example using RCS:
|
|
1404
|
|
1405 @smallexample
|
|
1406 @group
|
|
1407 /home/jim/project:
|
|
1408
|
|
1409 -rw-r--r-- (jim) Apr 2 23:39 file1
|
|
1410 -r--r--r-- Apr 5 20:21 file2
|
|
1411 @end group
|
|
1412 @end smallexample
|
|
1413
|
|
1414 @noindent
|
|
1415 The files @samp{file1} and @samp{file2} are under version control,
|
|
1416 @samp{file1} is locked by user jim, and @samp{file2} is unlocked.
|
|
1417
|
|
1418 Here is an example using CVS:
|
|
1419
|
|
1420 @smallexample
|
|
1421 @group
|
|
1422 /home/joe/develop:
|
|
1423
|
|
1424 -rw-r--r-- (modified) Aug 2 1997 file1.c
|
|
1425 -rw-r--r-- Apr 4 20:09 file2.c
|
|
1426 -rw-r--r-- (merge) Sep 13 1996 file3.c
|
|
1427 @end group
|
|
1428 @end smallexample
|
|
1429
|
|
1430 Here @samp{file1.c} is modified with respect to the repository, and
|
|
1431 @samp{file2.c} is not. @samp{file3.c} is modified, but other changes
|
|
1432 have also been checked in to the repository---you need to merge them
|
|
1433 with the work file before you can check it in.
|
|
1434
|
|
1435 @vindex vc-directory-exclusion-list
|
|
1436 When VC Dired displays subdirectories (in the ``full'' display mode),
|
|
1437 it omits some that should never contain any files under version control.
|
|
1438 By default, this includes Version Control subdirectories such as
|
|
1439 @samp{RCS} and @samp{CVS}; you can customize this by setting the
|
|
1440 variable @code{vc-directory-exclusion-list}.
|
|
1441
|
|
1442 You can fine-tune VC Dired's format by typing @kbd{C-u C-x v d}---as in
|
|
1443 ordinary Dired, that allows you to specify additional switches for the
|
|
1444 @samp{ls} command.
|
|
1445
|
|
1446 @node VC Dired Commands
|
|
1447 @subsubsection VC Dired Commands
|
|
1448
|
|
1449 All the usual Dired commands work normally in VC Dired mode, except
|
|
1450 for @kbd{v}, which is redefined as the version control prefix. You can
|
|
1451 invoke VC commands such as @code{vc-diff} and @code{vc-print-log} by
|
|
1452 typing @kbd{v =}, or @kbd{v l}, and so on. Most of these commands apply
|
|
1453 to the file name on the current line.
|
|
1454
|
|
1455 The command @kbd{v v} (@code{vc-next-action}) operates on all the
|
|
1456 marked files, so that you can lock or check in several files at once.
|
|
1457 If it operates on more than one file, it handles each file according to
|
|
1458 its current state; thus, it might lock one file, but check in another
|
|
1459 file. This could be confusing; it is up to you to avoid confusing
|
|
1460 behavior by marking a set of files that are in a similar state.
|
|
1461
|
|
1462 If any files call for check-in, @kbd{v v} reads a single log entry,
|
|
1463 then uses it for all the files being checked in. This is convenient for
|
|
1464 registering or checking in several files at once, as part of the same
|
|
1465 change.
|
|
1466
|
|
1467 @findex vc-dired-toggle-terse-mode
|
|
1468 @findex vc-dired-mark-locked
|
|
1469 You can toggle between terse display (only locked files, or files not
|
|
1470 up-to-date) and full display at any time by typing @kbd{v t}
|
|
1471 @code{vc-dired-toggle-terse-mode}. There is also a special command
|
|
1472 @kbd{* l} (@code{vc-dired-mark-locked}), which marks all files currently
|
|
1473 locked (or, with CVS, all files not up-to-date). Thus, typing @kbd{* l
|
|
1474 t k} is another way to delete from the buffer all files except those
|
|
1475 currently locked.
|
|
1476
|
|
1477 @node Branches
|
|
1478 @subsection Multiple Branches of a File
|
|
1479 @cindex branch (version control)
|
|
1480 @cindex trunk (version control)
|
|
1481
|
|
1482 One use of version control is to maintain multiple ``current''
|
|
1483 versions of a file. For example, you might have different versions of a
|
|
1484 program in which you are gradually adding various unfinished new
|
|
1485 features. Each such independent line of development is called a
|
|
1486 @dfn{branch}. VC allows you to create branches, switch between
|
|
1487 different branches, and merge changes from one branch to another.
|
|
1488 Please note, however, that branches are only supported for RCS at the
|
|
1489 moment.
|
|
1490
|
|
1491 A file's main line of development is usually called the @dfn{trunk}.
|
|
1492 The versions on the trunk are normally numbered 1.1, 1.2, 1.3, etc. At
|
|
1493 any such version, you can start an independent branch. A branch
|
|
1494 starting at version 1.2 would have version number 1.2.1.1, and consecutive
|
|
1495 versions on this branch would have numbers 1.2.1.2, 1.2.1.3, 1.2.1.4,
|
|
1496 and so on. If there is a second branch also starting at version 1.2, it
|
|
1497 would consist of versions 1.2.2.1, 1.2.2.2, 1.2.2.3, etc.
|
|
1498
|
|
1499 @cindex head version
|
|
1500 If you omit the final component of a version number, that is called a
|
|
1501 @dfn{branch number}. It refers to the highest existing version on that
|
|
1502 branch---the @dfn{head version} of that branch. The branches in the
|
|
1503 example above have branch numbers 1.2.1 and 1.2.2.
|
|
1504
|
|
1505 @menu
|
|
1506 * Switching Branches:: How to get to another existing branch.
|
|
1507 * Creating Branches:: How to start a new branch.
|
|
1508 * Merging:: Transferring changes between branches.
|
|
1509 * Multi-User Branching:: Multiple users working at multiple branches
|
|
1510 in parallel.
|
|
1511 @end menu
|
|
1512
|
|
1513 @node Switching Branches
|
|
1514 @subsubsection Switching between Branches
|
|
1515
|
|
1516 To switch between branches, type @kbd{C-u C-x C-q} and specify the
|
|
1517 version number you want to select. This version is then visited
|
|
1518 @emph{unlocked} (write-protected), so you can examine it before locking
|
|
1519 it. Switching branches in this way is allowed only when the file is not
|
|
1520 locked.
|
|
1521
|
|
1522 You can omit the minor version number, thus giving only the branch
|
|
1523 number; this takes you to the head version on the chosen branch. If you
|
|
1524 only type @key{RET}, Emacs goes to the highest version on the trunk.
|
|
1525
|
|
1526 After you have switched to any branch (including the main branch), you
|
|
1527 stay on it for subsequent VC commands, until you explicitly select some
|
|
1528 other branch.
|
|
1529
|
|
1530 @node Creating Branches
|
|
1531 @subsubsection Creating New Branches
|
|
1532
|
|
1533 To create a new branch from a head version (one that is the latest in
|
|
1534 the branch that contains it), first select that version if necessary,
|
|
1535 lock it with @kbd{C-x C-q}, and make whatever changes you want. Then,
|
|
1536 when you check in the changes, use @kbd{C-u C-x C-q}. This lets you
|
|
1537 specify the version number for the new version. You should specify a
|
|
1538 suitable branch number for a branch starting at the current version.
|
|
1539 For example, if the current version is 2.5, the branch number should be
|
|
1540 2.5.1, 2.5.2, and so on, depending on the number of existing branches at
|
|
1541 that point.
|
|
1542
|
|
1543 To create a new branch at an older version (one that is no longer the
|
|
1544 head of a branch), first select that version (@pxref{Switching
|
|
1545 Branches}), then lock it with @kbd{C-x C-q}. You'll be asked to
|
|
1546 confirm, when you lock the old version, that you really mean to create a
|
|
1547 new branch---if you say no, you'll be offered a chance to lock the
|
|
1548 latest version instead.
|
|
1549
|
|
1550 Then make your changes and type @kbd{C-x C-q} again to check in a new
|
|
1551 version. This automatically creates a new branch starting from the
|
|
1552 selected version. You need not specially request a new branch, because
|
|
1553 that's the only way to add a new version at a point that is not the head
|
|
1554 of a branch.
|
|
1555
|
|
1556 After the branch is created, you ``stay'' on it. That means that
|
|
1557 subsequent check-ins create new versions on that branch. To leave the
|
|
1558 branch, you must explicitly select a different version with @kbd{C-u C-x
|
|
1559 C-q}. To transfer changes from one branch to another, use the merge
|
|
1560 command, described in the next section.
|
|
1561
|
|
1562 @node Merging
|
|
1563 @subsubsection Merging Branches
|
|
1564
|
|
1565 @cindex merging changes
|
|
1566 When you have finished the changes on a certain branch, you will
|
|
1567 often want to incorporate them into the file's main line of development
|
|
1568 (the trunk). This is not a trivial operation, because development might
|
|
1569 also have proceeded on the trunk, so that you must @dfn{merge} the
|
|
1570 changes into a file that has already been changed otherwise. VC allows
|
|
1571 you to do this (and other things) with the @code{vc-merge} command.
|
|
1572
|
|
1573 @table @kbd
|
|
1574 @item C-x v m (vc-merge)
|
|
1575 Merge changes into the work file.
|
|
1576 @end table
|
|
1577
|
|
1578 @kindex C-x v m
|
|
1579 @findex vc-merge
|
|
1580 @kbd{C-x v m} (@code{vc-merge}) takes a set of changes and merges it
|
|
1581 into the current version of the work file. It first asks you for a
|
|
1582 branch number or a pair of version numbers in the minibuffer. Then it
|
|
1583 finds the changes from that branch, or between the two versions you
|
|
1584 specified, and merges them into the current version of the current file.
|
|
1585
|
|
1586 As an example, suppose that you have finished a certain feature on
|
|
1587 branch 1.3.1. In the meantime, development on the trunk has proceeded
|
|
1588 to version 1.5. To merge the changes from the branch to the trunk,
|
|
1589 first go to the head version of the trunk, by typing @kbd{C-u C-x C-q
|
|
1590 RET}. Version 1.5 is now current. If locking is used for the file,
|
|
1591 type @kbd{C-x C-q} to lock version 1.5 so that you can change it. Next,
|
|
1592 type @kbd{C-x v m 1.3.1 RET}. This takes the entire set of changes on
|
|
1593 branch 1.3.1 (relative to version 1.3, where the branch started, up to
|
|
1594 the last version on the branch) and merges it into the current version
|
|
1595 of the work file. You can now check in the changed file, thus creating
|
|
1596 version 1.6 containing the changes from the branch.
|
|
1597
|
|
1598 It is possible to do further editing after merging the branch, before
|
|
1599 the next check-in. But it is usually wiser to check in the merged
|
|
1600 version, then lock it and make the further changes. This will keep
|
|
1601 a better record of the history of changes.
|
|
1602
|
|
1603 @cindex conflicts
|
|
1604 @cindex resolving conflicts
|
|
1605 When you merge changes into a file that has itself been modified, the
|
|
1606 changes might overlap. We call this situation a @dfn{conflict}, and
|
|
1607 reconciling the conflicting changes is called @dfn{resolving a
|
|
1608 conflict}.
|
|
1609
|
|
1610 Whenever conflicts occur during merging, VC detects them, tells you
|
|
1611 about them in the echo area, and asks whether you want help in merging.
|
|
1612 If you say yes, it starts an Ediff session (@pxref{Top,
|
|
1613 Ediff, Ediff, ediff, The Ediff Manual}).
|
|
1614
|
|
1615 If you say no, the conflicting changes are both inserted into the
|
|
1616 file, surrounded by @dfn{conflict markers}. The example below shows how
|
|
1617 a conflict region looks; the file is called @samp{name} and the current
|
|
1618 master file version with user B's changes in it is 1.11.
|
|
1619
|
|
1620 @c @w here is so CVS won't think this is a conflict.
|
|
1621 @smallexample
|
|
1622 @group
|
|
1623 @w{<}<<<<<< name
|
|
1624 @var{User A's version}
|
|
1625 =======
|
|
1626 @var{User B's version}
|
|
1627 @w{>}>>>>>> 1.11
|
|
1628 @end group
|
|
1629 @end smallexample
|
|
1630
|
|
1631 @cindex vc-resolve-conflicts
|
|
1632 Then you can resolve the conflicts by editing the file manually. Or
|
|
1633 you can type @code{M-x vc-resolve-conflicts} after visiting the file.
|
|
1634 This starts an Ediff session, as described above.
|
|
1635
|
|
1636 @node Multi-User Branching
|
|
1637 @subsubsection Multi-User Branching
|
|
1638
|
|
1639 It is often useful for multiple developers to work simultaneously on
|
|
1640 different branches of a file. CVS allows this by default; for RCS, it
|
|
1641 is possible if you create multiple source directories. Each source
|
|
1642 directory should have a link named @file{RCS} which points to a common
|
|
1643 directory of RCS master files. Then each source directory can have its
|
|
1644 own choice of selected versions, but all share the same common RCS
|
|
1645 records.
|
|
1646
|
|
1647 This technique works reliably and automatically, provided that the
|
|
1648 source files contain RCS version headers (@pxref{Version Headers}). The
|
|
1649 headers enable Emacs to be sure, at all times, which version number is
|
|
1650 present in the work file.
|
|
1651
|
|
1652 If the files do not have version headers, you must instead tell Emacs
|
|
1653 explicitly in each session which branch you are working on. To do this,
|
|
1654 first find the file, then type @kbd{C-u C-x C-q} and specify the correct
|
|
1655 branch number. This ensures that Emacs knows which branch it is using
|
|
1656 during this particular editing session.
|
|
1657
|
|
1658 @node Snapshots
|
|
1659 @subsection Snapshots
|
|
1660 @cindex snapshots and version control
|
|
1661
|
|
1662 A @dfn{snapshot} is a named set of file versions (one for each
|
|
1663 registered file) that you can treat as a unit. One important kind of
|
|
1664 snapshot is a @dfn{release}, a (theoretically) stable version of the
|
|
1665 system that is ready for distribution to users.
|
|
1666
|
|
1667 @menu
|
|
1668 * Making Snapshots:: The snapshot facilities.
|
|
1669 * Snapshot Caveats:: Things to be careful of when using snapshots.
|
|
1670 @end menu
|
|
1671
|
|
1672 @node Making Snapshots
|
|
1673 @subsubsection Making and Using Snapshots
|
|
1674
|
|
1675 There are two basic commands for snapshots; one makes a
|
|
1676 snapshot with a given name, the other retrieves a named snapshot.
|
|
1677
|
|
1678 @table @code
|
|
1679 @kindex C-x v s
|
|
1680 @findex vc-create-snapshot
|
|
1681 @item C-x v s @var{name} @key{RET}
|
|
1682 Define the last saved versions of every registered file in or under the
|
|
1683 current directory as a snapshot named @var{name}
|
|
1684 (@code{vc-create-snapshot}).
|
|
1685
|
|
1686 @kindex C-x v r
|
|
1687 @findex vc-retrieve-snapshot
|
|
1688 @item C-x v r @var{name} @key{RET}
|
|
1689 For all registered files at or below the current directory level, select
|
|
1690 whatever versions correspond to the snapshot @var{name}
|
|
1691 (@code{vc-retrieve-snapshot}).
|
|
1692
|
|
1693 This command reports an error if any files are locked at or below the
|
|
1694 current directory, without changing anything; this is to avoid
|
|
1695 overwriting work in progress.
|
|
1696 @end table
|
|
1697
|
|
1698 A snapshot uses a very small amount of resources---just enough to record
|
|
1699 the list of file names and which version belongs to the snapshot. Thus,
|
|
1700 you need not hesitate to create snapshots whenever they are useful.
|
|
1701
|
|
1702 You can give a snapshot name as an argument to @kbd{C-x v =} or
|
|
1703 @kbd{C-x v ~} (@pxref{Old Versions}). Thus, you can use it to compare a
|
|
1704 snapshot against the current files, or two snapshots against each other,
|
|
1705 or a snapshot against a named version.
|
|
1706
|
|
1707 @node Snapshot Caveats
|
|
1708 @subsubsection Snapshot Caveats
|
|
1709
|
|
1710 @cindex named configurations (RCS)
|
|
1711 VC's snapshot facilities are modeled on RCS's named-configuration
|
|
1712 support. They use RCS's native facilities for this, so under VC
|
|
1713 snapshots made using RCS are visible even when you bypass VC.
|
|
1714
|
|
1715 @c worded verbosely to avoid overfull hbox.
|
|
1716 For SCCS, VC implements snapshots itself. The files it uses contain
|
|
1717 name/file/version-number triples. These snapshots are visible only
|
|
1718 through VC.
|
|
1719
|
|
1720 A snapshot is a set of checked-in versions. So make sure that all the
|
|
1721 files are checked in and not locked when you make a snapshot.
|
|
1722
|
|
1723 File renaming and deletion can create some difficulties with snapshots.
|
|
1724 This is not a VC-specific problem, but a general design issue in version
|
|
1725 control systems that no one has solved very well yet.
|
|
1726
|
|
1727 If you rename a registered file, you need to rename its master along
|
|
1728 with it (the command @code{vc-rename-file} does this automatically). If
|
|
1729 you are using SCCS, you must also update the records of the snapshot, to
|
|
1730 mention the file by its new name (@code{vc-rename-file} does this,
|
|
1731 too). An old snapshot that refers to a master file that no longer
|
|
1732 exists under the recorded name is invalid; VC can no longer retrieve
|
|
1733 it. It would be beyond the scope of this manual to explain enough about
|
|
1734 RCS and SCCS to explain how to update the snapshots by hand.
|
|
1735
|
|
1736 Using @code{vc-rename-file} makes the snapshot remain valid for
|
|
1737 retrieval, but it does not solve all problems. For example, some of the
|
|
1738 files in the program probably refer to others by name. At the very
|
|
1739 least, the makefile probably mentions the file that you renamed. If you
|
|
1740 retrieve an old snapshot, the renamed file is retrieved under its new
|
|
1741 name, which is not the name that the makefile expects. So the program
|
|
1742 won't really work as retrieved.
|
|
1743
|
|
1744 @node Miscellaneous VC
|
|
1745 @subsection Miscellaneous Commands and Features of VC
|
|
1746
|
|
1747 This section explains the less-frequently-used features of VC.
|
|
1748
|
|
1749 @menu
|
|
1750 * Change Logs and VC:: Generating a change log file from log entries.
|
|
1751 * Renaming and VC:: A command to rename both the source and master
|
|
1752 file correctly.
|
|
1753 * Version Headers:: Inserting version control headers into working files.
|
|
1754 @end menu
|
|
1755
|
|
1756 @node Change Logs and VC
|
|
1757 @subsubsection Change Logs and VC
|
|
1758
|
|
1759 If you use RCS or CVS for a program and also maintain a change log
|
|
1760 file for it (@pxref{Change Log}), you can generate change log entries
|
|
1761 automatically from the version control log entries:
|
|
1762
|
|
1763 @table @kbd
|
|
1764 @item C-x v a
|
|
1765 @kindex C-x v a
|
|
1766 @findex vc-update-change-log
|
|
1767 Visit the current directory's change log file and, for registered files
|
|
1768 in that directory, create new entries for versions checked in since the
|
|
1769 most recent entry in the change log file.
|
|
1770 (@code{vc-update-change-log}).
|
|
1771
|
|
1772 This command works with RCS or CVS only, not with SCCS.
|
|
1773
|
|
1774 @item C-u C-x v a
|
|
1775 As above, but only find entries for the current buffer's file.
|
|
1776
|
|
1777 @item M-1 C-x v a
|
|
1778 As above, but find entries for all the currently visited files that are
|
|
1779 maintained with version control. This works only with RCS, and it puts
|
|
1780 all entries in the log for the default directory, which may not be
|
|
1781 appropriate.
|
|
1782 @end table
|
|
1783
|
|
1784 For example, suppose the first line of @file{ChangeLog} is dated
|
|
1785 1999-04-10, and that the only check-in since then was by Nathaniel
|
|
1786 Bowditch to @file{rcs2log} on 1999-05-22 with log text @samp{Ignore log
|
|
1787 messages that start with `#'.}. Then @kbd{C-x v a} visits
|
|
1788 @file{ChangeLog} and inserts text like this:
|
|
1789
|
|
1790 @iftex
|
|
1791 @medbreak
|
|
1792 @end iftex
|
|
1793 @smallexample
|
|
1794 @group
|
|
1795 1999-05-22 Nathaniel Bowditch <nat@@apn.org>
|
|
1796
|
|
1797 * rcs2log: Ignore log messages that start with `#'.
|
|
1798 @end group
|
|
1799 @end smallexample
|
|
1800 @iftex
|
|
1801 @medbreak
|
|
1802 @end iftex
|
|
1803
|
|
1804 @noindent
|
|
1805 You can then edit the new change log entry further as you wish.
|
|
1806
|
|
1807 Unfortunately, timestamps in ChangeLog files are only dates, so some
|
|
1808 of the new change log entry may duplicate what's already in ChangeLog.
|
|
1809 You will have to remove these duplicates by hand.
|
|
1810
|
|
1811 Normally, the log entry for file @file{foo} is displayed as @samp{*
|
|
1812 foo: @var{text of log entry}}. The @samp{:} after @file{foo} is omitted
|
|
1813 if the text of the log entry starts with @w{@samp{(@var{functionname}):
|
|
1814 }}. For example, if the log entry for @file{vc.el} is
|
|
1815 @samp{(vc-do-command): Check call-process status.}, then the text in
|
|
1816 @file{ChangeLog} looks like this:
|
|
1817
|
|
1818 @iftex
|
|
1819 @medbreak
|
|
1820 @end iftex
|
|
1821 @smallexample
|
|
1822 @group
|
|
1823 1999-05-06 Nathaniel Bowditch <nat@@apn.org>
|
|
1824
|
|
1825 * vc.el (vc-do-command): Check call-process status.
|
|
1826 @end group
|
|
1827 @end smallexample
|
|
1828 @iftex
|
|
1829 @medbreak
|
|
1830 @end iftex
|
|
1831
|
|
1832 When @kbd{C-x v a} adds several change log entries at once, it groups
|
|
1833 related log entries together if they all are checked in by the same
|
|
1834 author at nearly the same time. If the log entries for several such
|
|
1835 files all have the same text, it coalesces them into a single entry.
|
|
1836 For example, suppose the most recent check-ins have the following log
|
|
1837 entries:
|
|
1838
|
|
1839 @flushleft
|
|
1840 @bullet{} For @file{vc.texinfo}: @samp{Fix expansion typos.}
|
|
1841 @bullet{} For @file{vc.el}: @samp{Don't call expand-file-name.}
|
|
1842 @bullet{} For @file{vc-hooks.el}: @samp{Don't call expand-file-name.}
|
|
1843 @end flushleft
|
|
1844
|
|
1845 @noindent
|
|
1846 They appear like this in @file{ChangeLog}:
|
|
1847
|
|
1848 @iftex
|
|
1849 @medbreak
|
|
1850 @end iftex
|
|
1851 @smallexample
|
|
1852 @group
|
|
1853 1999-04-01 Nathaniel Bowditch <nat@@apn.org>
|
|
1854
|
|
1855 * vc.texinfo: Fix expansion typos.
|
|
1856
|
|
1857 * vc.el, vc-hooks.el: Don't call expand-file-name.
|
|
1858 @end group
|
|
1859 @end smallexample
|
|
1860 @iftex
|
|
1861 @medbreak
|
|
1862 @end iftex
|
|
1863
|
|
1864 Normally, @kbd{C-x v a} separates log entries by a blank line, but you
|
|
1865 can mark several related log entries to be clumped together (without an
|
|
1866 intervening blank line) by starting the text of each related log entry
|
|
1867 with a label of the form @w{@samp{@{@var{clumpname}@} }}. The label
|
|
1868 itself is not copied to @file{ChangeLog}. For example, suppose the log
|
|
1869 entries are:
|
|
1870
|
|
1871 @flushleft
|
|
1872 @bullet{} For @file{vc.texinfo}: @samp{@{expand@} Fix expansion typos.}
|
|
1873 @bullet{} For @file{vc.el}: @samp{@{expand@} Don't call expand-file-name.}
|
|
1874 @bullet{} For @file{vc-hooks.el}: @samp{@{expand@} Don't call expand-file-name.}
|
|
1875 @end flushleft
|
|
1876
|
|
1877 @noindent
|
|
1878 Then the text in @file{ChangeLog} looks like this:
|
|
1879
|
|
1880 @iftex
|
|
1881 @medbreak
|
|
1882 @end iftex
|
|
1883 @smallexample
|
|
1884 @group
|
|
1885 1999-04-01 Nathaniel Bowditch <nat@@apn.org>
|
|
1886
|
|
1887 * vc.texinfo: Fix expansion typos.
|
|
1888 * vc.el, vc-hooks.el: Don't call expand-file-name.
|
|
1889 @end group
|
|
1890 @end smallexample
|
|
1891 @iftex
|
|
1892 @medbreak
|
|
1893 @end iftex
|
|
1894
|
|
1895 A log entry whose text begins with @samp{#} is not copied to
|
|
1896 @file{ChangeLog}. For example, if you merely fix some misspellings in
|
|
1897 comments, you can log the change with an entry beginning with @samp{#}
|
|
1898 to avoid putting such trivia into @file{ChangeLog}.
|
|
1899
|
|
1900 @node Renaming and VC
|
|
1901 @subsubsection Renaming VC Work Files and Master Files
|
|
1902
|
|
1903 @findex vc-rename-file
|
|
1904 When you rename a registered file, you must also rename its master
|
|
1905 file correspondingly to get proper results. Use @code{vc-rename-file}
|
|
1906 to rename the source file as you specify, and rename its master file
|
|
1907 accordingly. It also updates any snapshots (@pxref{Snapshots}) that
|
|
1908 mention the file, so that they use the new name; despite this, the
|
|
1909 snapshot thus modified may not completely work (@pxref{Snapshot
|
|
1910 Caveats}).
|
|
1911
|
|
1912 You cannot use @code{vc-rename-file} on a file that is locked by
|
|
1913 someone else.
|
|
1914
|
|
1915 @node Version Headers
|
|
1916 @subsubsection Inserting Version Control Headers
|
|
1917
|
|
1918 Sometimes it is convenient to put version identification strings
|
|
1919 directly into working files. Certain special strings called
|
|
1920 @dfn{version headers} are replaced in each successive version by the
|
|
1921 number of that version.
|
|
1922
|
|
1923 If you are using RCS, and version headers are present in your working
|
|
1924 files, Emacs can use them to determine the current version and the
|
|
1925 locking state of the files. This is more reliable than referring to the
|
|
1926 master files, which is done when there are no version headers. Note
|
|
1927 that in a multi-branch environment, version headers are necessary to
|
|
1928 make VC behave correctly (@pxref{Multi-User Branching}).
|
|
1929
|
|
1930 Searching for version headers is controlled by the variable
|
|
1931 @code{vc-consult-headers}. If it is non-@code{nil}, Emacs searches for
|
|
1932 headers to determine the version number you are editing. Setting it to
|
|
1933 @code{nil} disables this feature.
|
|
1934
|
|
1935 @kindex C-x v h
|
|
1936 @findex vc-insert-headers
|
|
1937 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to
|
|
1938 insert a suitable header string.
|
|
1939
|
|
1940 @table @kbd
|
|
1941 @item C-x v h
|
|
1942 Insert headers in a file for use with your version-control system.
|
|
1943 @end table
|
|
1944
|
|
1945 @vindex vc-header-alist
|
|
1946 The default header string is @samp{@w{$}Id$} for RCS and
|
|
1947 @samp{@w{%}W%} for SCCS. You can specify other headers to insert by
|
|
1948 setting the variable @code{vc-header-alist}. Its value is a list of
|
|
1949 elements of the form @code{(@var{program} . @var{string})} where
|
|
1950 @var{program} is @code{RCS} or @code{SCCS} and @var{string} is the
|
|
1951 string to use.
|
|
1952
|
|
1953 Instead of a single string, you can specify a list of strings; then
|
|
1954 each string in the list is inserted as a separate header on a line of
|
|
1955 its own.
|
|
1956
|
|
1957 It is often necessary to use ``superfluous'' backslashes when writing
|
|
1958 the strings that you put in this variable. This is to prevent the
|
|
1959 string in the constant from being interpreted as a header itself if the
|
|
1960 Emacs Lisp file containing it is maintained with version control.
|
|
1961
|
|
1962 @vindex vc-comment-alist
|
|
1963 Each header is inserted surrounded by tabs, inside comment delimiters,
|
|
1964 on a new line at point. Normally the ordinary comment
|
|
1965 start and comment end strings of the current mode are used, but for
|
|
1966 certain modes, there are special comment delimiters for this purpose;
|
|
1967 the variable @code{vc-comment-alist} specifies them. Each element of
|
|
1968 this list has the form @code{(@var{mode} @var{starter} @var{ender})}.
|
|
1969
|
|
1970 @vindex vc-static-header-alist
|
|
1971 The variable @code{vc-static-header-alist} specifies further strings
|
|
1972 to add based on the name of the buffer. Its value should be a list of
|
|
1973 elements of the form @code{(@var{regexp} . @var{format})}. Whenever
|
|
1974 @var{regexp} matches the buffer name, @var{format} is inserted as part
|
|
1975 of the header. A header line is inserted for each element that matches
|
|
1976 the buffer name, and for each string specified by
|
|
1977 @code{vc-header-alist}. The header line is made by processing the
|
|
1978 string from @code{vc-header-alist} with the format taken from the
|
|
1979 element. The default value for @code{vc-static-header-alist} is as follows:
|
|
1980
|
|
1981 @example
|
|
1982 @group
|
|
1983 (("\\.c$" .
|
|
1984 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
|
|
1985 #endif /* lint */\n"))
|
|
1986 @end group
|
|
1987 @end example
|
|
1988
|
|
1989 @noindent
|
|
1990 It specifies insertion of text of this form:
|
|
1991
|
|
1992 @example
|
|
1993 @group
|
|
1994
|
|
1995 #ifndef lint
|
|
1996 static char vcid[] = "@var{string}";
|
|
1997 #endif /* lint */
|
|
1998 @end group
|
|
1999 @end example
|
|
2000
|
|
2001 @noindent
|
|
2002 Note that the text above starts with a blank line.
|
|
2003
|
|
2004 If you use more than one version header in a file, put them close
|
|
2005 together in the file. The mechanism in @code{revert-buffer} that
|
|
2006 preserves markers may not handle markers positioned between two version
|
|
2007 headers.
|
|
2008
|
|
2009 @node Customizing VC
|
|
2010 @subsection Customizing VC
|
|
2011
|
|
2012 There are many ways of customizing VC. The options you can set fall
|
|
2013 into four categories, described in the following sections.
|
|
2014
|
|
2015 @menu
|
|
2016 * Backend Options:: Customizing the back-end to your needs.
|
|
2017 * VC Workfile Handling:: Various options concerning working files.
|
|
2018 * VC Status Retrieval:: How VC finds the version control status of a file,
|
|
2019 and how to customize this.
|
|
2020 * VC Command Execution:: Which commands VC should run, and how.
|
|
2021 @end menu
|
|
2022
|
|
2023 @node Backend Options
|
|
2024 @subsubsection Options for VC Backends
|
|
2025
|
|
2026 @cindex backend options (VC)
|
|
2027 @cindex locking under version control
|
|
2028 You can tell RCS and CVS whether to use locking for a file or not
|
|
2029 (@pxref{VC Concepts}, for a description of locking). VC automatically
|
|
2030 recognizes what you have chosen, and behaves accordingly.
|
|
2031
|
|
2032 @cindex non-strict locking (RCS)
|
|
2033 @cindex locking, non-strict (RCS)
|
|
2034 For RCS, the default is to use locking, but there is a mode called
|
|
2035 @dfn{non-strict locking} in which you can check-in changes without
|
|
2036 locking the file first. Use @samp{rcs -U} to switch to non-strict
|
|
2037 locking for a particular file, see the @samp{rcs} manpage for details.
|
|
2038
|
|
2039 @cindex locking (CVS)
|
|
2040 Under CVS, the default is not to use locking; anyone can change a work
|
|
2041 file at any time. However, there are ways to restrict this, resulting
|
|
2042 in behavior that resembles locking.
|
|
2043
|
|
2044 @cindex CVSREAD environment variable (CVS)
|
|
2045 For one thing, you can set the @code{CVSREAD} environment variable to
|
|
2046 an arbitrary value. If this variable is defined, CVS makes your work
|
|
2047 files read-only by default. In Emacs, you must type @kbd{C-x C-q} to
|
|
2048 make the file writeable, so that editing works in fact similar as if
|
|
2049 locking was used. Note however, that no actual locking is performed, so
|
|
2050 several users can make their files writeable at the same time. When
|
|
2051 setting @code{CVSREAD} for the first time, make sure to check out all
|
|
2052 your modules anew, so that the file protections are set correctly.
|
|
2053
|
|
2054 @cindex cvs watch feature
|
|
2055 @cindex watching files (CVS)
|
|
2056 Another way to achieve something similar to locking is to use the
|
|
2057 @dfn{watch} feature of CVS. If a file is being watched, CVS makes it
|
|
2058 read-only by default, and you must also use @kbd{C-x C-q} in Emacs to
|
|
2059 make it writable. VC calls @code{cvs edit} to make the file writeable,
|
|
2060 and CVS takes care to notify other developers of the fact that you
|
|
2061 intend to change the file. See the CVS documentation for details on
|
|
2062 using the watch feature.
|
|
2063
|
|
2064 @vindex vc-handle-cvs
|
|
2065 You can turn off use of VC for CVS-managed files by setting the
|
|
2066 variable @code{vc-handle-cvs} to @code{nil}. If you do this, Emacs
|
|
2067 treats these files as if they were not registered, and the VC commands
|
|
2068 are not available for them. You must do all CVS operations manually.
|
|
2069
|
|
2070 @node VC Workfile Handling
|
|
2071 @subsubsection VC Workfile Handling
|
|
2072
|
|
2073 @vindex vc-make-backup-files
|
|
2074 Emacs normally does not save backup files for source files that are
|
|
2075 maintained with version control. If you want to make backup files even
|
|
2076 for files that use version control, set the variable
|
|
2077 @code{vc-make-backup-files} to a non-@code{nil} value.
|
|
2078
|
|
2079 @vindex vc-keep-workfiles
|
|
2080 Normally the work file exists all the time, whether it is locked or
|
|
2081 not. If you set @code{vc-keep-workfiles} to @code{nil}, then checking
|
|
2082 in a new version with @kbd{C-x C-q} deletes the work file; but any
|
|
2083 attempt to visit the file with Emacs creates it again. (With CVS, work
|
|
2084 files are always kept.)
|
|
2085
|
|
2086 @vindex vc-follow-symlinks
|
|
2087 Editing a version-controlled file through a symbolic link can be
|
|
2088 dangerous. It bypasses the version control system---you can edit the
|
|
2089 file without locking it, and fail to check your changes in. Also,
|
|
2090 your changes might overwrite those of another user. To protect against
|
|
2091 this, VC checks each symbolic link that you visit, to see if it points
|
|
2092 to a file under version control.
|
|
2093
|
|
2094 The variable @code{vc-follow-symlinks} controls what to do when a
|
|
2095 symbolic link points to a version-controlled file. If it is @code{nil},
|
|
2096 VC only displays a warning message. If it is @code{t}, VC automatically
|
|
2097 follows the link, and visits the real file instead, telling you about
|
|
2098 this in the echo area. If the value is @code{ask} (the default), VC
|
|
2099 asks you each time whether to follow the link.
|
|
2100
|
|
2101 @node VC Status Retrieval
|
|
2102 @subsubsection VC Status Retrieval
|
|
2103 @c There is no need to tell users about vc-master-templates.
|
|
2104
|
|
2105 When deducing the locked/unlocked state of a file, VC first looks for
|
|
2106 an RCS version header string in the file (@pxref{Version Headers}). If
|
|
2107 there is no header string, or if you are using SCCS, VC normally looks
|
|
2108 at the file permissions of the work file; this is fast. But there might
|
|
2109 be situations when the file permissions cannot be trusted. In this case
|
|
2110 the master file has to be consulted, which is rather expensive. Also
|
|
2111 the master file can only tell you @emph{if} there's any lock on the
|
|
2112 file, but not whether your work file really contains that locked
|
|
2113 version.
|
|
2114
|
|
2115 @vindex vc-consult-headers
|
|
2116 You can tell VC not to use version headers to determine lock status by
|
|
2117 setting @code{vc-consult-headers} to @code{nil}. VC then always uses
|
|
2118 the file permissions (if it can trust them), or else checks the master
|
|
2119 file.
|
|
2120
|
|
2121 @vindex vc-mistrust-permissions
|
|
2122 You can specify the criterion for whether to trust the file
|
|
2123 permissions by setting the variable @code{vc-mistrust-permissions}. Its
|
|
2124 value can be @code{t} (always mistrust the file permissions and check
|
|
2125 the master file), @code{nil} (always trust the file permissions), or a
|
|
2126 function of one argument which makes the decision. The argument is the
|
|
2127 directory name of the @file{RCS}, @file{CVS} or @file{SCCS}
|
|
2128 subdirectory. A non-@code{nil} value from the function says to mistrust
|
|
2129 the file permissions. If you find that the file permissions of work
|
|
2130 files are changed erroneously, set @code{vc-mistrust-permissions} to
|
|
2131 @code{t}. Then VC always checks the master file to determine the file's
|
|
2132 status.
|
|
2133
|
|
2134 @node VC Command Execution
|
|
2135 @subsubsection VC Command Execution
|
|
2136
|
|
2137 @vindex vc-suppress-confirm
|
|
2138 If @code{vc-suppress-confirm} is non-@code{nil}, then @kbd{C-x C-q}
|
|
2139 and @kbd{C-x v i} can save the current buffer without asking, and
|
|
2140 @kbd{C-x v u} also operates without asking for confirmation. (This
|
|
2141 variable does not affect @kbd{C-x v c}; that operation is so drastic
|
|
2142 that it should always ask for confirmation.)
|
|
2143
|
|
2144 @vindex vc-command-messages
|
|
2145 VC mode does much of its work by running the shell commands for RCS,
|
|
2146 CVS and SCCS. If @code{vc-command-messages} is non-@code{nil}, VC
|
|
2147 displays messages to indicate which shell commands it runs, and
|
|
2148 additional messages when the commands finish.
|
|
2149
|
|
2150 @vindex vc-path
|
|
2151 You can specify additional directories to search for version control
|
|
2152 programs by setting the variable @code{vc-path}. These directories are
|
|
2153 searched before the usual search path. But the proper files are usually
|
|
2154 found automatically.
|
|
2155
|
|
2156 @node Directories
|
|
2157 @section File Directories
|
|
2158
|
|
2159 @cindex file directory
|
|
2160 @cindex directory listing
|
|
2161 The file system groups files into @dfn{directories}. A @dfn{directory
|
|
2162 listing} is a list of all the files in a directory. Emacs provides
|
|
2163 commands to create and delete directories, and to make directory
|
|
2164 listings in brief format (file names only) and verbose format (sizes,
|
|
2165 dates, and authors included). There is also a directory browser called
|
|
2166 Dired; see @ref{Dired}.
|
|
2167
|
|
2168 @table @kbd
|
|
2169 @item C-x C-d @var{dir-or-pattern} @key{RET}
|
|
2170 Display a brief directory listing (@code{list-directory}).
|
|
2171 @item C-u C-x C-d @var{dir-or-pattern} @key{RET}
|
|
2172 Display a verbose directory listing.
|
|
2173 @item M-x make-directory @key{RET} @var{dirname} @key{RET}
|
|
2174 Create a new directory named @var{dirname}.
|
|
2175 @item M-x delete-directory @key{RET} @var{dirname} @key{RET}
|
|
2176 Delete the directory named @var{dirname}. It must be empty,
|
|
2177 or you get an error.
|
|
2178 @end table
|
|
2179
|
|
2180 @findex list-directory
|
|
2181 @kindex C-x C-d
|
|
2182 The command to display a directory listing is @kbd{C-x C-d}
|
|
2183 (@code{list-directory}). It reads using the minibuffer a file name
|
|
2184 which is either a directory to be listed or a wildcard-containing
|
|
2185 pattern for the files to be listed. For example,
|
|
2186
|
|
2187 @example
|
|
2188 C-x C-d /u2/emacs/etc @key{RET}
|
|
2189 @end example
|
|
2190
|
|
2191 @noindent
|
|
2192 lists all the files in directory @file{/u2/emacs/etc}. Here is an
|
|
2193 example of specifying a file name pattern:
|
|
2194
|
|
2195 @example
|
|
2196 C-x C-d /u2/emacs/src/*.c @key{RET}
|
|
2197 @end example
|
|
2198
|
|
2199 Normally, @kbd{C-x C-d} prints a brief directory listing containing
|
|
2200 just file names. A numeric argument (regardless of value) tells it to
|
|
2201 make a verbose listing including sizes, dates, and authors (like
|
|
2202 @samp{ls -l}).
|
|
2203
|
|
2204 @vindex list-directory-brief-switches
|
|
2205 @vindex list-directory-verbose-switches
|
|
2206 The text of a directory listing is obtained by running @code{ls} in an
|
|
2207 inferior process. Two Emacs variables control the switches passed to
|
|
2208 @code{ls}: @code{list-directory-brief-switches} is a string giving the
|
|
2209 switches to use in brief listings (@code{"-CF"} by default), and
|
|
2210 @code{list-directory-verbose-switches} is a string giving the switches to
|
|
2211 use in a verbose listing (@code{"-l"} by default).
|
|
2212
|
|
2213 @node Comparing Files
|
|
2214 @section Comparing Files
|
|
2215 @cindex comparing files
|
|
2216
|
|
2217 @findex diff
|
|
2218 @vindex diff-switches
|
|
2219 The command @kbd{M-x diff} compares two files, displaying the
|
|
2220 differences in an Emacs buffer named @samp{*Diff*}. It works by running
|
|
2221 the @code{diff} program, using options taken from the variable
|
|
2222 @code{diff-switches}, whose value should be a string.
|
|
2223
|
|
2224 The buffer @samp{*Diff*} has Compilation mode as its major mode, so
|
|
2225 you can use @kbd{C-x `} to visit successive changed locations in the two
|
|
2226 source files. You can also move to a particular hunk of changes and
|
|
2227 type @key{RET} or @kbd{C-c C-c}, or click @kbd{Mouse-2} on it, to move
|
|
2228 to the corresponding source location. You can also use the other
|
|
2229 special commands of Compilation mode: @key{SPC} and @key{DEL} for
|
|
2230 scrolling, and @kbd{M-p} and @kbd{M-n} for cursor motion.
|
|
2231 @xref{Compilation}.
|
|
2232
|
|
2233 @findex diff-backup
|
|
2234 The command @kbd{M-x diff-backup} compares a specified file with its most
|
|
2235 recent backup. If you specify the name of a backup file,
|
|
2236 @code{diff-backup} compares it with the source file that it is a backup
|
|
2237 of.
|
|
2238
|
|
2239 @findex compare-windows
|
|
2240 The command @kbd{M-x compare-windows} compares the text in the current
|
|
2241 window with that in the next window. Comparison starts at point in each
|
|
2242 window, and each starting position is pushed on the mark ring in its
|
|
2243 respective buffer. Then point moves forward in each window, a character
|
|
2244 at a time, until a mismatch between the two windows is reached. Then
|
|
2245 the command is finished. For more information about windows in Emacs,
|
|
2246 @ref{Windows}.
|
|
2247
|
|
2248 @vindex compare-ignore-case
|
|
2249 With a numeric argument, @code{compare-windows} ignores changes in
|
|
2250 whitespace. If the variable @code{compare-ignore-case} is
|
|
2251 non-@code{nil}, it ignores differences in case as well.
|
|
2252
|
|
2253 See also @ref{Emerge}, for convenient facilities for merging two
|
|
2254 similar files.
|
|
2255
|
|
2256 @node Misc File Ops
|
|
2257 @section Miscellaneous File Operations
|
|
2258
|
|
2259 Emacs has commands for performing many other operations on files.
|
|
2260 All operate on one file; they do not accept wildcard file names.
|
|
2261
|
|
2262 @findex view-file
|
|
2263 @cindex viewing
|
|
2264 @cindex View mode
|
|
2265 @cindex mode, View
|
|
2266 @kbd{M-x view-file} allows you to scan or read a file by sequential
|
|
2267 screenfuls. It reads a file name argument using the minibuffer. After
|
|
2268 reading the file into an Emacs buffer, @code{view-file} displays the
|
|
2269 beginning. You can then type @key{SPC} to scroll forward one windowful,
|
|
2270 or @key{DEL} to scroll backward. Various other commands are provided
|
|
2271 for moving around in the file, but none for changing it; type @kbd{?}
|
|
2272 while viewing for a list of them. They are mostly the same as normal
|
|
2273 Emacs cursor motion commands. To exit from viewing, type @kbd{q}.
|
|
2274 The commands for viewing are defined by a special major mode called View
|
|
2275 mode.
|
|
2276
|
|
2277 A related command, @kbd{M-x view-buffer}, views a buffer already present
|
|
2278 in Emacs. @xref{Misc Buffer}.
|
|
2279
|
|
2280 @findex insert-file
|
|
2281 @kbd{M-x insert-file} inserts a copy of the contents of the specified
|
|
2282 file into the current buffer at point, leaving point unchanged before the
|
|
2283 contents and the mark after them.
|
|
2284
|
|
2285 @findex write-region
|
|
2286 @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
|
|
2287 copies the contents of the region into the specified file. @kbd{M-x
|
|
2288 append-to-file} adds the text of the region to the end of the specified
|
|
2289 file. @xref{Accumulating Text}.
|
|
2290
|
|
2291 @findex delete-file
|
|
2292 @cindex deletion (of files)
|
|
2293 @kbd{M-x delete-file} deletes the specified file, like the @code{rm}
|
|
2294 command in the shell. If you are deleting many files in one directory, it
|
|
2295 may be more convenient to use Dired (@pxref{Dired}).
|
|
2296
|
|
2297 @findex rename-file
|
|
2298 @kbd{M-x rename-file} reads two file names @var{old} and @var{new} using
|
|
2299 the minibuffer, then renames file @var{old} as @var{new}. If a file named
|
|
2300 @var{new} already exists, you must confirm with @kbd{yes} or renaming is not
|
|
2301 done; this is because renaming causes the old meaning of the name @var{new}
|
|
2302 to be lost. If @var{old} and @var{new} are on different file systems, the
|
|
2303 file @var{old} is copied and deleted.
|
|
2304
|
|
2305 @findex add-name-to-file
|
|
2306 The similar command @kbd{M-x add-name-to-file} is used to add an
|
|
2307 additional name to an existing file without removing its old name.
|
|
2308 The new name must belong on the same file system that the file is on.
|
|
2309
|
|
2310 @findex copy-file
|
|
2311 @cindex copying files
|
|
2312 @kbd{M-x copy-file} reads the file @var{old} and writes a new file named
|
|
2313 @var{new} with the same contents. Confirmation is required if a file named
|
|
2314 @var{new} already exists, because copying has the consequence of overwriting
|
|
2315 the old contents of the file @var{new}.
|
|
2316
|
|
2317 @findex make-symbolic-link
|
|
2318 @kbd{M-x make-symbolic-link} reads two file names @var{target} and
|
|
2319 @var{linkname}, then creates a symbolic link named @var{linkname} and
|
|
2320 pointing at @var{target}. The effect is that future attempts to open file
|
|
2321 @var{linkname} will refer to whatever file is named @var{target} at the
|
|
2322 time the opening is done, or will get an error if the name @var{target} is
|
|
2323 not in use at that time. This command does not expand the argument
|
|
2324 @var{target}, so that it allows you to specify a relative name
|
|
2325 as the target of the link.
|
|
2326
|
|
2327 Confirmation is required when creating the link if @var{linkname} is
|
|
2328 in use. Note that not all systems support symbolic links.
|
|
2329
|
|
2330 @node Compressed Files
|
|
2331 @section Accessing Compressed Files
|
|
2332 @cindex compression
|
|
2333 @cindex uncompression
|
|
2334 @cindex Auto Compression mode
|
|
2335 @cindex mode, Auto Compression
|
|
2336 @pindex gzip
|
|
2337
|
|
2338 @findex auto-compression-mode
|
|
2339 Emacs comes with a library that can automatically uncompress
|
|
2340 compressed files when you visit them, and automatically recompress them
|
|
2341 if you alter them and save them. To enable this feature, type the
|
|
2342 command @kbd{M-x auto-compression-mode}.
|
|
2343
|
|
2344 When automatic compression (which implies automatic uncompression as
|
|
2345 well) is enabled, Emacs recognizes compressed files by their file names.
|
|
2346 File names ending in @samp{.gz} indicate a file compressed with
|
|
2347 @code{gzip}. Other endings indicate other compression programs.
|
|
2348
|
|
2349 Automatic uncompression and compression apply to all the operations in
|
|
2350 which Emacs uses the contents of a file. This includes visiting it,
|
|
2351 saving it, inserting its contents into a buffer, loading it, and byte
|
|
2352 compiling it.
|
|
2353
|
|
2354 @node Remote Files
|
|
2355 @section Remote Files
|
|
2356
|
|
2357 @cindex FTP
|
|
2358 @cindex remote file access
|
|
2359 You can refer to files on other machines using a special file name syntax:
|
|
2360
|
|
2361 @example
|
|
2362 @group
|
|
2363 /@var{host}:@var{filename}
|
|
2364 /@var{user}@@@var{host}:@var{filename}
|
|
2365 @end group
|
|
2366 @end example
|
|
2367
|
|
2368 @noindent
|
|
2369 When you do this, Emacs uses the FTP program to read and write files on
|
|
2370 the specified host. It logs in through FTP using your user name or the
|
|
2371 name @var{user}. It may ask you for a password from time to time; this
|
|
2372 is used for logging in on @var{host}.
|
|
2373
|
|
2374 @cindex ange-ftp
|
|
2375 @vindex ange-ftp-default-user
|
|
2376 Normally, if you do not specify a user name in a remote file name,
|
|
2377 that means to use your own user name. But if you set the variable
|
|
2378 @code{ange-ftp-default-user} to a string, that string is used instead.
|
|
2379 (The Emacs package that implements FTP file access is called
|
|
2380 @code{ange-ftp}.)
|
|
2381
|
|
2382 @vindex file-name-handler-alist
|
|
2383 You can entirely turn off the FTP file name feature by setting the
|
|
2384 variable @code{file-name-handler-alist} to @code{nil}.
|
|
2385
|
|
2386 @node Quoted File Names
|
|
2387 @section Quoted File Names
|
|
2388
|
|
2389 @cindex quoting file names
|
|
2390 You can @dfn{quote} an absolute file name to prevent special
|
|
2391 characters and syntax in it from having their special effects.
|
|
2392 The way to do this is to add @samp{/:} at the beginning.
|
|
2393
|
|
2394 For example, you can quote a local file name which appears remote, to
|
|
2395 prevent it from being treated as a remote file name. Thus, if you have
|
|
2396 a directory named @file{/foo:} and a file named @file{bar} in it, you
|
|
2397 can refer to that file in Emacs as @samp{/:/foo:/bar}.
|
|
2398
|
|
2399 @samp{/:} can also prevent @samp{~} from being treated as a special
|
|
2400 character for a user's home directory. For example, @file{/:/tmp/~hack}
|
|
2401 refers to a file whose name is @file{~hack} in directory @file{/tmp}.
|
|
2402
|
|
2403 Likewise, quoting with @samp{/:} is one way to enter in the minibuffer
|
|
2404 a file name that contains @samp{$}. However, the @samp{/:} must be at
|
|
2405 the beginning of the buffer in order to quote @samp{$}.
|
|
2406
|
|
2407 You can also quote wildcard characters with @samp{/:}, for visiting.
|
|
2408 For example, @file{/:/tmp/foo*bar} visits the file @file{/tmp/foo*bar}.
|
|
2409 However, in most cases you can simply type the wildcard characters for
|
|
2410 themselves. For example, if the only file name in @file{/tmp} that
|
|
2411 starts with @samp{foo} and ends with @samp{bar} is @file{foo*bar}, then
|
|
2412 specifying @file{/tmp/foo*bar} will visit just @file{/tmp/foo*bar}.
|
|
2413
|