]> code.delx.au - gnu-emacs/blobdiff - lispref/files.texi
(Visiting Functions, Reading from Files, Saving Buffers): Mention code and EOL
[gnu-emacs] / lispref / files.texi
index 93c104e6ccdeaaf080affd10c79722efc357dafc..d23b5efdd674d494fb2eb1bd85d80da2a52e5aa3 100644 (file)
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2004
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2002, 2003,
+@c   2004, 2005, 2006 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/files
 @node Files, Backups and Auto-Saving, Documentation, Top
@@ -136,6 +136,10 @@ example, if it needs to create a buffer, and there is no file named
 @var{filename}, it displays the message @samp{(New file)} in the echo
 area, and leaves the buffer empty.
 
+Reading the file(s) into their respective buffers involves decoding
+the files' contents (@pxref{Coding Systems}), including end-of-line
+conversion.
+
 The @code{find-file-noselect} function normally calls
 @code{after-find-file} after reading the file (@pxref{Subroutines of
 Visiting}).  That function sets the buffer major mode, parses local
@@ -341,10 +345,10 @@ The optional @var{pred} argument controls which buffers to ask about
 If it is @code{nil}, that means to ask only about file-visiting buffers.
 If it is @code{t}, that means also offer to save certain other non-file
 buffers---those that have a non-@code{nil} buffer-local value of
-@code{buffer-offer-save}.  (A user who says @samp{yes} to saving a
-non-file buffer is asked to specify the file name to use.)  The
-@code{save-buffers-kill-emacs} function passes the value @code{t} for
-@var{pred}.
+@code{buffer-offer-save} (@pxref{Killing Buffers}).  A user who says
+@samp{yes} to saving a non-file buffer is asked to specify the file
+name to use.  The @code{save-buffers-kill-emacs} function passes the
+value @code{t} for @var{pred}.
 
 If @var{pred} is neither @code{t} nor @code{nil}, then it should be
 a function of no arguments.  It will be called in each buffer to decide
@@ -395,11 +399,12 @@ You might wish to save the file modes value returned by
 bits of the file that you write.  This is what @code{save-buffer}
 normally does. @xref{Making Backups,, Making Backup Files}.
 
-The hook functions in @code{write-file-functions} are also responsible for
-encoding the data (if desired): they must choose a suitable coding
-system (@pxref{Lisp and Coding Systems}), perform the encoding
-(@pxref{Explicit Encoding}), and set @code{last-coding-system-used} to
-the coding system that was used (@pxref{Encoding and I/O}).
+The hook functions in @code{write-file-functions} are also responsible
+for encoding the data (if desired): they must choose a suitable coding
+system and end-of-line conversion (@pxref{Lisp and Coding Systems}),
+perform the encoding (@pxref{Explicit Encoding}), and set
+@code{last-coding-system-used} to the coding system that was used
+(@pxref{Encoding and I/O}).
 
 If you set this hook locally in a buffer, it is assumed to be
 associated with the file or the way the contents of the buffer were
@@ -496,7 +501,8 @@ appropriate.  @xref{Format Conversion}.  It also calls the functions in
 the list @code{after-insert-file-functions}; see @ref{Saving
 Properties}.  Normally, one of the functions in the
 @code{after-insert-file-functions} list determines the coding system
-(@pxref{Coding Systems}) used for decoding the file's contents.
+(@pxref{Coding Systems}) used for decoding the file's contents,
+including end-of-line conversion.
 
 If @var{visit} is non-@code{nil}, this function additionally marks the
 buffer as unmodified and sets up various fields in the buffer so that it
@@ -625,7 +631,7 @@ feature is useful for programs that use files for internal purposes,
 files that the user does not need to know about.
 @end deffn
 
-@defmac with-temp-file file body...
+@defmac with-temp-file file body@dots{}
 @anchor{Definition of with-temp-file}
 The @code{with-temp-file} macro evaluates the @var{body} forms with a
 temporary buffer as the current buffer; then, at the end, it writes the
@@ -1283,8 +1289,9 @@ suffixes to append to @var{filename} when searching.
 suffixes.  If @var{suffixes} is @code{nil}, or @code{("")}, then there
 are no suffixes, and @var{filename} is used only as-is.  Typical
 values of @var{suffixes} are @code{exec-suffixes} (@pxref{Subprocess
-Creation, exec-suffixes}) and @code{load-suffixes} (@pxref{Library
-Search, load-suffixes}).
+Creation, exec-suffixes}), @code{load-suffixes},
+@code{load-file-rep-suffixes} and the return value of the function
+@code{get-load-suffixes} (@pxref{Load Suffixes}).
 
 Typical values for @var{path} are @code{exec-path} (@pxref{Subprocess
 Creation, exec-path}) when looking for executable programs or
@@ -1601,7 +1608,7 @@ directory name (@pxref{Directory Names}), or @code{nil} if
 @var{filename} does not include a directory part.
 
 On GNU and Unix systems, a string returned by this function always
