Merge from emacs-24; up to 2012-04-24T08:35:02Z!lekktu@gmail.com
[bpt/emacs.git] / doc / lispref / files.texi
index 87a3035..7bb2bad 100644 (file)
@@ -3,7 +3,6 @@
 @c Copyright (C) 1990-1995, 1998-1999, 2001-2012
 @c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
-@setfilename ../../info/files
 @node Files, Backups and Auto-Saving, Documentation, Top
 @comment  node-name,  next,  previous,  up
 @chapter Files
@@ -72,8 +71,8 @@ back into the file.
 
   In spite of the distinction between files and buffers, people often
 refer to a file when they mean a buffer and vice-versa.  Indeed, we say,
-``I am editing a file,'' rather than, ``I am editing a buffer that I
-will soon save as a file of the same name.''  Humans do not usually need
+``I am editing a file'', rather than, ``I am editing a buffer that I
+will soon save as a file of the same name''.  Humans do not usually need
 to make the distinction explicit.  When dealing with a computer program,
 however, it is good to keep the distinction in mind.
 
@@ -490,11 +489,13 @@ in particular buffers.
 @defopt require-final-newline
 This variable determines whether files may be written out that do
 @emph{not} end with a newline.  If the value of the variable is
-@code{t}, then @code{save-buffer} silently adds a newline at the end of
-the file whenever the buffer being saved does not already end in one.
-If the value of the variable is non-@code{nil}, but not @code{t}, then
-@code{save-buffer} asks the user whether to add a newline each time the
-case arises.
+@code{t}, then @code{save-buffer} silently adds a newline at the end
+of the buffer whenever it does not already end in one.  If the value
+is @code{visit}, Emacs adds a missing newline just after it visits the
+file.  If the value is @code{visit-save}, Emacs adds a missing newline
+both on visiting and on saving.  For any other non-@code{nil} value,
+@code{save-buffer} asks the user whether to add a newline each time
+the case arises.
 
 If the value of the variable is @code{nil}, then @code{save-buffer}
 doesn't add newlines at all.  @code{nil} is the default value, but a few
@@ -687,7 +688,7 @@ The file lock is really a file, a symbolic link with a special name,
 stored in the same directory as the file you are editing.
 
   When you access files using NFS, there may be a small probability that
-you and another user will both lock the same file ``simultaneously.''
+you and another user will both lock the same file ``simultaneously''.
 If this happens, it is possible for the two users to make changes
 simultaneously, but Emacs will still warn the user who saves second.
 Also, the detection of modification of a buffer visiting a file changed
@@ -725,7 +726,12 @@ system does not support locking.
 
   File locking is not supported on some systems.  On systems that do not
 support it, the functions @code{lock-buffer}, @code{unlock-buffer} and
-@code{file-locked-p} do nothing and return @code{nil}.
+@code{file-locked-p} do nothing and return @code{nil}.  It is also
+possible to disable locking, by setting the variable @code{create-lockfiles}.
+
+@defopt create-lockfiles
+If this variable is @code{nil}, Emacs does not lock files.
+@end defopt
 
 @defun ask-user-about-lock file other-user
 This function is called when the user tries to modify @var{file}, but it
@@ -1020,17 +1026,17 @@ other I/O device).
 
 @defun file-equal-p file1 file2
 This function returns @code{t} if the files @var{file1} and
-@var{file2} name the same file.  Two ordinary files are considered to
-be the same if the function @code{file-attributes} (@pxref{File
-Attributes}) returns @code{equal} values for them.
+@var{file2} name the same file.  If @var{file1} or @var{file2} does
+not exist, the return value is unspecified.
 @end defun
 
-@defun file-subdir-of-p dir1 dir2
-This function returns @code{t} if directory @var{dir1} is a
-subdirectory of @var{dir2}, or if @var{dir1} and @var{dir2} are the
-same directory.  It compares the @code{file-truename} values of the
-two directories (@pxref{Truenames}).  If @var{dir2} 
-do not name an existing directory, the return value is @code{nil}.
+@defun file-in-directory-p file dir
+This function returns @code{t} if @var{file} is a file in directory
+@var{dir}, or in a subdirectory of @var{dir}.  It also returns
+@code{t} if @var{file} and @var{dir} are the same directory.  It
+compares the @code{file-truename} values of the two directories
+(@pxref{Truenames}).  If @var{dir} does not name an existing
+directory, the return value is @code{nil}.
 @end defun
 
 @node Truenames
