]> code.delx.au - gnu-emacs/blobdiff - doc/emacs/files.texi
Implement CLASH_DETECTION for MS-Windows.
[gnu-emacs] / doc / emacs / files.texi
index a2a09cea11e2446d177afb2781d197ab74448f53..1f78747eaa6fbcdcccb98f6d8b9cf2ec7aec23fd 100644 (file)
@@ -1,9 +1,8 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
-@c   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2013 Free Software
+@c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
-@node Files, Buffers, Keyboard Macros, Top
+@node Files
 @chapter File Handling
 @cindex files
 
@@ -37,7 +36,7 @@ on file directories.
 * Misc File Ops::       Other things you can do on files.
 * Compressed Files::    Accessing compressed files.
 * File Archives::       Operating on tar, zip, jar etc. archive files.
-* Remote Files::        Accessing files on other sites.
+* Remote Files::        Accessing files on other machines.
 * 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.
@@ -48,56 +47,58 @@ on file directories.
 @section File Names
 @cindex file names
 
+@cindex default file name
   Many Emacs commands that operate on a file require you to specify
-the file name, using the minibuffer (@pxref{Minibuffer}).  You can use
-@dfn{completion} to specify long file names (@pxref{Completion}).
-Note that file name completion ignores file names whose extensions
-appear in the variable @code{completion-ignored-extensions}
-(@pxref{Completion Options}).
-
-  For most operations, there is a @dfn{default file name} which is
-used if you type just @key{RET} to enter an empty argument.  Normally,
-the default file name is the name of the file visited in the current
-buffer.
-
+the file name, using the minibuffer (@pxref{Minibuffer File}).
+
+  While in the minibuffer, you can use the usual completion and
+history commands (@pxref{Minibuffer}).  Note that file name completion
+ignores file names whose extensions appear in the variable
+@code{completion-ignored-extensions} (@pxref{Completion Options}).
+Note also that most commands use ``permissive completion with
+confirmation'' for reading file names: you are allowed to submit a
+nonexistent file name, but if you type @key{RET} immediately after
+completing up to a nonexistent file name, Emacs prints
+@samp{[Confirm]} and you must type a second @key{RET} to confirm.
+@xref{Completion Exit}, for details.
+
+@cindex default directory
 @vindex default-directory
 @vindex insert-default-directory
-  Each buffer has a @dfn{default directory} which is normally the same
-as the directory of the file visited in that buffer.  For example, if
-the default file name is @file{/u/rms/gnu/gnu.tasks}, the default
-directory is normally @file{/u/rms/gnu/}.  The default directory is
-kept in the variable @code{default-directory}, which has a separate
-value in every buffer.  When a command reads a file name using the
-minibuffer, the default directory usually serves as the initial
-contents of the minibuffer.  To inhibit the insertion of the default
-directory, set the variable @code{insert-default-directory} to
-@code{nil}.
+  Each buffer has a @dfn{default directory}, stored in the
+buffer-local variable @code{default-directory}.  Whenever Emacs reads
+a file name using the minibuffer, it usually inserts the default
+directory into the minibuffer as the initial contents.  You can
+inhibit this insertion by changing the variable
+@code{insert-default-directory} to @code{nil} (@pxref{Minibuffer
+File}).  Regardless, Emacs always assumes that any relative file name
+is relative to the default directory, e.g., entering a file name
+without a directory specifies a file in the default directory.
 
-  If you enter a file name without a directory, that specifies a file
-in the default directory.  If you specify a directory in a relative
-fashion, with a name that does not start with a slash, it is
-interpreted with respect to the default directory.  For example,
-suppose the default directory is @file{/u/rms/gnu/}.  Entering just
-@samp{foo} in the minibuffer, with a directory omitted, specifies the
-file @file{/u/rms/gnu/foo}; entering @samp{../.login} specifies
+@findex cd
+@findex pwd
+  When you visit a file, Emacs sets @code{default-directory} in the
+visiting buffer to the directory of its file.  When you create a new
+buffer that is not visiting a file, via a command like @kbd{C-x b},
+its default directory is usually copied from the buffer that was
+current at the time (@pxref{Select Buffer}).  You can use the command
+@kbd{M-x pwd} to see the value of @code{default-directory} in the
+current buffer.  The command @kbd{M-x cd} prompts for a directory
+name, and sets the buffer's @code{default-directory} to that directory
+(doing this does not change the buffer's file name, if any).
+
+  As an example, when you visit the file @file{/u/rms/gnu/gnu.tasks},
+the default directory is set to @file{/u/rms/gnu/}.  If you invoke a
+command that reads a file name, entering just @samp{foo} in the
+minibuffer, with a directory omitted, specifies the file
+@file{/u/rms/gnu/foo}; entering @samp{../.login} specifies
 @file{/u/rms/.login}; and entering @samp{new/foo} specifies
 @file{/u/rms/gnu/new/foo}.
 
   When typing a file name into the minibuffer, you can make use of a
 couple of shortcuts: a double slash is interpreted as ``ignore
-everything before the second slash in the pair,'' and @samp{~/} is
-interpreted as your home directory.  @xref{Minibuffer File}, for more
-information about these shortcuts.
-
-@findex cd
-@findex pwd
-  The command @kbd{M-x pwd} displays the default directory, and the
-command @kbd{M-x cd} sets it to a value read using the minibuffer.  A
-buffer's default directory changes only when the @code{cd} command is
-used.  A file-visiting buffer's default directory is initialized to
-the directory of the file it visits.  If you create a buffer with
-@kbd{C-x b}, its default directory is copied from that of the buffer
-that was current at the time (@pxref{Select Buffer}).
+everything before the second slash in the pair'', and @samp{~/} is
+interpreted as your home directory.  @xref{Minibuffer File}.
 
 @cindex environment variables in file names
 @cindex expansion of environment variables
@@ -112,10 +113,8 @@ the @samp{$}; alternatively, it can be enclosed in braces after the
 @file{/u/$@{FOO@}/test.c} are abbreviations for
 @file{/u/rms/hacks/test.c}.  If the environment variable is not
 defined, no substitution occurs, so that the character @samp{$} stands
-for itself.
-
-  Note that environment variables affect Emacs only if they are
-applied before Emacs is started.
+for itself.  Note that environment variables affect Emacs only if they
+are applied before Emacs is started.
 
   To access a file with @samp{$} in its name, if the @samp{$} causes
 expansion, type @samp{$$}.  This pair is converted to a single
@@ -124,8 +123,7 @@ a single @samp{$}.  Alternatively, quote the whole file name with
 @samp{/:} (@pxref{Quoted File Names}).  File names which begin with a
 literal @samp{~} should also be quoted with @samp{/:}.
 
-  You can include non-@acronym{ASCII} characters in file names if you set the
-variable @code{file-name-coding-system} to a non-@code{nil} value.
+  You can include non-@acronym{ASCII} characters in file names.
 @xref{File Name Coding}.
 
 @node Visiting
@@ -158,59 +156,57 @@ Visit a file with no conversion of the contents.
 buffer so you can edit them.  Emacs makes a new buffer for each file
 that you visit.
 
-  Emacs normally constructs the buffer name from the file name,
-omitting the directory name.  For example, a file named
-@file{/usr/rms/emacs.tex} is visited in a buffer named
-@samp{emacs.tex}.  If there is already a buffer with that name, Emacs
-constructs a unique name; the normal method is to append @samp{<2>},
-@samp{<3>}, and so on, but you can select other methods.
+@kindex C-x C-f
+@findex find-file
+  To visit a file, type @kbd{C-x C-f} (@code{find-file}) and use the
+minibuffer to enter the name of the desired file.  While in the
+minibuffer, you can abort the command by typing @kbd{C-g}.  @xref{File
+Names}, for details about entering file names into minibuffers.
+
+  If the specified file exists but the system does not allow you to
+read it, an error message is displayed in the echo area.  Otherwise,
+you can tell that @kbd{C-x C-f} has completed successfully by the
+appearance of new text on the screen, and by the buffer name shown in
+the mode line (@pxref{Mode Line}).  Emacs normally constructs the
+buffer name from the file name, omitting the directory name.  For
+example, a file named @file{/usr/rms/emacs.tex} is visited in a buffer
+named @samp{emacs.tex}.  If there is already a buffer with that name,
+Emacs constructs a unique name; the normal method is to append
+@samp{<2>}, @samp{<3>}, and so on, but you can select other methods.
 @xref{Uniquify}.
 
-  Each window's mode line shows the name of the buffer that is being
-displayed in that window, so you can always tell what buffer you are
-editing.  @pxref{Mode Line}.
-
-  The changes you make with editing commands are made in the Emacs
-buffer.  They do not take effect in the file that you visited, or any
-permanent place, until you @dfn{save} the buffer (@pxref{Saving}).
+@cindex creating files
+  To create a new file, just visit it using the same command, @kbd{C-x
+C-f}.  Emacs displays @samp{(New file)} in the echo area, but in other
+respects behaves as if you had visited an existing empty file.
 
 @cindex modified (buffer)
-  If a buffer contains changes that have not been saved, we say the
-buffer is @dfn{modified}.  This implies that some changes will be lost
-if the buffer is not saved.  The mode line displays two stars near the
-left margin to indicate that the buffer is modified.
-
-@kindex C-x C-f
-@findex find-file
-  To visit a file, type @kbd{C-x C-f} (@code{find-file}) and use the
-minibuffer to enter the name of the desired file.  The usual
-defaulting and completion behavior is available in this minibuffer
-(@pxref{Minibuffer File}).  Note, also, that completion ignores
-certain file names (@pxref{Completion Options}).  While in the
-minibuffer, you can abort @kbd{C-x C-f} by typing @kbd{C-g}.
-
-  Your can tell that @kbd{C-x C-f} has completed successfully by the
-appearance of new text on the screen and a new buffer name in the mode
-line.  If the specified file does not exist and you could not create
-it, or exists but you can't read it, an error message is displayed in
-the echo area.
-
-  If you visit a file that is already in Emacs, @kbd{C-x C-f} does not make
-another copy.  It selects the existing buffer containing that file.
-However, before doing so, it checks whether the file itself has changed
-since you visited or saved it last.  If the file has changed, Emacs offers
-to reread it.
+  After visiting a file, the changes you make with editing commands are
+made in the Emacs buffer.  They do not take effect in the visited
+file, until you @dfn{save} the buffer (@pxref{Saving}).  If a buffer
+contains changes that have not been saved, we say the buffer is
+@dfn{modified}.  This implies that some changes will be lost if the
+buffer is not saved.  The mode line displays two stars near the left
+margin to indicate that the buffer is modified.
+
+  If you visit a file that is already in Emacs, @kbd{C-x C-f} switches
+to the existing buffer instead of making another copy.  Before doing
+so, it checks whether the file has changed since you last visited or
+saved it.  If the file has changed, Emacs offers to reread it.
 
 @vindex large-file-warning-threshold
+@cindex file, warning when size is large
+@cindex size of file, warning when visiting
 @cindex maximum buffer size exceeded, error message
   If you try to visit a file larger than
 @code{large-file-warning-threshold} (the default is 10000000, which is
 about 10 megabytes), Emacs asks you for confirmation first.  You can
 answer @kbd{y} to proceed with visiting the file.  Note, however, that
 Emacs cannot visit files that are larger than the maximum Emacs buffer
-size, which is around 512 megabytes on 32-bit machines
-(@pxref{Buffers}).  If you try, Emacs will display an error message
-saying that the maximum buffer size has been exceeded.
+size, which is limited by the amount of memory Emacs can allocate and
+by the integers that Emacs can represent (@pxref{Buffers}).  If you
+try, Emacs displays an error message saying that the maximum buffer
+size has been exceeded.
 
 @cindex wildcard characters in file names
 @vindex find-file-wildcards
@@ -224,63 +220,21 @@ 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}.
 
