Mercurial > emacs
comparison man/files.texi @ 38739:7055d897b6bb
Many minor cleanups.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 08 Aug 2001 23:28:08 +0000 |
parents | 926054175878 |
children | b08b8519c0ab |
comparison
equal
deleted
inserted
replaced
38738:bffa96512ce4 | 38739:7055d897b6bb |
---|---|
44 @cindex file names | 44 @cindex file names |
45 | 45 |
46 Most Emacs commands that operate on a file require you to specify the | 46 Most Emacs commands that operate on a file require you to specify the |
47 file name. (Saving and reverting are exceptions; the buffer knows which | 47 file name. (Saving and reverting are exceptions; the buffer knows which |
48 file name to use for them.) You enter the file name using the | 48 file name to use for them.) You enter the file name using the |
49 minibuffer (@pxref{Minibuffer}). @dfn{Completion} is available, to make | 49 minibuffer (@pxref{Minibuffer}). @dfn{Completion} is available |
50 it easier to specify long file names. @xref{Completion}. When | 50 (@pxref{Completion}) to make it easier to specify long file names. When |
51 completing file names, Emacs ignores those whose file-name extensions | 51 completing file names, Emacs ignores those whose file-name extensions |
52 appear in the variable @code{completion-ignored-extensions}, see | 52 appear in the variable @code{completion-ignored-extensions}; see |
53 @ref{Completion Options}. | 53 @ref{Completion Options}. |
54 | 54 |
55 For most operations, there is a @dfn{default file name} which is used | 55 For most operations, there is a @dfn{default file name} which is used |
56 if you type just @key{RET} to enter an empty argument. Normally the | 56 if you type just @key{RET} to enter an empty argument. Normally the |
57 default file name is the name of the file visited in the current buffer; | 57 default file name is the name of the file visited in the current buffer; |
77 @findex pwd | 77 @findex pwd |
78 The command @kbd{M-x pwd} prints the current buffer's default | 78 The command @kbd{M-x pwd} prints the current buffer's default |
79 directory, and the command @kbd{M-x cd} sets it (to a value read using | 79 directory, and the command @kbd{M-x cd} sets it (to a value read using |
80 the minibuffer). A buffer's default directory changes only when the | 80 the minibuffer). A buffer's default directory changes only when the |
81 @code{cd} command is used. A file-visiting buffer's default directory | 81 @code{cd} command is used. A file-visiting buffer's default directory |
82 is initialized to the directory of the file that is visited there. If | 82 is initialized to the directory of the file that is visited in that buffer. If |
83 you create a buffer with @kbd{C-x b}, its default directory is copied | 83 you create a buffer with @kbd{C-x b}, its default directory is copied |
84 from that of the buffer that was current at the time. | 84 from that of the buffer that was current at the time. |
85 | 85 |
86 @vindex insert-default-directory | 86 @vindex insert-default-directory |
87 The default directory actually appears in the minibuffer when the | 87 The default directory actually appears in the minibuffer when the |
160 Visit a file with no conversion of the contents. | 160 Visit a file with no conversion of the contents. |
161 @end table | 161 @end table |
162 | 162 |
163 @cindex files, visiting and saving | 163 @cindex files, visiting and saving |
164 @cindex saving files | 164 @cindex saving files |
165 @dfn{Visiting} a file means copying its contents into an Emacs buffer | 165 @dfn{Visiting} a file means copying its contents into an Emacs |
166 so you can edit them. Emacs makes a new buffer for each file that you | 166 buffer so you can edit them. Emacs makes a new buffer for each file |
167 visit. We say that this buffer is visiting the file that it was created | 167 that you visit. We often say that this buffer ``is visiting'' that |
168 to hold. Emacs constructs the buffer name from the file name by | 168 file, or that the buffer's ``visited file'' is that file. Emacs |
169 throwing away the directory, keeping just the name proper. For example, | 169 constructs the buffer name from the file name by throwing away the |
170 a file named @file{/usr/rms/emacs.tex} would get a buffer named | 170 directory, keeping just the name proper. For example, a file named |
171 @samp{emacs.tex}. If there is already a buffer with that name, a unique | 171 @file{/usr/rms/emacs.tex} would get a buffer named @samp{emacs.tex}. |
172 name is constructed by appending @samp{<2>}, @samp{<3>}, and so on, using | 172 If there is already a buffer with that name, Emacs constructs a unique |
173 the lowest number that makes a name that is not already in use. | 173 name---the normal method is to append @samp{<2>}, @samp{<3>}, and so |
174 on, but you can select other methods (@pxref{Uniquify}). | |
174 | 175 |
175 Each window's mode line shows the name of the buffer that is being displayed | 176 Each window's mode line shows the name of the buffer that is being displayed |
176 in that window, so you can always tell what buffer you are editing. | 177 in that window, so you can always tell what buffer you are editing. |
177 | 178 |
178 The changes you make with editing commands are made in the Emacs | 179 The changes you make with editing commands are made in the Emacs |
257 Archives}, for more about these features. | 258 Archives}, for more about these features. |
258 | 259 |
259 @cindex wildcard characters in file names | 260 @cindex wildcard characters in file names |
260 @vindex find-file-wildcards | 261 @vindex find-file-wildcards |
261 If the file name you specify contains shell-style wildcard characters, | 262 If the file name you specify contains shell-style wildcard characters, |
262 Emacs visits all the files that match it. Wildcards comprise @samp{?}, | 263 Emacs visits all the files that match it. Wildcards include @samp{?}, |
263 @samp{*} and @samp{[@dots{}]} sequences. @xref{Quoted File Names}, for | 264 @samp{*}, and @samp{[@dots{}]} sequences. @xref{Quoted File Names}, for |
264 information on how to visit a file whose name actually contains wildcard | 265 information on how to visit a file whose name actually contains wildcard |
265 characters. You can disable the wildcard feature by customizing | 266 characters. You can disable the wildcard feature by customizing |
266 @code{find-file-wildcards}. | 267 @code{find-file-wildcards}. |
267 | 268 |
268 If you visit a file that the operating system won't let you modify, | 269 If you visit a file that the operating system won't let you modify, |
326 of functions, and the functions are called one by one (with no | 327 of functions, and the functions are called one by one (with no |
327 arguments) until one of them returns non-@code{nil}. This is not a | 328 arguments) until one of them returns non-@code{nil}. This is not a |
328 normal hook, and the name ends in @samp{-hooks} rather than @samp{-hook} | 329 normal hook, and the name ends in @samp{-hooks} rather than @samp{-hook} |
329 to indicate that fact. | 330 to indicate that fact. |
330 | 331 |
331 Any visiting of a file, whether extant or not, expects | 332 Successful visiting of any file, whether existing or not, calls the |
332 @code{find-file-hooks} to contain a list of functions, and calls them | 333 functions in the list @code{find-file-hooks}, with no arguments. |
333 all, one by one, with no arguments. This variable is really a normal | 334 This variable is really a normal hook, but it has an abnormal name for |
334 hook, but it has an abnormal name for historical compatibility. In the | 335 historical compatibility. In the case of a nonexistent file, the |
335 case of a nonexistent file, the @code{find-file-not-found-hooks} are run | 336 @code{find-file-not-found-hooks} are run first. @xref{Hooks}. |
336 first. @xref{Hooks}. | |
337 | 337 |
338 There are several ways to specify automatically the major mode for | 338 There are several ways to specify automatically the major mode for |
339 editing the file (@pxref{Choosing Modes}), and to specify local | 339 editing the file (@pxref{Choosing Modes}), and to specify local |
340 variables defined for that file (@pxref{File Variables}). | 340 variables defined for that file (@pxref{File Variables}). |
341 | 341 |
345 @dfn{Saving} a buffer in Emacs means writing its contents back into the file | 345 @dfn{Saving} a buffer in Emacs means writing its contents back into the file |
346 that was visited in the buffer. | 346 that was visited in the buffer. |
347 | 347 |
348 @table @kbd | 348 @table @kbd |
349 @item C-x C-s | 349 @item C-x C-s |
350 Save the current buffer in its visited file (@code{save-buffer}). | 350 Save the current buffer in its visited file on disk (@code{save-buffer}). |
351 @item C-x s | 351 @item C-x s |
352 Save any or all buffers in their visited files (@code{save-some-buffers}). | 352 Save any or all buffers in their visited files (@code{save-some-buffers}). |
353 @item M-~ | 353 @item M-~ |
354 Forget that the current buffer has been changed (@code{not-modified}). | 354 Forget that the current buffer has been changed (@code{not-modified}). |
355 With prefix argument (@kbd{C-u}), mark the current buffer as changed. | 355 With prefix argument (@kbd{C-u}), mark the current buffer as changed. |
356 @item C-x C-w | 356 @item C-x C-w |
357 Save the current buffer in a specified file (@code{write-file}). | 357 Save the current buffer as a specified file name (@code{write-file}). |
358 @item M-x set-visited-file-name | 358 @item M-x set-visited-file-name |
359 Change the file name under which the current buffer will be saved. | 359 Change the file name under which the current buffer will be saved. |
360 @end table | 360 @end table |
361 | 361 |
362 @kindex C-x C-s | 362 @kindex C-x C-s |
428 all the changes; but reverting is easier. | 428 all the changes; but reverting is easier. |
429 | 429 |
430 @findex set-visited-file-name | 430 @findex set-visited-file-name |
431 @kbd{M-x set-visited-file-name} alters the name of the file that the | 431 @kbd{M-x set-visited-file-name} alters the name of the file that the |
432 current buffer is visiting. It reads the new file name using the | 432 current buffer is visiting. It reads the new file name using the |
433 minibuffer. Then it specifies the visited file name and changes the | 433 minibuffer. Then it marks the buffer as visiting that file name, and |
434 buffer name correspondingly (as long as the new name is not in use). | 434 changes the buffer name correspondingly. @code{set-visited-file-name} |
435 @code{set-visited-file-name} does not save the buffer in the newly | 435 does not save the buffer in the newly visited file; it just alters the |
436 visited file; it just alters the records inside Emacs in case you do | 436 records inside Emacs in case you do save later. It also marks the |
437 save later. It also marks the buffer as ``modified'' so that @kbd{C-x | 437 buffer as ``modified'' so that @kbd{C-x C-s} in that buffer |
438 C-s} in that buffer @emph{will} save. | 438 @emph{will} save. |
439 | 439 |
440 @kindex C-x C-w | 440 @kindex C-x C-w |
441 @findex write-file | 441 @findex write-file |
442 If you wish to mark the buffer as visiting a different file and save it | 442 If you wish to mark the buffer as visiting a different file and save it |
443 right away, use @kbd{C-x C-w} (@code{write-file}). It is precisely | 443 right away, use @kbd{C-x C-w} (@code{write-file}). It is precisely |
444 equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}. | 444 equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}. |
445 @kbd{C-x C-s} used on a buffer that is not visiting a file has the | 445 @kbd{C-x C-s} used on a buffer that is not visiting a file has the |
446 same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the | 446 same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the |
447 buffer as visiting that file, and saves it there. The default file name in | 447 buffer as visiting that file, and saves it there. The default file name in |
448 a buffer that is not visiting a file is made by combining the buffer name | 448 a buffer that is not visiting a file is made by combining the buffer name |
449 with the buffer's default directory. | 449 with the buffer's default directory (@pxref{File Names}). |
450 | 450 |
451 If the new file name implies a major mode, then @kbd{C-x C-w} switches | 451 If the new file name implies a major mode, then @kbd{C-x C-w} switches |
452 to that major mode, in most cases. The command | 452 to that major mode, in most cases. The command |
453 @code{set-visited-file-name} also does this. @xref{Choosing Modes}. | 453 @code{set-visited-file-name} also does this. @xref{Choosing Modes}. |
454 | 454 |
519 buffer even though it has already been saved at least once. If you save | 519 buffer even though it has already been saved at least once. If you save |
520 the buffer with @kbd{C-u C-x C-s}, the version thus saved will be made | 520 the buffer with @kbd{C-u C-x C-s}, the version thus saved will be made |
521 into a backup file if you save the buffer again. @kbd{C-u C-u C-x C-s} | 521 into a backup file if you save the buffer again. @kbd{C-u C-u C-x C-s} |
522 saves the buffer, but first makes the previous file contents into a new | 522 saves the buffer, but first makes the previous file contents into a new |
523 backup file. @kbd{C-u C-u C-u C-x C-s} does both things: it makes a | 523 backup file. @kbd{C-u C-u C-u C-x C-s} does both things: it makes a |
524 backup from the previous contents and arranges to make another from the | 524 backup from the previous contents, and arranges to make another from the |
525 newly saved contents, if you save again. | 525 newly saved contents if you save again. |
526 | 526 |
527 @menu | 527 @menu |
528 * Names: Backup Names. How backup files are named; | 528 * Names: Backup Names. How backup files are named; |
529 choosing single or numbered backup files. | 529 choosing single or numbered backup files. |
530 * Deletion: Backup Deletion. Emacs deletes excess numbered backups. | 530 * Deletion: Backup Deletion. Emacs deletes excess numbered backups. |
608 | 608 |
609 @vindex kept-old-versions | 609 @vindex kept-old-versions |
610 @vindex kept-new-versions | 610 @vindex kept-new-versions |
611 The two variables @code{kept-old-versions} and | 611 The two variables @code{kept-old-versions} and |
612 @code{kept-new-versions} control this deletion. Their values are, | 612 @code{kept-new-versions} control this deletion. Their values are, |
613 respectively, the number of oldest (lowest-numbered) backups to keep and | 613 respectively, the number of oldest (lowest-numbered) backups to keep |
614 the number of newest (highest-numbered) ones to keep, each time a new | 614 and the number of newest (highest-numbered) ones to keep, each time a |
615 backup is made. Recall that these values are used just after a new | 615 new backup is made. The backups in the middle (excluding those oldest |
616 backup version is made; that newly made backup is included in the count | 616 and newest) are the excess middle versions---those backups are |
617 in @code{kept-new-versions}. By default, both variables are 2. | 617 deleted. These variables' values are used when it is time to delete |
618 excess versions, just after a new backup version is made; the newly | |
619 made backup is included in the count in @code{kept-new-versions}. By | |
620 default, both variables are 2. | |
618 | 621 |
619 @vindex delete-old-versions | 622 @vindex delete-old-versions |
620 If @code{delete-old-versions} is non-@code{nil}, the excess | 623 If @code{delete-old-versions} is non-@code{nil}, Emacs deletes the |
621 middle versions are deleted without a murmur. If it is @code{nil}, the | 624 excess backup files silently. If it is @code{nil}, the default, Emacs |
622 default, then you are asked whether the excess middle versions should | 625 asks you whether it should delete the excess backup versions. |
623 really be deleted. | |
624 | 626 |
625 Dired's @kbd{.} (Period) command can also be used to delete old versions. | 627 Dired's @kbd{.} (Period) command can also be used to delete old versions. |
626 @xref{Dired Deletion}. | 628 @xref{Dired Deletion}. |
627 | 629 |
628 @node Backup Copying | 630 @node Backup Copying |
629 @subsubsection Copying vs.@: Renaming | 631 @subsubsection Copying vs.@: Renaming |
630 | 632 |
631 Backup files can be made by copying the old file or by renaming it. This | 633 Backup files can be made by copying the old file or by renaming it. |
632 makes a difference when the old file has multiple names. If the old file | 634 This makes a difference when the old file has multiple names (hard |
633 is renamed into the backup file, then the alternate names become names for | 635 links). If the old file is renamed into the backup file, then the |
634 the backup file. If the old file is copied instead, then the alternate | 636 alternate names become names for the backup file. If the old file is |
635 names remain names for the file that you are editing, and the contents | 637 copied instead, then the alternate names remain names for the file |
636 accessed by those names will be the new contents. | 638 that you are editing, and the contents accessed by those names will be |
639 the new contents. | |
637 | 640 |
638 The method of making a backup file may also affect the file's owner | 641 The method of making a backup file may also affect the file's owner |
639 and group. If copying is used, these do not change. If renaming is used, | 642 and group. If copying is used, these do not change. If renaming is used, |
640 you become the file's owner, and the file's group becomes the default | 643 you become the file's owner, and the file's group becomes the default |
641 (different operating systems have different defaults for the group). | 644 (different operating systems have different defaults for the group). |
716 Steal the lock. Whoever was already changing the file loses the lock, | 719 Steal the lock. Whoever was already changing the file loses the lock, |
717 and you gain the lock. | 720 and you gain the lock. |
718 @item p | 721 @item p |
719 Proceed. Go ahead and edit the file despite its being locked by someone else. | 722 Proceed. Go ahead and edit the file despite its being locked by someone else. |
720 @item q | 723 @item q |
721 Quit. This causes an error (@code{file-locked}) and the modification you | 724 Quit. This causes an error (@code{file-locked}), and the buffer |
722 were trying to make in the buffer does not actually take place. | 725 contents remain unchanged---the modification you were trying to make |
726 does not actually take place. | |
723 @end table | 727 @end table |
724 | 728 |
725 Note that locking works on the basis of a file name; if a file has | 729 Note that locking works on the basis of a file name; if a file has |
726 multiple names, Emacs does not realize that the two names are the same file | 730 multiple names, Emacs does not realize that the two names are the same file |
727 and cannot prevent two users from editing it simultaneously under different | 731 and cannot prevent two users from editing it simultaneously under different |
944 useful if it contains the deleted text. To reenable auto-saving after | 948 useful if it contains the deleted text. To reenable auto-saving after |
945 this happens, save the buffer with @kbd{C-x C-s}, or use @kbd{C-u 1 M-x | 949 this happens, save the buffer with @kbd{C-x C-s}, or use @kbd{C-u 1 M-x |
946 auto-save}. | 950 auto-save}. |
947 | 951 |
948 @vindex auto-save-visited-file-name | 952 @vindex auto-save-visited-file-name |
949 If you want auto-saving to be done in the visited file, set the variable | 953 If you want auto-saving to be done in the visited file rather than |
950 @code{auto-save-visited-file-name} to be non-@code{nil}. In this mode, | 954 in a separate auto-save file, set the variable |
951 there is really no difference between auto-saving and explicit saving. | 955 @code{auto-save-visited-file-name} to a non-@code{nil} value. In this |
956 mode, there is no real difference between auto-saving and explicit | |
957 saving. | |
952 | 958 |
953 @vindex delete-auto-save-files | 959 @vindex delete-auto-save-files |
954 A buffer's auto-save file is deleted when you save the buffer in its | 960 A buffer's auto-save file is deleted when you save the buffer in its |
955 visited file. To inhibit this, set the variable @code{delete-auto-save-files} | 961 visited file. To inhibit this, set the variable @code{delete-auto-save-files} |
956 to @code{nil}. Changing the visited file name with @kbd{C-x C-w} or | 962 to @code{nil}. Changing the visited file name with @kbd{C-x C-w} or |
1342 to do the operation. | 1348 to do the operation. |
1343 | 1349 |
1344 @itemize @bullet | 1350 @itemize @bullet |
1345 @item | 1351 @item |
1346 If the file is modified (or locked), you can specify the version | 1352 If the file is modified (or locked), you can specify the version |
1347 number to use for the new verion that you check-in. This is one way | 1353 number to use for the new version that you check in. This is one way |
1348 to create a new branch (@pxref{Branches}). | 1354 to create a new branch (@pxref{Branches}). |
1349 | 1355 |
1350 @item | 1356 @item |
1351 If the file is not modified (and unlocked), you can specify the | 1357 If the file is not modified (and unlocked), you can specify the |
1352 version to select; this lets you start working from an older version, | 1358 version to select; this lets you start working from an older version, |
1356 the repository. | 1362 the repository. |
1357 | 1363 |
1358 @item | 1364 @item |
1359 Instead of the version number, you can also specify the name of a | 1365 Instead of the version number, you can also specify the name of a |
1360 version control system. This is useful when one file is being managed | 1366 version control system. This is useful when one file is being managed |
1361 with two version control systems at the same time file (@pxref{Local | 1367 with two version control systems at the same time (@pxref{Local |
1362 Version Control}). | 1368 Version Control}). |
1363 @end itemize | 1369 @end itemize |
1364 | 1370 |
1365 @node Log Buffer | 1371 @node Log Buffer |
1366 @subsubsection Features of the Log Entry Buffer | 1372 @subsubsection Features of the Log Entry Buffer |
1410 Display the result of the CVS annotate command using colors. | 1416 Display the result of the CVS annotate command using colors. |
1411 @end table | 1417 @end table |
1412 | 1418 |
1413 @findex vc-version-other-window | 1419 @findex vc-version-other-window |
1414 @kindex C-x v ~ | 1420 @kindex C-x v ~ |
1415 To examine an old version in toto, visit the file and then type | 1421 To examine an old version in its entirety, visit the file and then type |
1416 @kbd{C-x v ~ @var{version} @key{RET}} (@code{vc-version-other-window}). | 1422 @kbd{C-x v ~ @var{version} @key{RET}} (@code{vc-version-other-window}). |
1417 This puts the text of version @var{version} in a file named | 1423 This puts the text of version @var{version} in a file named |
1418 @file{@var{filename}.~@var{version}~}, and visits it in its own buffer | 1424 @file{@var{filename}.~@var{version}~}, and visits it in its own buffer |
1419 in a separate window. (In RCS, you can also select an old version | 1425 in a separate window. (In RCS, you can also select an old version |
1420 and create a branch from it. @xref{Branches}.) | 1426 and create a branch from it. @xref{Branches}.) |
1436 | 1442 |
1437 If you supply a directory name instead of the name of a registered | 1443 If you supply a directory name instead of the name of a registered |
1438 file, this command compares the two specified versions of all registered | 1444 file, this command compares the two specified versions of all registered |
1439 files in that directory and its subdirectories. | 1445 files in that directory and its subdirectories. |
1440 | 1446 |
1441 @vindex diff-switches | |
1442 @vindex vc-diff-switches | 1447 @vindex vc-diff-switches |
1448 @vindex vc-rcs-diff-switches | |
1443 @kbd{C-x v =} works by running a variant of the @code{diff} utility | 1449 @kbd{C-x v =} works by running a variant of the @code{diff} utility |
1444 designed to work with the version control system in use. Emacs passes | 1450 designed to work with the version control system in use. When you |
1445 the contents of the variable @code{diff-switches} to it; you can | 1451 invoke @code{diff} this way, in addition to the options specified by |
1446 specify comparison options for version control in | 1452 @code{diff-switches} (@pxref{Comparing files}), it receives those |
1447 @code{vc-diff-switches}, and there are similar variables for each | 1453 specified by @code{vc-diff-switches}, plus those specified for the |
1448 specific system---@code{vc-rcs-diff-switches}, and so on. | 1454 specific back end by @code{vc-@var{backend}-diff-switches}. For |
1455 instance, when the version control back end is RCS, @code{diff} uses | |
1456 the options in @code{vc-rcs-diff-switches}. The | |
1457 @samp{vc@dots{}diff-switches} variables are @code{nil} by default. | |
1449 | 1458 |
1450 Unlike the @kbd{M-x diff} command, @kbd{C-x v =} does not try to | 1459 Unlike the @kbd{M-x diff} command, @kbd{C-x v =} does not try to |
1451 locate the changes in the old and new versions. This is because | 1460 locate the changes in the old and new versions. This is because |
1452 normally one or both versions do not exist as files when you compare | 1461 normally one or both versions do not exist as files when you compare |
1453 them; they exist only in the records of the master file. | 1462 them; they exist only in the records of the master file. |
1455 | 1464 |
1456 @findex vc-annotate | 1465 @findex vc-annotate |
1457 @kindex C-x v g | 1466 @kindex C-x v g |
1458 For CVS-controlled files, you can display the result of the CVS | 1467 For CVS-controlled files, you can display the result of the CVS |
1459 annotate command, using colors to enhance the visual appearance. Use | 1468 annotate command, using colors to enhance the visual appearance. Use |
1460 the command @kbd{M-x vc-annotate} to do this. Red means new, blue means | 1469 the command @kbd{M-x vc-annotate} to do this. Red means new, blue |
1461 old, and intermediate colors indicate intermediate ages. A prefix | 1470 means old, and intermediate colors indicate intermediate ages. By |
1462 argument @var{n} specifies a stretch factor for the time scale; it makes | 1471 default, the time scale is 360 days, so that everything more than one |
1463 each color cover a period @var{n} times as long. | 1472 year old is shown in blue. Giving a prefix argument @var{n} to this |
1473 command multiplies the time scale by @var{n}, so that all text over | |
1474 @var{n} years old is shown in blue. | |
1464 | 1475 |
1465 @node Secondary VC Commands | 1476 @node Secondary VC Commands |
1466 @subsection The Secondary Commands of VC | 1477 @subsection The Secondary Commands of VC |
1467 | 1478 |
1468 This section explains the secondary commands of VC; those that you might | 1479 This section explains the secondary commands of VC; those that you might |
1816 since you checked the file out (we call this @dfn{merging the news}). | 1827 since you checked the file out (we call this @dfn{merging the news}). |
1817 This is the common way to pick up recent changes from the repository, | 1828 This is the common way to pick up recent changes from the repository, |
1818 regardless of whether you have already changed the file yourself. | 1829 regardless of whether you have already changed the file yourself. |
1819 | 1830 |
1820 You can also enter a branch number or a pair of version numbers in | 1831 You can also enter a branch number or a pair of version numbers in |
1821 the minibuffer. Then @kbd{C-x v m} finds the changes from that branch, | 1832 the minibuffer. Then @kbd{C-x v m} finds the changes from that |
1822 or between the two versions you specified, and merges them into the | 1833 branch, or the differences between the two versions you specified, and |
1823 current version of the current file. | 1834 merges them into the current version of the current file. |
1824 | 1835 |
1825 As an example, suppose that you have finished a certain feature on | 1836 As an example, suppose that you have finished a certain feature on |
1826 branch 1.3.1. In the meantime, development on the trunk has proceeded | 1837 branch 1.3.1. In the meantime, development on the trunk has proceeded |
1827 to version 1.5. To merge the changes from the branch to the trunk, | 1838 to version 1.5. To merge the changes from the branch to the trunk, |
1828 first go to the head version of the trunk, by typing @kbd{C-u C-x C-q | 1839 first go to the head version of the trunk, by typing @kbd{C-u C-x C-q |
1868 @end smallexample | 1879 @end smallexample |
1869 | 1880 |
1870 @cindex vc-resolve-conflicts | 1881 @cindex vc-resolve-conflicts |
1871 Then you can resolve the conflicts by editing the file manually. Or | 1882 Then you can resolve the conflicts by editing the file manually. Or |
1872 you can type @code{M-x vc-resolve-conflicts} after visiting the file. | 1883 you can type @code{M-x vc-resolve-conflicts} after visiting the file. |
1873 This starts an Ediff session, as described above. | 1884 This starts an Ediff session, as described above. Don't forget to |
1885 check in the merged version afterwards. | |
1874 | 1886 |
1875 @node Multi-User Branching | 1887 @node Multi-User Branching |
1876 @subsubsection Multi-User Branching | 1888 @subsubsection Multi-User Branching |
1877 | 1889 |
1878 It is often useful for multiple developers to work simultaneously on | 1890 It is often useful for multiple developers to work simultaneously on |
2332 master files, which is done when there are no version headers. Note | 2344 master files, which is done when there are no version headers. Note |
2333 that in a multi-branch environment, version headers are necessary to | 2345 that in a multi-branch environment, version headers are necessary to |
2334 make VC behave correctly (@pxref{Multi-User Branching}). | 2346 make VC behave correctly (@pxref{Multi-User Branching}). |
2335 | 2347 |
2336 Searching for version headers is controlled by the variable | 2348 Searching for version headers is controlled by the variable |
2337 @code{vc-consult-headers}. If it is non-@code{nil}, Emacs searches for | 2349 @code{vc-consult-headers}. If it is non-@code{nil} (the default), |
2338 headers to determine the version number you are editing. Setting it to | 2350 Emacs searches for headers to determine the version number you are |
2339 @code{nil} disables this feature. | 2351 editing. Setting it to @code{nil} disables this feature. |
2340 | 2352 |
2341 @kindex C-x v h | 2353 @kindex C-x v h |
2342 @findex vc-insert-headers | 2354 @findex vc-insert-headers |
2343 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to | 2355 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to |
2344 insert a suitable header string. | 2356 insert a suitable header string. |
2358 | 2370 |
2359 Instead of a single string, you can specify a list of strings; then | 2371 Instead of a single string, you can specify a list of strings; then |
2360 each string in the list is inserted as a separate header on a line of | 2372 each string in the list is inserted as a separate header on a line of |
2361 its own. | 2373 its own. |
2362 | 2374 |
2363 It is often necessary to use ``superfluous'' backslashes when writing | 2375 It is often necessary to use ``superfluous'' backslashes when |
2364 the strings that you put in this variable. This is to prevent the | 2376 writing the strings that you put in this variable. For instance, you |
2365 string in the constant from being interpreted as a header itself if the | 2377 might write @code{"$Id\$"} rather than @code{"$Id@w{$}"}. The extra |
2366 Emacs Lisp file containing it is maintained with version control. | 2378 backslash prevents the string constant from being interpreted as a |
2379 header, if the Emacs Lisp file containing it is maintained with | |
2380 version control. | |
2367 | 2381 |
2368 @vindex vc-comment-alist | 2382 @vindex vc-comment-alist |
2369 Each header is inserted surrounded by tabs, inside comment delimiters, | 2383 Each header is inserted surrounded by tabs, inside comment delimiters, |
2370 on a new line at point. Normally the ordinary comment | 2384 on a new line at point. Normally the ordinary comment |
2371 start and comment end strings of the current mode are used, but for | 2385 start and comment end strings of the current mode are used, but for |
2647 @cindex comparing files | 2661 @cindex comparing files |
2648 | 2662 |
2649 @findex diff | 2663 @findex diff |
2650 @vindex diff-switches | 2664 @vindex diff-switches |
2651 The command @kbd{M-x diff} compares two files, displaying the | 2665 The command @kbd{M-x diff} compares two files, displaying the |
2652 differences in an Emacs buffer named @samp{*diff*}. It works by running | 2666 differences in an Emacs buffer named @samp{*diff*}. It works by |
2653 the @code{diff} program, using options taken from the variable | 2667 running the @code{diff} program, using options taken from the variable |
2654 @code{diff-switches}, whose value should be a string. | 2668 @code{diff-switches}. The value of @code{diff-switches} should be a |
2669 string; the default is @code{"-c"} to specify a context diff. | |
2655 | 2670 |
2656 The buffer @samp{*diff*} has Compilation mode as its major mode, so | 2671 The buffer @samp{*diff*} has Compilation mode as its major mode, so |
2657 you can use @kbd{C-x `} to visit successive changed locations in the two | 2672 you can use @kbd{C-x `} to visit successive changed locations in the two |
2658 source files. You can also move to a particular hunk of changes and | 2673 source files. You can also move to a particular hunk of changes and |
2659 type @key{RET} or @kbd{C-c C-c}, or click @kbd{Mouse-2} on it, to move | 2674 type @key{RET} or @kbd{C-c C-c}, or click @kbd{Mouse-2} on it, to move |
2729 mode. | 2744 mode. |
2730 | 2745 |
2731 A related command, @kbd{M-x view-buffer}, views a buffer already present | 2746 A related command, @kbd{M-x view-buffer}, views a buffer already present |
2732 in Emacs. @xref{Misc Buffer}. | 2747 in Emacs. @xref{Misc Buffer}. |
2733 | 2748 |
2749 @kindex C-x i | |
2734 @findex insert-file | 2750 @findex insert-file |
2735 @kbd{M-x insert-file} inserts a copy of the contents of the specified | 2751 @kbd{M-x insert-file} (also @kbd{C-x i}) inserts a copy of the |
2736 file into the current buffer at point, leaving point unchanged before the | 2752 contents of the specified file into the current buffer at point, |
2737 contents and the mark after them. | 2753 leaving point unchanged before the contents and the mark after them. |
2738 | 2754 |
2739 @findex write-region | 2755 @findex write-region |
2740 @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it | 2756 @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it |
2741 copies the contents of the region into the specified file. @kbd{M-x | 2757 copies the contents of the region into the specified file. @kbd{M-x |
2742 append-to-file} adds the text of the region to the end of the specified | 2758 append-to-file} adds the text of the region to the end of the specified |
2748 command in the shell. If you are deleting many files in one directory, it | 2764 command in the shell. If you are deleting many files in one directory, it |
2749 may be more convenient to use Dired (@pxref{Dired}). | 2765 may be more convenient to use Dired (@pxref{Dired}). |
2750 | 2766 |
2751 @findex rename-file | 2767 @findex rename-file |
2752 @kbd{M-x rename-file} reads two file names @var{old} and @var{new} using | 2768 @kbd{M-x rename-file} reads two file names @var{old} and @var{new} using |
2753 the minibuffer, then renames file @var{old} as @var{new}. If a file named | 2769 the minibuffer, then renames file @var{old} as @var{new}. If the file name |
2754 @var{new} already exists, you must confirm with @kbd{yes} or renaming is not | 2770 @var{new} already exists, you must confirm with @kbd{yes} or renaming is not |
2755 done; this is because renaming causes the old meaning of the name @var{new} | 2771 done; this is because renaming causes the old meaning of the name @var{new} |
2756 to be lost. If @var{old} and @var{new} are on different file systems, the | 2772 to be lost. If @var{old} and @var{new} are on different file systems, the |
2757 file @var{old} is copied and deleted. | 2773 file @var{old} is copied and deleted. |
2758 | 2774 |
2759 @findex add-name-to-file | 2775 @findex add-name-to-file |
2776 @cindex hard links (creation) | |
2760 The similar command @kbd{M-x add-name-to-file} is used to add an | 2777 The similar command @kbd{M-x add-name-to-file} is used to add an |
2761 additional name to an existing file without removing its old name. | 2778 additional name to an existing file without removing its old name. |
2779 The new name is created as a ``hard link'' to the existing file. | |
2762 The new name must belong on the same file system that the file is on. | 2780 The new name must belong on the same file system that the file is on. |
2763 On Windows, this command works only if the file resides in an NTFS | 2781 On Windows, this command works only if the file resides in an NTFS |
2764 file system. On MS-DOS, it works by copying the file. | 2782 file system. On MS-DOS, it works by copying the file. |
2765 | 2783 |
2766 @findex copy-file | 2784 @findex copy-file |