@c This is part of the Emacs manual.
-@c Copyright (C) 1985,86,87,93,94,95,97,99, 2000, 2001, 2004
-@c Free Software Foundation, Inc.
+@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
+@c 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Files, Buffers, Keyboard Macros, Top
@chapter File Handling
* Quoted File Names:: Quoting special characters in file names.
* File Name Cache:: Completion against a list of files you often use.
* File Conveniences:: Convenience Features for Finding Files.
+* Filesets:: Handling sets of files.
@end menu
@node File Names
@cindex wildcard characters in file names
@vindex find-file-wildcards
- If the file name you specify contains shell-style wildcard characters,
-Emacs visits all the files that match it. Wildcards include @samp{?},
-@samp{*}, and @samp{[@dots{}]} sequences. @xref{Quoted File Names}, for
-information on how to visit a file whose name actually contains wildcard
-characters. You can disable the wildcard feature by customizing
+ If the file name you specify contains shell-style wildcard
+characters, Emacs visits all the files that match it. Wildcards
+include @samp{?}, @samp{*}, and @samp{[@dots{}]} sequences. To enter
+the wild card @samp{?} in a file name in the minibuffer, you need to
+type @kbd{C-q ?}. @xref{Quoted File Names}, for information on how to
+visit a file whose name actually contains wildcard characters. You
+can disable the wildcard feature by customizing
@code{find-file-wildcards}.
If you visit a file that the operating system won't let you modify,
@dfn{Saving} a buffer in Emacs means writing its contents back into the file
that was visited in the buffer.
+@menu
+* Save Commands:: Commands for saving files.
+* Backup:: How Emacs saves the old version of your file.
+* Customize Save:: Customizing the saving of files.
+* Interlocking:: How Emacs protects against simultaneous editing
+ of one file by two users.
+* Shadowing: File Shadowing. Copying files to "shadows" automatically.
+* Time Stamps:: Emacs can update time stamps on saved files.
+@end menu
+
+@node Save Commands
+@subsection Commands for Saving Files
+
+ These are the commands that relate to saving and writing files.
+
@table @kbd
@item C-x C-s
Save the current buffer in its visited file on disk (@code{save-buffer}).
@kindex C-x C-w
@findex write-file
If you wish to mark the buffer as visiting a different file and save it
-right away, use @kbd{C-x C-w} (@code{write-file}). It is precisely
-equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}.
+right away, use @kbd{C-x C-w} (@code{write-file}). It is
+equivalent to @code{set-visited-file-name} followed by @kbd{C-x C-s}
+(except that @kbd{C-x C-w} asks for confirmation if the file exists).
@kbd{C-x C-s} used on a buffer that is not visiting a file has the
same effect as @kbd{C-x C-w}; that is, it reads a file name, marks the
buffer as visiting that file, and saves it there. The default file name in
by simultaneous editing and requires your immediate attention.
@xref{Interlocking,, Simultaneous Editing}.
-@vindex require-final-newline
- If the value of the variable @code{require-final-newline} is
-@code{t}, Emacs silently puts a newline at the end of any file that
-doesn't already end in one, every time a file is saved or written. If
-the value is @code{visit}, Emacs adds a newline at the end of any file
-that doesn't have one, just after it visits the file. (This marks the
-buffer as modified, and you can undo it.) If the value is
-@code{visit-save}, that means to add newlines both on visiting and on
-saving. If the value is @code{nil}, Emacs leaves the end of the file
-unchanged; if it's neither @code{nil} nor @code{t}, Emacs asks you
-whether to add a newline. The default is @code{nil}.
-
-@vindex mode-require-final-newline
- Many major modes are designed for specific kinds of files that are
-always supposed to end in newlines. These major modes set the
-variable @code{require-final-newline} according to
-@code{mode-require-final-newline}. By setting the latter variable,
-you can control how these modes handle final newlines.
-
-@menu
-* Backup:: How Emacs saves the old version of your file.
-* Interlocking:: How Emacs protects against simultaneous editing
- of one file by two users.
-* Shadowing: File Shadowing.
- Copying files to "shadows" automatically.
-* Time Stamps:: Emacs can update time stamps on saved files.
-@end menu
-
@node Backup
@subsection Backup Files
@cindex backup file
any alternate names for the same file. This has nothing to do with
Emacs---the version control system does it.
+@node Customize Save
+@subsection Customizing Saving of Files
+
+@vindex require-final-newline
+ If the value of the variable @code{require-final-newline} is
+@code{t}, saving or writing a file silently puts a newline at the end
+if there isn't already one there. If the value is @code{visit}, Emacs
+adds a newline at the end of any file that doesn't have one, just
+after it visits the file. (This marks the buffer as modified, and you
+can undo it.) If the value is @code{visit-save}, that means to add
+newlines both on visiting and on saving. If the value is @code{nil},
+Emacs leaves the end of the file unchanged; if it's neither @code{nil}
+nor @code{t}, Emacs asks you whether to add a newline. The default is
+@code{nil}.
+
+@vindex mode-require-final-newline
+ Many major modes are designed for specific kinds of files that are
+always supposed to end in newlines. These major modes set the
+variable @code{require-final-newline} according to
+@code{mode-require-final-newline}. By setting the latter variable,
+you can control how these modes handle final newlines.
+
+@vindex write-region-inhibit-fsync
+ When Emacs saves a file, it invokes the @code{fsync} system call to
+force the data immediately out to disk. This is important for safety
+if the system crashes or in case of power outage. However, it can be
+disruptive on laptops using power saving, because it requires the disk
+to spin up each time you save a file. Setting
+@code{write-region-inhibit-fsync} to a non-@code{nil} value disables
+this synchronization. Be careful---this means increased risk of data
+loss.
+
@node Interlocking
@subsection Protection against Simultaneous Editing
for a changed file. Since checking a remote file is too slow, these
modes do not check or revert remote files.
-@vindex auto-revert-check-vc-info
- Whenever Auto Revert mode reverts the buffer, it updates the version
-control information, such as the version control number displayed in
-the mode line. However, this information may not be properly updated
-if the version control state changes outside of Emacs---for example,
-if a new version is checked in from outside the current Emacs session.
-If you set @code{auto-revert-check-vc-info} to @code{t}, Auto Revert
-mode will update the version control status information periodically.
+@xref{VC Mode Line}, for Auto Revert peculiarities in buffers that
+visit files under version control.
@node Auto Save
@section Auto-Saving: Protection Against Disasters
higher-level systems such as CVS or GNU Arch.
In the following, we discuss mainly RCS, SCCS and CVS. Nearly
-everything said about CVS applies to Gnu Arch, Subversion and Meta-CVS
+everything said about CVS applies to GNU Arch, Subversion and Meta-CVS
as well.
@node VC Concepts
that it is modified. If the file is locked by some other user (for
instance, @samp{jim}), that is displayed as @samp{RCS:jim:1.3}.
+@vindex auto-revert-check-vc-info
+ When Auto Revert mode (@pxref{Reverting}) reverts a buffer that is
+under version control, it updates the version control information in
+the mode line. However, Auto Revert mode may not properly update this
+information if the version control status changes without changes to
+the work file, from outside the current Emacs session. If you set
+@code{auto-revert-check-vc-info} to @code{t}, Auto Revert mode updates
+the version control status information every
+@code{auto-revert-interval} seconds, even if the work file itself is
+unchanged. The resulting CPU usage depends on the version control
+system, but is usually not excessive.
+
@node Basic VC Editing
@subsection Basic Editing under Version Control
When you check in changes, @kbd{C-x v v} first reads a log entry. It
pops up a buffer called @samp{*VC-Log*} for you to enter the log entry.
-When you are finished, type @kbd{C-c C-c} in the @samp{*VC-Log*} buffer.
-That is when check-in really happens.
+
+Sometimes the @samp{*VC-Log*} buffer contains default text when you enter it,
+typically the last log message entered. If it does, mark and point
+are set around the entire contents of the buffer so that it is easy to
+kill the contents of the buffer with @kbd{C-w}.
+
+@findex log-edit-insert-changelog
+If you work by writing entries in the @file{ChangeLog}
+(@pxref{Change Log}) and then commit the change under revision
+control, you can generate the Log Edit text from the ChangeLog using
+@kbd{C-c C-a} (@kbd{log-edit-insert-changelog}). This looks for
+entries for the file(s) concerned in the top entry in the ChangeLog
+and uses those paragraphs as the log text. This text is only inserted
+if the top entry was made under your user name on the current date.
+@xref{Change Logs and VC}, for the opposite way of
+working---generating ChangeLog entries from the revision control log.
+
+In the @samp{*VC-Log*} buffer, @kbd{C-c C-f} (@kbd{M-x log-edit-show-files})
+shows the list of files to be committed in case you need to check
+that. (This can be a list of more than one file if you use VC Dired
+mode or PCL-CVS. @xref{VC Dired Mode}, and @ref{Top, , About PCL-CVS,
+pcl-cvs, PCL-CVS --- The Emacs Front-End to CVS}.)
+
+When you have finished editing the log message, type @kbd{C-c C-c} to
+exit the buffer and commit the change.
To abort check-in, just @strong{don't} type @kbd{C-c C-c} in that
buffer. You can switch buffers and do other editing. As long as you
@kindex C-x v g
For some backends, you can display the file @dfn{annotated} with
per-line version information and using colors to enhance the visual
-appearance, with the the command @kbd{M-x vc-annotate}.
+appearance, with the command @kbd{M-x vc-annotate}.
It creates a new buffer
to display file's text, colored to show how old each part is. Text
colored red is new, blue means old, and intermediate colors indicate
If locking is in use, @kbd{C-x v i} leaves the file unlocked and
read-only. Type @kbd{C-x v v} if you wish to start editing it. After
registering a file with CVS, you must subsequently commit the initial
-version by typing @kbd{C-x v v}.
+version by typing @kbd{C-x v v}. Until you do that, the version
+appears as @samp{@@@@} in the mode line.
@vindex vc-default-init-version
@cindex initial version number to register
snapshot thus modified may not completely work (@pxref{Snapshot
Caveats}).
+ Some backends do not provide an explicit rename operation to their
+repositories. After issuing @code{vc-rename-file}, use @kbd{C-x v v}
+on the original and renamed buffers and provide the necessary edit
+log.
+
You cannot use @code{vc-rename-file} on a file that is locked by
someone else.
@findex diff-goto-source
After running @kbd{M-x diff}, you can use @kbd{C-x `} to visit
successive changed locations in the two source files, as in
-Compilation mode (@pxref{Compilation}.) In the @samp{*diff*} buffer,
+Compilation mode (@pxref{Compilation Mode}.) In the @samp{*diff*} buffer,
you can move to a particular hunk of changes and type @kbd{C-c C-c}
(@code{diff-goto-source}) to visit the corresponding source location.
of.
@findex compare-windows
- The command @kbd{M-x compare-windows} compares the text in the current
-window with that in the next window. Comparison starts at point in each
-window, and each starting position is pushed on the mark ring in its
-respective buffer. Then point moves forward in each window, a character
-at a time, until a mismatch between the two windows is reached. Then
-the command is finished. For more information about windows in Emacs,
-@ref{Windows}.
+ The command @kbd{M-x compare-windows} compares the text in the
+current window with that in the next window. (For more information
+about windows in Emacs, @ref{Windows}.) Comparison starts at point in
+each window, after pushing each initial point value on the mark ring
+in its respective buffer. Then it moves point forward in each window,
+one character at a time, until it reaches characters that don't match.
+Then the command exits.
+
+ If point in the two windows is followed by non-matching text when
+the command starts, it tries heuristically to advance up to matching
+text in the two windows, and then exits. So if you use @kbd{M-x
+compare-windows} repeatedly, each time it either skips one matching
+range or finds the start of another.
@vindex compare-ignore-case
@vindex compare-ignore-whitespace
@findex write-region
@kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
copies the contents of the region into the specified file. @kbd{M-x
-append-to-file} adds the text of the region to the end of the specified
-file. @xref{Accumulating Text}.
+append-to-file} adds the text of the region to the end of the
+specified file. @xref{Accumulating Text}. The variable
+@code{write-region-inhibit-fsync} applies to these commands, as well
+as saving files; see @ref{Customize Save}.
@findex delete-file
@cindex deletion (of files)
@cindex mode, Auto Compression
@pindex gzip
-@findex auto-compression-mode
-@vindex auto-compression-mode
- Emacs comes with a library that can automatically uncompress
-compressed files when you visit them, and automatically recompress them
-if you alter them and save them. To enable this feature, type the
-command @kbd{M-x auto-compression-mode}. You can enable it permanently
-by customizing the variable @code{auto-compression-mode}.
-
- When automatic compression (which implies automatic uncompression as
-well) is enabled, Emacs recognizes compressed files by their file names.
-File names ending in @samp{.gz} indicate a file compressed with
+ Emacs automatically uncompresses compressed files when you visit
+them, and automatically recompresses them if you alter them and save
+them. Emacs recognizes compressed files by their file names. File
+names ending in @samp{.gz} indicate a file compressed with
@code{gzip}. Other endings indicate other compression programs.
Automatic uncompression and compression apply to all the operations in
saving it, inserting its contents into a buffer, loading it, and byte
compiling it.
+@findex auto-compression-mode
+@vindex auto-compression-mode
+ To disable this feature, type the command @kbd{M-x
+auto-compression-mode}. You can disenable it permanently by
+customizing the variable @code{auto-compression-mode}.
+
@node File Archives
@section File Archives
@cindex mode, tar
@section Quoted File Names
@cindex quoting file names
+@cindex file names, quote special characters
You can @dfn{quote} an absolute file name to prevent special
characters and syntax in it from having their special effects.
The way to do this is to add @samp{/:} at the beginning.
@node File Conveniences
@section Convenience Features for Finding Files
+ In this section, we introduce some convenient facilities for finding
+recently-opened files, reading file names from a buffer, and viewing
+image files.
+
@findex recentf-mode
@vindex recentf-mode
@findex recentf-save-list
@code{recent-file-list} to a file, and @kbd{M-x recentf-edit-list}
edits it.
-@findex auto-image-file-mode
-@findex mode, auto-image-file
-@cindex images, visiting
-@cindex visiting image files
-@vindex image-file-name-regexps
-@vindex image-file-name-extensions
- When Auto-image-file minor mode is enabled, visiting an image file
-displays it as an image, not as text. Likewise, inserting an image
-file into a buffer inserts it as an image. This works only when Emacs
-can display the relevant image type. The variables
-@code{image-file-name-extensions} or @code{image-file-name-regexps}
-control which file names are recognized as containing images.
-
The @kbd{M-x ffap} command generalizes @code{find-file} with more
powerful heuristic defaults (@pxref{FFAP}), often based on the text at
point. Partial Completion mode offers other features extending
@code{find-file}, which can be used with @code{ffap}.
@xref{Completion Options}.
+@findex image-mode
+@findex image-toggle-display
+@cindex images, viewing
+ Visiting image files automatically selects Image mode. This major
+mode allows you to toggle between displaying the file as an image in
+the Emacs buffer, and displaying its underlying text representation,
+using the command @kbd{C-c C-c} (@code{image-toggle-display}). This
+works only when Emacs can display the specific image type.
+
+@findex thumbs-mode
+@findex mode, thumbs
+ Thumbs mode is a major mode for viewing directories containing many
+image files. To use it, type @kbd{M-x thumbs} and specify the
+directory to view. The images in that directory will be displayed in
+a @samp{Thumbs} buffer as @dfn{thumbnails}; type @kbd{RET} on a
+thumbnail to view the full-size image. Thumbs mode requires the
+@file{convert} program, which is part of the ImageMagick software
+package.
+
+@node Filesets
+@section Filesets
+@cindex filesets
+
+@findex filesets-init
+ If you regularly edit a certain group of files, you can define them
+as a @dfn{fileset}. This lets you perform certain operations, such as
+visiting, @code{query-replace}, and shell commands on all the files
+at once. To make use of filesets, you must first add the expression
+@code{(filesets-init)} to your @file{.emacs} file (@pxref{Init File}).
+This adds a @samp{Filesets} menu to the menu bar.
+
+@findex filesets-add-buffer
+@findex filesets-remove-buffer
+ The simplest way to define filesets is by adding files to them one
+at a time. To add a file to fileset @var{name}, visit the file and
+type @kbd{M-x filesets-add-buffer @kbd{RET} @var{name} @kbd{RET}}. If
+there is no fileset @var{name}, this creates a new one, which
+initially creates only the current file. The command @kbd{M-x
+filesets-remove-buffer} removes the current file from a fileset.
+
+ You can also edit the list of filesets directly, with @kbd{M-x
+filesets-edit} (or by choosing @samp{Edit Filesets} from the
+@samp{Filesets} menu). The editing is performed in a Customize buffer
+(@pxref{Easy Customization}). Filesets need not be a simple list of
+files---you can also define filesets using regular expression matching
+file names. Some examples of these more complicated filesets are
+shown in the Customize buffer. Remember to select @samp{Save for
+future sessions} if you want to use the same filesets in future Emacs
+sessions.
+
+ You can use the command @kbd{M-x filesets-open} to visit all the
+files in a fileset, and @kbd{M-x filesets-close} to close them. Use
+@kbd{M-x filesets-run-cmd} to run a shell command on all the files in
+a fileset. These commands are also available from the @samp{Filesets}
+menu, where each existing fileset is represented by a submenu.
+
@ignore
arch-tag: 768d32cb-e15a-4cc1-b7bf-62c00ee12250
@end ignore