-@cindex file selection dialog
-  On graphical displays, there are two additional methods for visiting
-files.  Firstly, when Emacs is built with a suitable GUI toolkit,
-commands invoked with the mouse (by clicking on the menu bar or tool
-bar) use the toolkit's standard ``File Selection'' dialog instead of
-prompting for the file name in the minibuffer.  On GNU/Linux and Unix
-platforms, Emacs does this when built with GTK, LessTif, and Motif
-toolkits; on MS-Windows and Mac, the GUI version does that by default.
-For information on how to customize this, see @ref{Dialog Boxes}.
-
-  Secondly, Emacs supports ``drag and drop'': dropping a file into an
-ordinary Emacs window visits the file using that window.  As an
-exception, dropping a file into a window displaying a Dired buffer
-moves or copies the file into the displayed directory.  For details,
-see @ref{Drag and Drop}, and @ref{Misc Dired Features}.
-
-@cindex creating files
-  What if you want to create a new file?  Just visit it.  Emacs
-displays @samp{(New file)} in the echo area, but in other respects
-behaves as if you had visited an existing empty file.  If you make
-changes and save them, the file is created.
-
-@cindex minibuffer confirmation
-@cindex confirming in the minibuffer
-@vindex confirm-nonexistent-file-or-buffer
-  When @key{TAB} completion results in a nonexistent file name and you
-type @key{RET} immediately to visit it, Emacs asks for confirmation;
-this is because it's possible that you expected completion to go
-further and give you an existing file's name.  The string
-@samp{[Confirm]} appears for a short time after the file name to
-indicate the need to confirm in this way.  Type @key{RET} to confirm
-and visit the nonexistent file.  The variable
-@code{confirm-nonexistent-file-or-buffer} controls whether Emacs asks
-for confirmation before visiting a new file.  The default value,
-@code{after-completion}, gives the behavior we have just described.
-If the value is @code{nil}, Emacs never asks for confirmation; for any
-other non-@code{nil} value, Emacs always asks for confirmation.  This
-variable also affects the @code{switch-to-buffer} command
-(@pxref{Select Buffer}).  @xref{Completion}, for more information
-about completion.
-
 @kindex C-x C-v
 @findex find-alternate-file
-  If you visit a nonexistent file unintentionally (because you typed
-the wrong file name), type @kbd{C-x C-v} (@code{find-alternate-file})
-to visit the file you really wanted.  @kbd{C-x C-v} is similar to
-@kbd{C-x C-f}, but it kills the current buffer (after first offering
-to save it if it is modified).  When @kbd{C-x C-v} reads the file name
-to visit, it inserts the entire default file name in the buffer, with
-point just after the directory part; this is convenient if you made a
-slight error in typing the name.
+  If you visit the wrong file unintentionally by typing its name
+incorrectly, type @kbd{C-x C-v} (@code{find-alternate-file}) to visit
+the file you really wanted.  @kbd{C-x C-v} is similar to @kbd{C-x
+C-f}, but it kills the current buffer (after first offering to save it
+if it is modified).  When @kbd{C-x C-v} reads the file name to visit,
+it inserts the entire default file name in the buffer, with point just
+after the directory part; this is convenient if you made a slight
+error in typing the name.
 
 @vindex find-file-run-dired
   If you ``visit'' a file that is actually a directory, Emacs invokes
-Dired, the Emacs directory browser; this lets you ``edit'' the
-contents of the directory.  @xref{Dired}.  You can disable this
-behavior by setting the variable @code{find-file-run-dired} to
+Dired, the Emacs directory browser.  @xref{Dired}.  You can disable
+this behavior by setting the variable @code{find-file-run-dired} to
 @code{nil}; in that case, it is an error to try to visit a directory.
 
   Files which are actually collections of other files, or @dfn{file
@@ -292,7 +246,7 @@ Archives}, for more about these features.
 or that is marked read-only, Emacs makes the buffer read-only too, so
 that you won't go ahead and make changes that you'll have trouble
 saving afterward.  You can make the buffer writable with @kbd{C-x C-q}
-(@code{toggle-read-only}).  @xref{Misc Buffer}.
+(@code{read-only-mode}).  @xref{Misc Buffer}.
 
 @kindex C-x C-r
 @findex find-file-read-only
@@ -313,28 +267,39 @@ newly requested file.  @xref{Windows}.
 @kindex C-x 5 f
 @findex find-file-other-frame
   @kbd{C-x 5 f} (@code{find-file-other-frame}) is similar, but opens a