@@ -1805,7 +1811,7 @@ return value, but backup version numbers are kept.
 @end defun
 
 @defun file-name-extension filename &optional period
-This function returns @var{filename}'s final ``extension,'' if any,
+This function returns @var{filename}'s final ``extension'', if any,
 after applying @code{file-name-sans-versions} to remove any
 version/backup part.  The extension, in a file name, is the part that
 follows the last @samp{.} in the last name component (minus any
@@ -2154,7 +2160,7 @@ double all @samp{$} characters to prevent subsequent incorrect
 results.
 
 @c Wordy to avoid overfull hbox.  --rjc 15mar92
-Here we assume that the environment variable @code{HOME}, which holds
+Here we assume that the environment variable @env{HOME}, which holds
 the user's home directory name, has value @samp{/xcssun/users/rms}.
 
 @example
@@ -2239,9 +2245,9 @@ non-@code{nil}.  To use it, you should expand the prefix against
 the proper directory before calling @code{make-temp-file}.
 
 @defopt temporary-file-directory
-@cindex @code{TMPDIR} environment variable
-@cindex @code{TMP} environment variable
-@cindex @code{TEMP} environment variable
+@cindex @env{TMPDIR} environment variable
+@cindex @env{TMP} environment variable
+@cindex @env{TEMP} environment variable
 This variable specifies the directory name for creating temporary files.
 Its value should be a directory name (@pxref{Directory Names}), but it
 is good for Lisp programs to cope if the value is a directory's file
@@ -2249,7 +2255,7 @@ name instead.  Using the value as the second argument to
 @code{expand-file-name} is a good way to achieve that.
 
 The default value is determined in a reasonable way for your operating
-system; it is based on the @code{TMPDIR}, @code{TMP} and @code{TEMP}
+system; it is based on the @env{TMPDIR}, @env{TMP} and @env{TEMP}
 environment variables, with a fall-back to a system-dependent name if
 none of these variables is defined.
 
@@ -2719,7 +2725,7 @@ first, before handlers for jobs such as remote file access.
 @code{file-name-nondirectory},
 @code{file-name-sans-versions}, @code{file-newer-than-file-p},
 @code{file-ownership-preserved-p},
-@code{file-readable-p}, @code{file-regular-p}, @code{file-subdir-of-p},
+@code{file-readable-p}, @code{file-regular-p}, @code{file-in-directory-p},
 @code{file-symlink-p}, @code{file-truename}, @code{file-writable-p},
 @code{file-equal-p}, @code{find-backup-file-name},
 @c Not sure why it was here:   @code{find-file-noselect},@*
@@ -2797,7 +2803,7 @@ unlocking the buffer if it is locked.
 possibly others to be added in the future.  It need not implement all
 these operations itself---when it has nothing special to do for a
 certain operation, it can reinvoke the primitive, to handle the
-operation ``in the usual way.''  It should always reinvoke the primitive
+operation ``in the usual way''.  It should always reinvoke the primitive
 for an operation it does not recognize.  Here's one way to do this:
 
 @smallexample
@@ -2949,7 +2955,8 @@ between consecutive checks.  For example:
 
 @example
 (defun display-time-file-nonempty-p (file)
-  (let ((remote-file-name-inhibit-cache (- display-time-interval 5)))
+  (let ((remote-file-name-inhibit-cache
+         (- display-time-interval 5)))
     (and (file-exists-p file)
          (< 0 (nth 7 (file-attributes (file-chase-links file)))))))
 @end example
@@ -3126,10 +3133,10 @@ in the order of appearance in the list.
 This command writes the current buffer contents into the file @var{file}
 in a format based on @var{format}, which is a list of format names.  It
 constructs the actual format starting from @var{format}, then appending
-any elements from the value of @code{buffer-file-format} with a non-nil
-@var{preserve} flag (see above), if they are not already present in
-@var{format}.  It then updates @code{buffer-file-format} with this
-format, making it the default for future saves.  Except for the
+any elements from the value of @code{buffer-file-format} with a
+non-@code{nil} @var{preserve} flag (see above), if they are not already
+present in @var{format}.  It then updates @code{buffer-file-format} with
+this format, making it the default for future saves.  Except for the
 @var{format} argument, this command is similar to @code{write-file}.  In
 particular, @var{confirm} has the same meaning and interactive treatment
 as the corresponding argument to @code{write-file}.  @xref{Definition of