-ends in a slash.  On MSDOS it can also end in a colon.  On VMS, it
+ends in a slash.  On MS-DOS it can also end in a colon.  On VMS, it
 returns a string ending in one of the three characters @samp{:},
 @samp{]}, or @samp{>}.
 
@@ -1768,6 +1775,32 @@ Unix syntax and VMS syntax.
      @result{} t
 @end group
 @end example
+@end defun
+
+  Given a possibly relative file name, you can convert it to an
+absolute name using @code{expand-file-name} (@pxref{File Name
+Expansion}).  This function converts absolute file names to relative
+names:
+
+@defun file-relative-name filename &optional directory
+This function tries to return a relative name that is equivalent to
+@var{filename}, assuming the result will be interpreted relative to
+@var{directory} (an absolute directory name or directory file name).
+If @var{directory} is omitted or @code{nil}, it defaults to the
+current buffer's default directory.
+
+On some operating systems, an absolute file name begins with a device
+name.  On such systems, @var{filename} has no relative equivalent based
+on @var{directory} if they start with two different device names.  In
+this case, @code{file-relative-name} returns @var{filename} in absolute
+form.
+
+@example
+(file-relative-name "/foo/bar" "/foo/")
+     @result{} "bar"
+(file-relative-name "/foo/bar" "/hack/")
+     @result{} "../foo/bar"
+@end example
 @end defun
 
 @node Directory Names
@@ -1782,7 +1815,7 @@ the directory name but not identical to it.  (This is not quite the
 same as the usual Unix terminology.)  These two different names for
 the same entity are related by a syntactic transformation.  On GNU and
 Unix systems, this is simple: a directory name ends in a slash,
-whereas the directory's name as a file lacks that slash.  On MSDOS and
+whereas the directory's name as a file lacks that slash.  On MS-DOS and
 VMS, the relationship is more complicated.
 
   The difference between a directory name and its name as a file is
@@ -1910,16 +1943,13 @@ you must specify the default directory name as well as the file name to
 be expanded.  Expansion also simplifies file names by eliminating
 redundancies such as @file{./} and @file{@var{name}/../}.
 
-In the next two functions, the @var{directory} argument can be either
-a directory name or a directory file name.  @xref{Directory Names}.
-
 @defun expand-file-name filename &optional directory
 This function converts @var{filename} to an absolute file name.  If
 @var{directory} is supplied, it is the default directory to start with
 if @var{filename} is relative.  (The value of @var{directory} should
-itself be an absolute directory name; it may start with @samp{~}.)
-Otherwise, the current buffer's value of @code{default-directory} is
-used.  For example:
+itself be an absolute directory name or directory file name; it may
+start with @samp{~}.)  Otherwise, the current buffer's value of
+@code{default-directory} is used.  For example:
 
 @example
 @group
@@ -1981,27 +2011,6 @@ should make sure to call @code{file-truename} without prior direct or
 indirect calls to @code{expand-file-name}.  @xref{Truenames}.
 @end defun
 
-@c Emacs 19 feature
-@defun file-relative-name filename &optional directory
-This function does the inverse of expansion---it tries to return a
-relative name that is equivalent to @var{filename} when interpreted
-relative to @var{directory}.  If @var{directory} is omitted or
-@code{nil}, it defaults to the current buffer's default directory.
-
-On some operating systems, an absolute file name begins with a device
-name.  On such systems, @var{filename} has no relative equivalent based
-on @var{directory} if they start with two different device names.  In
-this case, @code{file-relative-name} returns @var{filename} in absolute
-form.
-
-@example
-(file-relative-name "/foo/bar" "/foo/")
-     @result{} "bar"
-(file-relative-name "/foo/bar" "/hack/")
-     @result{} "../foo/bar"
-@end example
-@end defun
-
 @defvar default-directory
 The value of this buffer-local variable is the default directory for the
 current buffer.  It should be an absolute directory name; it may start
@@ -2580,7 +2589,9 @@ Here are the operations that a magic file name handler gets to handle:
 @code{get-file-buffer},
 @code{insert-directory},
 @code{insert-file-contents},@*
-@code{load}, @code{make-directory},
+@code{load},
+@code{make-auto-save-file-name},
+@code{make-directory},
 @code{make-directory-internal},
 @code{make-symbolic-link},@*
 @code{rename-file}, @code{set-file-modes}, @code{set-file-times},
@@ -2704,11 +2715,13 @@ The operation for which certain handlers are presently inhibited.
 @end defvar
 
 @defun find-file-name-handler file operation
-This function returns the handler function for file name @var{file}, or
-@code{nil} if there is none.  The argument @var{operation} should be the
-operation to be performed on the file---the value you will pass to the
-handler as its first argument when you call it.  The operation is needed
-for comparison with @code{inhibit-file-name-operation}.
+This function returns the handler function for file name @var{file},
+or @code{nil} if there is none.  The argument @var{operation} should
+be the operation to be performed on the file---the value you will pass
+to the handler as its first argument when you call it.  If
+@var{operation} equals @code{inhibit-file-name-operation}, or if it is
+not found in the @code{operations} property of the handler, this
+function returns @code{nil}.
 @end defun
 
 @defun file-local-copy filename