-new frame, or makes visible any existing frame showing the file you
-seek.  This feature is available only when you are using a window
-system.  @xref{Frames}.
-
-  Emacs recognizes from the contents of a file which end-of-line
-convention it uses to separate lines---newline (used on GNU/Linux and
-on Unix), carriage-return linefeed (used on Microsoft systems), or
-just carriage-return (used on the Macintosh)---and automatically
-converts the contents to the normal Emacs convention, which is that
-the newline character separates lines.  This is a part of the general
-feature of coding system conversion (@pxref{Coding Systems}), and
-makes it possible to edit files imported from different operating
-systems with equal convenience.  If you change the text and save the
-file, Emacs performs the inverse conversion, changing newlines back
-into carriage-return linefeed or just carriage-return if appropriate.
+new frame, or selects any existing frame showing the specified file.
+@xref{Frames}.
+
+@cindex file selection dialog
+  On graphical displays, there are two additional methods for visiting
+files.  Firstly, when Emacs is built with a suitable GUI toolkit,
+commands invoked with the mouse (by clicking on the menu bar or tool
+bar) use the toolkit's standard ``File Selection'' dialog instead of
+prompting for the file name in the minibuffer.  On GNU/Linux and Unix
+platforms, Emacs does this when built with GTK, LessTif, and Motif
+toolkits; on MS-Windows and Mac, the GUI version does that by default.
+For information on how to customize this, see @ref{Dialog Boxes}.
+
+  Secondly, Emacs supports ``drag and drop'': dropping a file into an
+ordinary Emacs window visits the file using that window.  As an
+exception, dropping a file into a window displaying a Dired buffer
+moves or copies the file into the displayed directory.  For details,
+see @ref{Drag and Drop}, and @ref{Misc Dired Features}.
+
+  Each time you visit a file, Emacs automatically scans its contents
+to detect what character encoding and end-of-line convention it uses,
+and converts these to Emacs's internal encoding and end-of-line
+convention within the buffer.  When you save the buffer, Emacs
+performs the inverse conversion, writing the file to disk with its
+original encoding and end-of-line convention.  @xref{Coding Systems}.
 
 @findex find-file-literally
   If you wish to edit a file as a sequence of @acronym{ASCII}
 characters with no special encoding or conversion, use the @kbd{M-x
 find-file-literally} command.  This visits a file, like @kbd{C-x C-f},
-but does not do format conversion (@pxref{Formatted Text}), character
-code conversion (@pxref{Coding Systems}), or automatic uncompression
+but does not do format conversion (@pxref{Format Conversion,, Format
+Conversion, elisp, the Emacs Lisp Reference Manual}), character code
+conversion (@pxref{Coding Systems}), or automatic uncompression
 (@pxref{Compressed Files}), and does not add a final newline because
 of @code{require-final-newline} (@pxref{Customize Save}).  If you have
 already visited the same file in the usual (non-literal) manner, this
@@ -342,17 +307,17 @@ command asks you whether to visit it literally instead.
 
 @vindex find-file-hook
 @vindex find-file-not-found-functions
-  Two special hook variables allow extensions to modify the operation of
-visiting files.  Visiting a file that does not exist runs the functions
-in the list @code{find-file-not-found-functions}; this variable holds a list
-of functions, and the functions are called one by one (with no
-arguments) until one of them returns non-@code{nil}.  This is not a
-normal hook, and the name ends in @samp{-functions} rather than @samp{-hook}
-to indicate that fact.
+  Two special hook variables allow extensions to modify the operation
+of visiting files.  Visiting a file that does not exist runs the
+functions in @code{find-file-not-found-functions}; this variable holds
+a list of functions, which are called one by one (with no arguments)
+until one of them returns non-@code{nil}.  This is not a normal hook,
+and the name ends in @samp{-functions} rather than @samp{-hook} to
+indicate that fact.
 
   Successful visiting of any file, whether existing or not, calls the
-functions in the list @code{find-file-hook}, with no arguments.
-This variable is a normal hook.  In the case of a nonexistent file, the
+functions in @code{find-file-hook}, with no arguments.  This variable
+is a normal hook.  In the case of a nonexistent file, the
 @code{find-file-not-found-functions} are run first.  @xref{Hooks}.
 
   There are several ways to specify automatically the major mode for
@@ -382,9 +347,9 @@ that was visited in the buffer.
 
 @table @kbd
 @item C-x C-s
-Save the current buffer in its visited file on disk (@code{save-buffer}).
+Save the current buffer to its file (@code{save-buffer}).
 @item C-x s
-Save any or all buffers in their visited files (@code{save-some-buffers}).
+Save any or all buffers to their files (@code{save-some-buffers}).
 @item M-~
 Forget that the current buffer has been changed (@code{not-modified}).
 With prefix argument (@kbd{C-u}), mark the current buffer as changed.
@@ -405,10 +370,10 @@ Wrote /u/rms/gnu/gnu.tasks
 @end example
 
 @noindent
-If the selected buffer is not modified (no changes have been made in it
-since the buffer was created or last saved), saving is not really done,
-because it would have no effect.  Instead, @kbd{C-x C-s} displays a message
-like this in the echo area:
+If the current buffer is not modified (no changes have been made in it
+since the buffer was created or last saved), saving is not really
+done, because it would have no effect.  Instead, @kbd{C-x C-s}
+displays a message like this in the echo area:
 
 @example
 (No changes need to be saved)
@@ -593,8 +558,8 @@ Never make numbered backups; always make single backups.
 @end table
 
 @noindent
-The usual way to set this variable is globally, through your
-@file{.emacs} file or the customization buffer.  However, you can set
+The usual way to set this variable is globally, through your init file
+or the customization buffer.  However, you can set
 @code{version-control} locally in an individual buffer to control the
 making of backups for that buffer's file (@pxref{Locals}).  You can
 have Emacs set @code{version-control} locally whenever you visit a
@@ -675,34 +640,38 @@ and group.  If copying is used, these do not change.  If renaming is used,
 you become the file's owner, and the file's group becomes the default
 (different operating systems have different defaults for the group).
 
-  Having the owner change is usually a good idea, because then the owner
-always shows who last edited the file.  Also, the owners of the backups
-show who produced those versions.  Occasionally there is a file whose
-owner should not change; it is a good idea for such files to contain
-local variable lists to set @code{backup-by-copying-when-mismatch}
-locally (@pxref{File Variables}).
-
 @vindex backup-by-copying
 @vindex backup-by-copying-when-linked
 @vindex backup-by-copying-when-mismatch
 @vindex backup-by-copying-when-privileged-mismatch
 @cindex file ownership, and backup
 @cindex backup, and user-id
-  The choice of renaming or copying is controlled by four variables.
-Renaming is the default choice.  If the variable
-@code{backup-by-copying} is non-@code{nil}, copying is used.  Otherwise,
-if the variable @code{backup-by-copying-when-linked} is non-@code{nil},
-then copying is used for files that have multiple names, but renaming
-may still be used when the file being edited has only one name.  If the
-variable @code{backup-by-copying-when-mismatch} is non-@code{nil}, then
-copying is used if renaming would cause the file's owner or group to
-change.  @code{backup-by-copying-when-mismatch} is @code{t} by default
-if you start Emacs as the superuser.  The fourth variable,
-@code{backup-by-copying-when-privileged-mismatch}, gives the highest
-numeric user-id for which @code{backup-by-copying-when-mismatch} will be
-forced on.  This is useful when low-numbered user-ids are assigned to
-special system users, such as @code{root}, @code{bin}, @code{daemon},
-etc., which must maintain ownership of files.
+  The choice of renaming or copying is made as follows:
+
+@itemize
+@item
+If the variable @code{backup-by-copying} is non-@code{nil} (the
+default is @code{nil}), use copying.
+
+@item
+Otherwise, if the variable @code{backup-by-copying-when-linked} is
+non-@code{nil} (the default is @code{nil}), and the file has multiple
+names, use copying.
+
+@item
+Otherwise, if the variable @code{backup-by-copying-when-mismatch} is
+non-@code{nil} (the default is @code{t}), and renaming would change
+the file's owner or group, use copying.
+
+If you change @code{backup-by-copying-when-mismatch} to @code{nil},
+Emacs checks the numeric user-id of the file's owner.  If this is
+higher than @code{backup-by-copying-when-privileged-mismatch}, then it
+behaves as though @code{backup-by-copying-when-mismatch} is
+non-@code{nil} anyway.
+
+@item
+Otherwise, renaming is the default choice.
+@end itemize
 
   When a file is managed with a version control system (@pxref{Version
 Control}), Emacs does not normally make backups in the usual way for
@@ -721,28 +690,28 @@ Emacs---the version control system does it.
 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
+can undo it.)  If the value is @code{visit-save}, Emacs adds such
 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
+Emacs leaves the end of the file unchanged; any other non-@code{nil}
+value means to 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.
+  Some major modes are designed for specific kinds of files that are
+always supposed to end in newlines.  Such major modes set the variable
+@code{require-final-newline} to the value of
+@code{mode-require-final-newline}, which defaults to @code{t}.  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.
+disruptive on laptops using power saving, as it may force a disk
+spin-up each time you save a file.  If you accept an increased risk of
+data loss, you can set @code{write-region-inhibit-fsync} to a
+non-@code{nil} value to disable the synchronization.
 
 @node Interlocking
 @subsection Protection against Simultaneous Editing
@@ -750,9 +719,9 @@ loss.
 @cindex file dates
 @cindex simultaneous editing
   Simultaneous editing occurs when two users visit the same file, both
-make changes, and then both save them.  If nobody were informed that
-this was happening, whichever user saved first would later find that his
-changes were lost.
+make changes, and then both save them.  If nobody is informed that
+this is happening, whichever user saves first would later find that
+his changes were lost.
 
   On some systems, Emacs notices immediately when the second user starts
 to change the file, and issues an immediate warning.  On all systems,
@@ -765,10 +734,15 @@ file.
 @cindex locking files
   When you make the first modification in an Emacs buffer that is
 visiting a file, Emacs records that the file is @dfn{locked} by you.
-(It does this by creating a specially-named symbolic link in the same
-directory.)  Emacs removes the lock when you save the changes.  The
-idea is that the file is locked whenever an Emacs buffer visiting it
-has unsaved changes.
+(It does this by creating a specially-named symbolic link or regular
+file with special contents in the same directory.)  Emacs removes the
+lock when you save the changes.  The idea is that the file is locked
+whenever an Emacs buffer visiting it has unsaved changes.
+
+@vindex create-lockfiles
+  You can prevent the creation of lock files by setting the variable
+@code{create-lockfiles} to @code{nil}.  @strong{Caution:} by
+doing so you will lose the benefits that this feature provides.
 
 @cindex collision
   If you begin to modify the buffer while the visited file is locked by
@@ -790,38 +764,28 @@ contents remain unchanged---the modification you were trying to make
 does not actually take place.
 @end table
 
-  Note that locking works on the basis of a file name; if a file has
-multiple names, Emacs does not realize that the two names are the same file
-and cannot prevent two users from editing it simultaneously under different
-names.  However, basing locking on names means that Emacs can interlock the
-editing of new files that will not really exist until they are saved.
-
-  Some systems are not configured to allow Emacs to make locks, and
-there are cases where lock files cannot be written.  In these cases,
-Emacs cannot detect trouble in advance, but it still can detect the
-collision when you try to save a file and overwrite someone else's
-changes.  Every time Emacs saves a buffer, it first checks the
-last-modification date of the existing file on disk to verify that it
-has not changed since the file was last visited or saved.  If the date
-does not match, it implies that changes were made in the file in some
-other way, and these changes are about to be lost if Emacs actually
-does save.  To prevent this, Emacs displays a warning message and asks
-for confirmation before saving.  Occasionally you will know why the
-file was changed and know that it does not matter; then you can answer
-@kbd{yes} and proceed.  Otherwise, you should cancel the save with
-@kbd{C-g} and investigate the situation.
-
   If Emacs or the operating system crashes, this may leave behind lock
 files which are stale, so you may occasionally get warnings about
-spurious collisions.  When you determine that the collision is spurious,
-just use @kbd{p} to tell Emacs to go ahead anyway.
+spurious collisions.  When you determine that the collision is
+spurious, just use @kbd{p} to tell Emacs to go ahead anyway.
 
-  The first thing you should do when notified that simultaneous editing
-has already taken place is to list the directory with @kbd{C-u C-x C-d}
-(@pxref{Directories}).  This shows the file's current author.  You
-should attempt to contact him to warn him not to continue editing.
-Often the next step is to save the contents of your Emacs buffer under a
-different name, and use @code{diff} to compare the two files.@refill
+  Note that locking works on the basis of a file name; if a file has
+multiple names, Emacs does not prevent two users from editing it
+simultaneously under different names.
+
+  A lock file cannot be written in some circumstances, e.g., if Emacs
+lacks the system permissions or cannot create lock files for some
+other reason.  In these cases, Emacs can still detect the collision
+when you try to save a file, by checking the file's last-modification
+date.  If the file has changed since the last time Emacs visited or
+saved it, that implies that changes have been made in some other way,
+and will be lost if Emacs proceeds with saving.  Emacs then displays a
+warning message and asks for confirmation before saving; answer
+@kbd{yes} to save, and @kbd{no} or @kbd{C-g} cancel the save.
+
+  If you are notified that simultaneous editing has already taken
+place, one way to compare the buffer to its file is the @kbd{M-x
+diff-buffer-with-file} command.  @xref{Comparing Files}.
 
 @node File Shadowing
 @subsection Shadowing Files
@@ -877,10 +841,10 @@ shadow-define-cluster}.
 @cindex modification dates
 @cindex locale, date format
 
-You can arrange to put a time stamp in a file, so that it will be updated
+You can arrange to put a time stamp in a file, so that it is updated
 automatically each time you edit and save the file.  The time stamp
-has to be in the first eight lines of the file, and you should
-insert it like this:
+must be in the first eight lines of the file, and you should insert it
+like this:
 
 @example
 Time-stamp: <>
@@ -894,13 +858,13 @@ Time-stamp: " "
 @end example
 
 @findex time-stamp
-  Then add the hook function @code{time-stamp} to the hook
-@code{before-save-hook}; that hook function will automatically update
-the time stamp, inserting the current date and time when you save the
-file.  You can also use the command @kbd{M-x time-stamp} to update the
-time stamp manually.  For other customizations, see the Custom group
-@code{time-stamp}.  Note that non-numeric fields in the time stamp are
-formatted according to your locale setting (@pxref{Environment}).
+  Then add the function @code{time-stamp} to the hook
+@code{before-save-hook} (@pxref{Hooks}).  When you save the file, this
+function then automatically updates the time stamp with the current
+date and time.  You can also use the command @kbd{M-x time-stamp} to
+update the time stamp manually.  For other customizations, see the
+Custom group @code{time-stamp}.  Note that the time stamp is formatted
+according to your locale setting (@pxref{Environment}).
 
 @node Reverting
 @section Reverting a Buffer
@@ -908,18 +872,21 @@ formatted according to your locale setting (@pxref{Environment}).
 @cindex drastic changes
 @cindex reread a file
 
-  If you have made extensive changes to a file and then change your mind
-about them, you can get rid of them by reading in the previous version
-of the file.  To do this, use @kbd{M-x revert-buffer}, which operates on
-the current buffer.  Since reverting a buffer unintentionally could lose
-a lot of work, you must confirm this command with @kbd{yes}.
+  If you have made extensive changes to a file-visiting buffer and
+then change your mind, you can @dfn{revert} the changes and go back to
+the saved version of the file.  To do this, type @kbd{M-x
+revert-buffer}.  Since reverting unintentionally could lose a lot of
+work, Emacs asks for confirmation first.
 
-  @code{revert-buffer} tries to position point in such a way that, if
-the file was edited only slightly, you will be at approximately the
-same piece of text after reverting as before.  However, if you have made
-drastic changes, point may wind up in a totally different piece of text.
+  The @code{revert-buffer} command tries to position point in such a
+way that, if the file was edited only slightly, you will be at
+approximately the same part of the text as before.  But if you have
+made major changes, point may end up in a totally different location.
 
-  Reverting marks the buffer as ``not modified''.
+  Reverting marks the buffer as ``not modified''.  It also clears the
+buffer's undo history (@pxref{Undo}).  Thus, the reversion cannot be
+undone---if you change your mind yet again, you can't use the undo
+commands to bring the reverted changes back.
 
   Some kinds of buffers that are not associated with files, such as
 Dired buffers, can also be reverted.  For them, reverting means
@@ -946,15 +913,14 @@ discard your changes.)
 @findex auto-revert-mode
 @findex auto-revert-tail-mode
 @vindex auto-revert-interval
-
-  In addition, you can tell Emacs to periodically revert a buffer by
-typing @kbd{M-x auto-revert-mode}.  This turns on Auto-Revert mode, a
-minor mode that makes Emacs automatically revert the current buffer
-every five seconds.  You can change this interval through the variable
-@code{auto-revert-interval}.  Typing @kbd{M-x global-auto-revert-mode}
-enables Global Auto-Revert mode, which does the same for all file
-buffers.  Auto-Revert mode and Global Auto-Revert modes do not check
-or revert remote files, because that is usually too slow.
+  You can also tell Emacs to revert buffers periodically.  To do this
+for a specific buffer, enable the minor mode Auto-Revert mode by
+typing @kbd{M-x auto-revert-mode}.  This automatically reverts the
+current buffer every five seconds; you can change the interval through
+the variable @code{auto-revert-interval}.  To do the same for all file
+buffers, type @kbd{M-x global-auto-revert-mode} to enable Global
+Auto-Revert mode.  These minor modes do not check or revert remote
+files, because that is usually too slow.
 
   One use of Auto-Revert mode is to ``tail'' a file such as a system
 log, so that changes made to that file by other programs are
@@ -965,8 +931,9 @@ the end, use Auto-Revert Tail mode instead
 (@code{auto-revert-tail-mode}).  It is more efficient for this.
 Auto-Revert Tail mode works also for remote files.
 
-  @xref{VC Mode Line}, for Auto Revert peculiarities in buffers that
-visit files under version control.
+  @xref{VC Undo}, for commands to revert to earlier versions of files
+under version control.  @xref{VC Mode Line}, for Auto Revert
+peculiarities when visiting files under version control.
 
 @ifnottex
 @include arevert-xtra.texi
@@ -1014,7 +981,7 @@ are not visiting files are auto-saved only if you request it explicitly;
 when they are auto-saved, the auto-save file name is made by appending
 @samp{#} to the front and rear of buffer name, then
 adding digits and letters at the end for uniqueness.  For
-example, the @samp{*mail*} buffer in which you compose messages to be
+example, the @file{*mail*} buffer in which you compose messages to be
 sent might be auto-saved in a file named @file{#*mail*#704juu}.  Auto-save file
 names are made this way unless you reprogram parts of Emacs to do
 something different (the functions @code{make-auto-save-file-name} and
@@ -1057,40 +1024,41 @@ any auto-save file to go with the new visited name.
 @vindex auto-save-default
 @findex auto-save-mode
   Each time you visit a file, auto-saving is turned on for that file's
-buffer if the variable @code{auto-save-default} is non-@code{nil} (but not
-in batch mode; @pxref{Entering Emacs}).  The default for this variable is
-@code{t}, so auto-saving is the usual practice for file-visiting buffers.
-Auto-saving can be turned on or off for any existing buffer with the
-command @kbd{M-x auto-save-mode}.  Like other minor mode commands, @kbd{M-x
-auto-save-mode} turns auto-saving on with a positive argument, off with a
-zero or negative argument; with no argument, it toggles.
+buffer if the variable @code{auto-save-default} is non-@code{nil} (but
+not in batch mode; @pxref{Initial Options}).  The default for this
+variable is @code{t}, so auto-saving is the usual practice for
+file-visiting buffers.  To toggle auto-saving in the current buffer,
+type @kbd{M-x auto-save-mode}.  Auto Save mode acts as a buffer-local
+minor mode (@pxref{Minor Modes}).
 
 @vindex auto-save-interval
-  Emacs does auto-saving periodically based on counting how many characters
-you have typed since the last time auto-saving was done.  The variable
-@code{auto-save-interval} specifies how many characters there are between
-auto-saves.  By default, it is 300.  Emacs doesn't accept values that are
-too small: if you customize @code{auto-save-interval} to a value less
-than 20, Emacs will behave as if the value is 20.
+  Emacs auto-saves periodically based on how many characters you have
+typed since the last auto-save.  The variable
+@code{auto-save-interval} specifies how many characters there are
+between auto-saves.  By default, it is 300.  Emacs doesn't accept
+values that are too small: if you customize @code{auto-save-interval}
+to a value less than 20, Emacs will behave as if the value is 20.
 
 @vindex auto-save-timeout
-  Auto-saving also takes place when you stop typing for a while.  The
-variable @code{auto-save-timeout} says how many seconds Emacs should
-wait before it does an auto save (and perhaps also a garbage
-collection).  (The actual time period is longer if the current buffer is
-long; this is a heuristic which aims to keep out of your way when you
-are editing long buffers, in which auto-save takes an appreciable amount
-of time.)  Auto-saving during idle periods accomplishes two things:
-first, it makes sure all your work is saved if you go away from the
-terminal for a while; second, it may avoid some auto-saving while you
-are actually typing.
+  Auto-saving also takes place when you stop typing for a while.  By
+default, it does this after 30 seconds of idleness (at this time,
+Emacs may also perform garbage collection; @pxref{Garbage
+Collection,,, elisp, The Emacs Lisp Reference Manual}).  To change
+this interval, customize the variable @code{auto-save-timeout}.  The
+actual time period is longer if the current buffer is long; this is a
+heuristic which aims to keep out of your way when you are editing long
+buffers, in which auto-save takes an appreciable amount of time.
+Auto-saving during idle periods accomplishes two things: first, it
+makes sure all your work is saved if you go away from the terminal for
+a while; second, it may avoid some auto-saving while you are actually
+typing.
 
   Emacs also does auto-saving whenever it gets a fatal error.  This
 includes killing the Emacs job with a shell command such as @samp{kill
 %emacs}, or disconnecting a phone line or network connection.
 
 @findex do-auto-save
-  You can request an auto-save explicitly with the command @kbd{M-x
+  You can perform an auto-save explicitly with the command @kbd{M-x
 do-auto-save}.
 
 @node Recover
@@ -1133,14 +1101,12 @@ recover are present in Emacs buffers.  You should then save them.  Only
 this---saving them---updates the files themselves.
 
 @vindex auto-save-list-file-prefix
-  Emacs records information about interrupted sessions for later
-recovery in files named
-@file{~/.emacs.d/auto-save-list/.saves-@var{pid}-@var{hostname}}.  The
-directory used, @file{~/.emacs.d/auto-save-list/}, is determined by
-the variable @code{auto-save-list-file-prefix}.  You can record
-sessions in a different place by customizing that variable.  If you
-set @code{auto-save-list-file-prefix} to @code{nil} in your
-@file{.emacs} file, sessions are not recorded for recovery.
+  Emacs records information about interrupted sessions in files named
+@file{.saves-@var{pid}-@var{hostname}} in the directory
+@file{~/.emacs.d/auto-save-list/}.  This directory is determined by
+the variable @code{auto-save-list-file-prefix}.  If you set
+@code{auto-save-list-file-prefix} to @code{nil}, sessions are not
+recorded for recovery.
 
 @node File Aliases
 @section File Name Aliases
@@ -1270,11 +1236,11 @@ this, it runs the program specified by
   The command @kbd{M-x delete-directory} prompts for a directory name
 using the minibuffer, and deletes the directory if it is empty.  If
 the directory is not empty, you will be asked whether you want to
-delete it recursively.  On systems that have a ``Trash'' or ``Recycle
-Bin'' feature, you can make this command move the specified directory
-to the Trash or Recycle Bin, instead of deleting it outright, by
-changing the variable @code{delete-by-moving-to-trash} to @code{t}.
-@xref{Misc File Ops}, for more information about using the Trash.
+delete it recursively.  On systems that have a ``Trash'' (or ``Recycle
+Bin'') feature, you can make this command move the specified directory
+to the Trash instead of deleting it outright, by changing the variable
+@code{delete-by-moving-to-trash} to @code{t}.  @xref{Misc File Ops},
+for more information about using the Trash.
 
 @node Comparing Files
 @section Comparing Files
@@ -1284,12 +1250,12 @@ changing the variable @code{delete-by-moving-to-trash} to @code{t}.
 @vindex diff-switches
   The command @kbd{M-x diff} prompts for two file names, using the
 minibuffer, and displays the differences between the two files in a
-buffer named @samp{*diff*}.  This works by running the @command{diff}
+buffer named @file{*diff*}.  This works by running the @command{diff}
 program, using options taken from the variable @code{diff-switches}.
 The value of @code{diff-switches} should be a string; the default is
 @code{"-c"} to specify a context diff.  @xref{Top,, Diff, diff,
-Comparing and Merging Files}, for more information about
-@command{diff} output formats.
+Comparing and Merging Files}, for more information about the
+@command{diff} program.
 
   The output of the @code{diff} command is shown using a major mode
 called Diff mode.  @xref{Diff Mode}.
@@ -1357,11 +1323,10 @@ merging files.
 @cindex patches, editing
 
   Diff mode is a major mode used for the output of @kbd{M-x diff} and
-other similar commands, as well as the output of the @command{diff}
-program.  This kind of output is called a @dfn{patch}, because it can
-be passed to the @command{patch} command to automatically apply the
-specified changes.  To select Diff mode manually, type @kbd{M-x
-diff-mode}.
+other similar commands.  This kind of output is called a @dfn{patch},
+because it can be passed to the @command{patch} command to
+automatically apply the specified changes.  To select Diff mode
+manually, type @kbd{M-x diff-mode}.
 
 @cindex hunk, diff
   The changes specified in a patch are grouped into @dfn{hunks}, which
@@ -1376,11 +1341,11 @@ contents of the hunk.
   You can edit a Diff mode buffer like any other buffer.  (If it is
 read-only, you need to make it writable first.  @xref{Misc Buffer}.)
 Whenever you change a hunk, Diff mode attempts to automatically
-correct the line numbers in the hunk headers, to ensure that the diff
+correct the line numbers in the hunk headers, to ensure that the patch
 remains ``correct''.  To disable automatic line number correction,
 change the variable @code{diff-update-on-the-fly} to @code{nil}.
 
-  Diff mode treats each hunk as an ``error message,'' similar to
+  Diff mode treats each hunk as an ``error message'', similar to
 Compilation mode.  Thus, you can use commands such as @kbd{C-x '} to
 visit the corresponding source locations.  @xref{Compilation Mode}.
 
@@ -1392,9 +1357,25 @@ manipulate and apply parts of patches:
 @findex diff-hunk-next
 Move to the next hunk-start (@code{diff-hunk-next}).
 
+@findex diff-auto-refine-mode
+@cindex mode, Diff Auto-Refine
+@cindex Diff Auto-Refine mode
+This command has a side effect: it @dfn{refines} the hunk you move to,
+highlighting its changes with better granularity.  To disable this
+feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor
+mode Diff Auto-Refine mode.  To disable Diff Auto Refine mode by
+default, add this to your init file (@pxref{Hooks}):
+
+@example
+(add-hook 'diff-mode-hook
+          (lambda () (diff-auto-refine-mode -1)))
+@end example
+
 @item M-p
 @findex diff-hunk-prev
-Move to the previous hunk-start (@code{diff-hunk-prev}).
+Move to the previous hunk-start (@code{diff-hunk-prev}).  Like
+@kbd{M-n}, this has the side-effect of refining the hunk you move to,
+unless you disable Diff Auto-Refine mode.
 
 @item M-@}
 @findex diff-file-next
@@ -1487,13 +1468,24 @@ descriptions of the changes.  @kbd{C-x 4 a} itself in Diff mode
 operates on behalf of the current hunk's file, but gets the function
 name from the patch itself.  This is useful for making log entries for
 functions that are deleted by the patch.
-
-@item M-x diff-show-trailing-whitespaces RET
-@findex diff-show-trailing-whitespaces
-Highlight trailing whitespace characters, except for those used by the
-patch syntax (@pxref{Useless Whitespace}).
 @end table
 
+@c Trailing whitespace is NOT shown by default.
+@c Emacs's dir-locals file enables this (for some reason).
+@cindex trailing whitespace, in patches
+@findex diff-delete-trailing-whitespace
+  Patches sometimes include trailing whitespace on modified lines, as
+an unintentional and undesired change.  There are two ways to deal
+with this problem.  Firstly, if you enable Whitespace mode in a Diff
+buffer (@pxref{Useless Whitespace}), it automatically highlights
+trailing whitespace in modified lines.  Secondly, you can use the
+command @kbd{M-x diff-delete-trailing-whitespace}, which searches for
+trailing whitespace in the lines modified by the patch, and removes
+that whitespace in both the patch and the patched source file(s).
+This command does not save the modifications that it makes, so you can
+decide whether to save the changes (the list of modified files is
+displayed in the echo area).  With a prefix argument, it tries to
+modify the original source files rather than the patched source files.
 
 @node Misc File Ops
 @section Miscellaneous File Operations
@@ -1501,23 +1493,90 @@ patch syntax (@pxref{Useless Whitespace}).
   Emacs has commands for performing many other operations on files.
 All operate on one file; they do not accept wildcard file names.
 
-@findex view-file
-@cindex viewing
-@cindex View mode
-@cindex mode, View
-  @kbd{M-x view-file} allows you to scan or read a file by sequential
-screenfuls.  It reads a file name argument using the minibuffer.  After
-reading the file into an Emacs buffer, @code{view-file} displays the
-beginning.  You can then type @key{SPC} to scroll forward one windowful,
-or @key{DEL} to scroll backward.  Various other commands are provided
-for moving around in the file, but none for changing it; type @kbd{?}
-while viewing for a list of them.  They are mostly the same as normal
-Emacs cursor motion commands.  To exit from viewing, type @kbd{q}.
-The commands for viewing are defined by a special minor mode called View
-mode.
-
-  A related command, @kbd{M-x view-buffer}, views a buffer already present
-in Emacs.  @xref{Misc Buffer}.
+@findex delete-file
+@cindex deletion (of files)
+  @kbd{M-x delete-file} prompts for a file and deletes it.  If you are
+deleting many files in one directory, it may be more convenient to use
+Dired rather than @code{delete-file}.  @xref{Dired Deletion}.
+
+@cindex trash
+@cindex recycle bin
+  @kbd{M-x move-file-to-trash} moves a file into the system
+@dfn{Trash} (or @dfn{Recycle Bin}).  This is a facility available on
+most operating systems; files that are moved into the Trash can be
+brought back later if you change your mind.
+
+@vindex delete-by-moving-to-trash
+  By default, Emacs deletion commands do @emph{not} use the Trash.  To
+use the Trash (when it is available) for common deletion commands,
+change the variable @code{delete-by-moving-to-trash} to @code{t}.
+This affects the commands @kbd{M-x delete-file} and @kbd{M-x
+delete-directory} (@pxref{Directories}), as well as the deletion
+commands in Dired (@pxref{Dired Deletion}).  Supplying a prefix
+argument to @kbd{M-x delete-file} or @kbd{M-x delete-directory} makes
+them delete outright, instead of using the Trash, regardless of
+@code{delete-by-moving-to-trash}.
+
+@ifnottex
+  If a file is under version control (@pxref{Version Control}), you
+should delete it using @kbd{M-x vc-delete-file} instead of @kbd{M-x
+delete-file}.  @xref{VC Delete/Rename}.
+@end ifnottex
+
+@findex copy-file
+@cindex copying files
+  @kbd{M-x copy-file} reads the file @var{old} and writes a new file
+named @var{new} with the same contents.
+
+@findex copy-directory
+  @kbd{M-x copy-directory} copies directories, similar to the
+@command{cp -r} shell command.  It prompts for a directory @var{old}
+and a destination @var{new}.  If @var{new} is an existing directory,
+it creates a copy of the @var{old} directory and puts it in @var{new}.
+If @var{new} is not an existing directory, it copies all the contents
+of @var{old} into a new directory named @var{new}.
+
+@cindex renaming files
+@findex rename-file
+  @kbd{M-x rename-file} reads two file names @var{old} and @var{new}
+using the minibuffer, then renames file @var{old} as @var{new}.  If
+the file name @var{new} already exists, you must confirm with
+@kbd{yes} or renaming is not done; this is because renaming causes the
+old meaning of the name @var{new} to be lost.  If @var{old} and
+@var{new} are on different file systems, the file @var{old} is copied
+and deleted.  If the argument @var{new} is just a directory name, the
+real new name is in that directory, with the same non-directory
+component as @var{old}.  For example, @kbd{M-x rename-file RET ~/foo
+RET /tmp RET} renames @file{~/foo} to @file{/tmp/foo}.  The same rule
+applies to all the remaining commands in this section.  All of them
+ask for confirmation when the new file name already exists, too.
+
+@ifnottex
+  If a file is under version control (@pxref{Version Control}), you
+should rename it using @kbd{M-x vc-rename-file} instead of @kbd{M-x
+rename-file}.  @xref{VC Delete/Rename}.
+@end ifnottex
+
+@findex add-name-to-file
+@cindex hard links (creation)
+  @kbd{M-x add-name-to-file} adds an additional name to an existing
+file without removing its old name.  The new name is created as a
+``hard link'' to the existing file.  The new name must belong on the
+same file system that the file is on.  On MS-Windows, this command
+works only if the file resides in an NTFS file system.  On MS-DOS, it
+works by copying the file.
+
+@findex make-symbolic-link
+@cindex symbolic links (creation)
+  @kbd{M-x make-symbolic-link} reads two file names @var{target} and
+@var{linkname}, then creates a symbolic link named @var{linkname},
+which points at @var{target}.  The effect is that future attempts to
+open file @var{linkname} will refer to whatever file is named
+@var{target} at the time the opening is done, or will get an error if
+the name @var{target} is nonexistent at that time.  This command does
+not expand the argument @var{target}, so that it allows you to specify
+a relative name as the target of the link.  On MS-Windows, this
+command works only on MS Windows Vista and later.
 
 @kindex C-x i
 @findex insert-file
@@ -1542,74 +1601,6 @@ 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)
-@vindex delete-by-moving-to-trash
-  @kbd{M-x delete-file} deletes the specified file, like the @code{rm}
-command in the shell.  If you are deleting many files in one
-directory, it may be more convenient to use Dired rather than
-@code{delete-file}.  @xref{Dired}.
-
-@cindex trash
-@cindex recycle bin
-  On some systems, there is a facility called the ``Trash'' (or
-``Recycle Bin''); ``deleting'' a file normally means moving it into
-the Trash, and you can bring the file back from the Trash if you later
-change your mind.  By default, Emacs does @emph{not} use the Trash for
-file deletion---when Emacs deletes a file, it is gone forever.  You
-can tell Emacs to use the Trash by changing the variable
-@code{delete-by-moving-to-trash} to @code{t}.  This applies to file
-deletion via @kbd{M-x delete-file}, as well as @kbd{M-x
-delete-directory} (@pxref{Directories}) and file deletion in Dired
-(@pxref{Dired Deletion}).  In addition, you can explicitly move a file
-into the Trash with the command @kbd{M-x move-file-to-trash}.
-
-@findex rename-file
-  @kbd{M-x rename-file} reads two file names @var{old} and @var{new} using
-the minibuffer, then renames file @var{old} as @var{new}.  If the file name
-@var{new} already exists, you must confirm with @kbd{yes} or renaming is not
-done; this is because renaming causes the old meaning of the name @var{new}
-to be lost.  If @var{old} and @var{new} are on different file systems, the
-file @var{old} is copied and deleted.
-
-  If the argument @var{new} is just a directory name, the real new
-name is in that directory, with the same non-directory component as
-@var{old}.  For example, @kbd{M-x rename-file RET ~/foo RET /tmp RET}
-renames @file{~/foo} to @file{/tmp/foo}.  The same rule applies to all
-the remaining commands in this section.  All of them ask for
-confirmation when the new file name already exists, too.
-
-@findex add-name-to-file
-@cindex hard links (creation)
-  The similar command @kbd{M-x add-name-to-file} is used to add an
-additional name to an existing file without removing its old name.
-The new name is created as a ``hard link'' to the existing file.
-The new name must belong on the same file system that the file is on.
-On MS-Windows, this command works only if the file resides in an NTFS
-file system.  On MS-DOS, it works by copying the file.
-
-@findex copy-file
-@findex copy-directory
-@cindex copying files
-  @kbd{M-x copy-file} reads the file @var{old} and writes a new file
-named @var{new} with the same contents.  @kbd{M-x copy-directory} does
-the same for directories, by recursive copying all files and
-subdirectories.
-
-@findex make-symbolic-link
-@cindex symbolic links (creation)
-  @kbd{M-x make-symbolic-link} reads two file names @var{target} and
-@var{linkname}, then creates a symbolic link named @var{linkname},
-which points at @var{target}.  The effect is that future attempts to
-open file @var{linkname} will refer to whatever file is named
-@var{target} at the time the opening is done, or will get an error if
-the name @var{target} is nonexistent at that time.  This command does
-not expand the argument @var{target}, so that it allows you to specify
-a relative name as the target of the link.
-
-  Not all systems support symbolic links; on systems that don't
-support them, this command is not defined.
-
 @findex set-file-modes
 @cindex file modes
 @cindex file permissions
@@ -1668,21 +1659,18 @@ Tar mode is used also for compressed archives---files with extensions
   The keys @kbd{e}, @kbd{f} and @key{RET} all extract a component file
 into its own buffer.  You can edit it there, and if you save the
 buffer, the edited version will replace the version in the Tar buffer.
-@kbd{v} extracts a file into a buffer in View mode.  @kbd{o} extracts
-the file and displays it in another window, so you could edit the file
-and operate on the archive simultaneously.  @kbd{d} marks a file for
-deletion when you later use @kbd{x}, and @kbd{u} unmarks a file, as in
-Dired.  @kbd{C} copies a file from the archive to disk and @kbd{R}
-renames a file within the archive.  @kbd{g} reverts the buffer from
-the archive on disk.
-
-  The keys @kbd{M}, @kbd{G}, and @kbd{O} change the file's permission
-bits, group, and owner, respectively.
-
-  If your display supports colors and the mouse, moving the mouse
-pointer across a file name highlights that file name, indicating that
-you can click on it.  Clicking @kbd{Mouse-2} on the highlighted file
-name extracts the file into a buffer and displays that buffer.
+Clicking with the mouse on the file name in the Tar buffer does
+likewise.  @kbd{v} extracts a file into a buffer in View mode
+(@pxref{View Mode}).  @kbd{o} extracts the file and displays it in
+another window, so you could edit the file and operate on the archive
+simultaneously.
+
+  @kbd{d} marks a file for deletion when you later use @kbd{x}, and
+@kbd{u} unmarks a file, as in Dired.  @kbd{C} copies a file from the
+archive to disk and @kbd{R} renames a file within the archive.
+@kbd{g} reverts the buffer from the archive on disk.  The keys
+@kbd{M}, @kbd{G}, and @kbd{O} change the file's permission bits,
+group, and owner, respectively.
 
   Saving the Tar buffer writes a new version of the archive to disk with
 the changes you made to the components.
@@ -1699,19 +1687,20 @@ requires the appropriate uncompression program.
 @cindex @code{zip}
 @cindex @code{lzh}
 @cindex @code{zoo}
+@cindex @code{7z}
 @pindex arc
 @pindex jar
 @pindex zip
 @pindex rar
 @pindex lzh
 @pindex zoo
+@pindex 7z
 @cindex Java class archives
 @cindex unzip archives
-  A separate but similar Archive mode is used for archives produced by
-the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip},
-@code{rar}, and @code{zoo}, which have extensions corresponding to the
-program names.  Archive mode also works for those @code{exe} files
-that are self-extracting executables.
+  A separate but similar Archive mode is used for @code{arc},
+@code{jar}, @code{lzh}, @code{zip}, @code{rar}, @code{7z}, and
+@code{zoo} archives, as well as @code{exe} files that are
+self-extracting executables.
 
   The key bindings of Archive mode are similar to those in Tar mode,
 with the addition of the @kbd{m} key which marks a file for subsequent
@@ -1721,11 +1710,11 @@ information, for those archive types where it won't fit in a single
 line.  Operations such as renaming a subfile, or changing its mode or
 owner, are supported only for some of the archive formats.
 
-  Unlike Tar mode, Archive mode runs the archiving program to unpack
-and repack archives.  Details of the program names and their options
-can be set in the @samp{Archive} Customize group.  However, you don't
-need these programs to look at the archive table of contents, only to
-extract or manipulate the subfiles in the archive.
+  Unlike Tar mode, Archive mode runs the archiving programs to unpack
+and repack archives.  However, you don't need these programs to look
+at the archive table of contents, only to extract or manipulate the
+subfiles in the archive.  Details of the program names and their
+options can be set in the @samp{Archive} Customize group.
 
 @node Remote Files
 @section Remote Files
@@ -1757,16 +1746,14 @@ Emacs chooses the method as follows:
 
 @enumerate
 @item
-If the host name starts with @samp{ftp.} (with dot), then Emacs uses
-FTP.
+If the host name starts with @samp{ftp.} (with dot), Emacs uses FTP.
 @item
-If the user name is @samp{ftp} or @samp{anonymous}, then Emacs uses
-FTP.
+If the user name is @samp{ftp} or @samp{anonymous}, Emacs uses FTP.
 @item
 If the variable @code{tramp-default-method} is set to @samp{ftp},
-then Emacs uses FTP.
+Emacs uses FTP.
 @item
-If @command{ssh-agent} is running, then Emacs uses @command{scp}.
+If @command{ssh-agent} is running, Emacs uses @command{scp}.
 @item
 Otherwise, Emacs uses @command{ssh}.
 @end enumerate
@@ -1778,32 +1765,31 @@ variable @code{tramp-mode} to @code{nil}.  You can turn off the
 feature in individual cases by quoting the file name with @samp{/:}
 (@pxref{Quoted File Names}).
 
+@cindex ange-ftp
   Remote file access through FTP is handled by the Ange-FTP package, which
 is documented in the following.  Remote file access through the other
 methods is handled by the Tramp package, which has its own manual.
 @xref{Top, The Tramp Manual,, tramp, The Tramp Manual}.
 
-When the Ange-FTP package is used, Emacs logs in through FTP using
-your user name or the name @var{user}.  It may ask you for a password
-from time to time (@pxref{Passwords}); this is used for logging in on
-@var{host}.  The form using @var{port} allows you to access servers
-running on a non-default TCP port.
+@vindex ange-ftp-default-user
+@cindex user name for remote file access
+  When the Ange-FTP package is used, Emacs logs in through FTP using
+the name @var{user}, if that is specified in the remote file name.  If
+@var{user} is unspecified, Emacs logs in using your user name on the
+local system; but if you set the variable @code{ange-ftp-default-user}
+to a string, that string is used instead.  When logging in, Emacs may
+also ask for a password.
 
 @cindex backups for remote files
 @vindex ange-ftp-make-backup-files
-  If you want to disable backups for remote files, set the variable
-@code{ange-ftp-make-backup-files} to @code{nil}.
+  For performance reasons, Emacs does not make backup files for files
+accessed via FTP by default.  To make it do so, change the variable
+@code{ange-ftp-make-backup-files} to a non-@code{nil} value.
 
-  By default, the auto-save files (@pxref{Auto Save Files}) for remote
-files are made in the temporary file directory on the local machine.
-This is achieved using the variable @code{auto-save-file-name-transforms}.
-
-@cindex ange-ftp
-@vindex ange-ftp-default-user
-@cindex user name for remote file access
-  Normally, if you do not specify a user name in a remote file name,
-that means to use your own user name.  But if you set the variable
-@code{ange-ftp-default-user} to a string, that string is used instead.
+  By default, auto-save files for remote files are made in the
+temporary file directory on the local machine, as specified by the
+variable @code{auto-save-file-name-transforms}.  @xref{Auto Save
+Files}.
 
 @cindex anonymous FTP
 @vindex ange-ftp-generate-anonymous-password
@@ -1874,7 +1860,7 @@ then specifying @file{/tmp/foo*bar} will visit only
 @cindex file name caching
 @cindex cache of file names
 @pindex find
-@kindex C-@key{TAB}
+@kindex C-TAB
 @findex file-cache-minibuffer-complete
   You can use the @dfn{file name cache} to make it easy to locate a
 file by name, without having to remember exactly where it is located.
@@ -1882,7 +1868,7 @@ When typing a file name in the minibuffer, @kbd{C-@key{tab}}
 (@code{file-cache-minibuffer-complete}) completes it using the file
 name cache.  If you repeat @kbd{C-@key{tab}}, that cycles through the
 possible completions of what you had originally typed.  (However, note
-that the @kbd{C-@key{tab}} character cannot be typed on most text-only
+that the @kbd{C-@key{tab}} character cannot be typed on most text
 terminals.)
 
   The file name cache does not fill up automatically.  Instead, you
@@ -1900,10 +1886,9 @@ Add each file name in @var{directory} and all of its nested
 subdirectories to the file name cache, using @command{locate} to find
 them all.
 @item M-x file-cache-add-directory-list @key{RET} @var{variable} @key{RET}
-Add each file name in each directory listed in @var{variable}
-to the file name cache.  @var{variable} should be a Lisp variable
-such as @code{load-path} or @code{exec-path}, whose value is a list
-of directory names.
+Add each file name in each directory listed in @var{variable} to the
+file name cache.  @var{variable} should be a Lisp variable whose value
+is a list of directory names, like @code{load-path}.
 @item M-x file-cache-clear-cache @key{RET}
 Clear the cache; that is, remove all file names from it.
 @end table
@@ -1937,20 +1922,45 @@ point.  Partial Completion mode offers other features extending
 
 @findex image-mode
 @findex image-toggle-display
+@findex image-toggle-animation
 @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.  If the
-displayed image is wider or taller than the frame, the usual point
-motion keys (@kbd{C-f}, @kbd{C-p}, and so forth) cause different parts
-of the image to be displayed.
+@cindex image animation
+@cindex animated images
+  Visiting image files automatically selects Image mode.  In this
+major mode, you can type @kbd{C-c C-c} (@code{image-toggle-display})
+to toggle between displaying the file as an image in the Emacs buffer,
+and displaying its underlying text (or raw byte) representation.
+Displaying the file as an image works only if Emacs is compiled with
+support for displaying such images.  If the displayed image is wider
+or taller than the frame, the usual point motion keys (@kbd{C-f},
+@kbd{C-p}, and so forth) cause different parts of the image to be
+displayed.  If the image can be animated, the command @kbd{RET}
+(@code{image-toggle-animation}) starts or stops the animation.
+Animation plays once, unless the option @code{image-animate-loop} is
+non-@code{nil}.
+
+@cindex ImageMagick support
+@vindex imagemagick-enabled-types
+@vindex imagemagick-types-inhibit
+  If Emacs was compiled with support for the ImageMagick library, it
+can use ImageMagick to render a wide variety of images.  The variable
+@code{imagemagick-enabled-types} lists the image types that Emacs may
+render using ImageMagick; each element in the list should be an
+internal ImageMagick name for an image type, as a symbol or an
+equivalent string (e.g., @code{BMP} for @file{.bmp} images).  To
+enable ImageMagick for all possible image types, change
+@code{imagemagick-enabled-types} to @code{t}.  The variable
+@code{imagemagick-types-inhibit} lists the image types which should
+never be rendered using ImageMagick, regardless of the value of
+@code{imagemagick-enabled-types} (the default list includes types like
+@code{C} and @code{HTML}, which ImageMagick can render as an ``image''
+but Emacs should not).  To disable ImageMagick entirely, change
+@code{imagemagick-types-inhibit} to @code{t}.
 
 @findex thumbs-mode
 @findex mode, thumbs
-  See also the Image-Dired package (@pxref{Image-Dired}) for viewing
-images as thumbnails.
+  The Image-Dired package can also be used to view images as
+thumbnails.  @xref{Image-Dired}.
 
 @node Filesets
 @section Filesets
@@ -1959,27 +1969,27 @@ images as thumbnails.
 @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.
+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 init 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 a fileset is by adding files to it 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
+  The simplest way to define a fileset is by adding files to it 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
+initially contains 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
+(@pxref{Easy Customization}).  Normally, a fileset is a simple list of
+files, but you can also define a fileset as a 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.
 
@@ -1989,11 +1999,7 @@ files in a fileset, and @kbd{M-x filesets-close} to close them.  Use
 a fileset.  These commands are also available from the @samp{Filesets}
 menu, where each existing fileset is represented by a submenu.
 
-   Emacs uses the concept of a fileset elsewhere @pxref{Version
-Control} to describe sets of files to be treated as a group for
-purposes of version control operations.  Those filesets are unnamed
-and do not persist across Emacs sessions.
-
-@ignore
-   arch-tag: 768d32cb-e15a-4cc1-b7bf-62c00ee12250
-@end ignore
+   @xref{Version Control}, for a different concept of ``filesets'':
+groups of files bundled together for version control operations.
+Filesets of that type are unnamed, and do not persist across Emacs
+sessions.