conversion (@pxref{Coding Systems}) and format conversion (@pxref{Format
Conversion}).
-The @code{find-file-noselect} function returns the buffer that is
-visiting the file @var{filename}.
+The @code{find-file-noselect} function usually returns the buffer that
+is visiting the file @var{filename}. But, if wildcards are actually
+used and expanded, it returns a list of buffers that are visiting the
+various files.
@example
@group
this case.
If @var{append} is non-@code{nil}, then the specified text is appended
-to the existing file contents (if any).
+to the existing file contents (if any). Starting in Emacs 21, if
+@var{append} is an integer, then @code{write-region} seeks to that byte
+offset from the start of the file and writes the data from there.
If @var{mustbenew} is non-@code{nil}, then @code{write-region} asks
for confirmation if @var{filename} names an existing file.
holds the low 16 bits.
@item
-The file system number of the file system that the file is in. This
-element and the file's inode number together give enough information to
+The file system number of the file system that the file is in.
+Depending on the magnitude of the value, this can be either an integer
+or a cons cell, in the same manner as the inode number. This element
+and the file's inode number together give enough information to
distinguish any two files on the system---no two files can have the same
values for both of these numbers.
@end enumerate
can operate on file names that do not refer to an existing file or
directory.
- On VMS, all these functions understand both VMS file-name syntax and
-Unix syntax. This is so that all the standard Lisp libraries can
-specify file names in Unix syntax and work properly on VMS without
-change. On MS-DOS and MS-Windows, these functions understand MS-DOS or
-MS-Windows file-name syntax as well as Unix syntax.
+ On MS-DOS and MS-Windows, these functions (like the function that
+actually operate on files) accept MS-DOS or MS-Windows file-name syntax,
+where backslashes separate the components, as well as Unix syntax; but
+they always return Unix syntax. On VMS, these functions (and the ones
+that operate on files) understand both VMS file-name syntax and Unix
+syntax. This enables Lisp programs to specify file names in Unix syntax
+and work properly on all systems without change.
@menu
* File Name Components:: The directory part of a file name, and the rest.
Concatenating these two parts reproduces the original file name.
On most systems, the directory part is everything up to and including
-the last slash (or backslash, on MS-DOS or MS-Windows); the nondirectory
-part is the rest. The rules in VMS syntax are complicated.
+the last slash (backslash is also allowed in input on MS-DOS or
+MS-Windows); the nondirectory part is the rest. The rules in VMS syntax
+are complicated.
For some purposes, the nondirectory part is further subdivided into
the name proper and the @dfn{version number}. On most systems, only
@defun file-name-sans-extension filename
This function returns @var{filename} minus its ``extension,'' if any.
The extension, in a file name, is the part that starts with the last
-@samp{.} in the last name component. For example,
+@samp{.} in the last name component, except if that @samp{.} is the
+first character of the file name's last component. For example,
@example
(file-name-sans-extension "foo.lose.c")
@result{} "foo.lose"
(file-name-sans-extension "big.hack/foo")
@result{} "big.hack/foo"
+(file-name-sans-extension "/my/home/.emacs")
+ @result{} "/my/home.emacs"
+(file-name-sans-extension "/my/home/.emacs.el")
+ @result{} "/my/home/.emacs"
@end example
@end defun
-@defvar directory-sep-char
-@tindex directory-sep-char
-This variable holds the character that the system normally uses to
-separate file name components. The value is @code{?/} on GNU and Unix
-systems, and @code{?\\} on MS-DOS and MS-Windows. Note that file names
-using slashes as separators work properly in Emacs on all of these
-systems; you are not obliged to use backslashes on Microsoft systems.
+@ignore
+Andrew Innes says that this
+
+@c @defvar directory-sep-char
+@c @tindex directory-sep-char
+This variable holds the character that Emacs normally uses to separate
+file name components. The default value is @code{?/}, but on MS-Windows
+you can set it to @code{?\\}; then the functions that transform file names
+use backslashes in their output.
+
+File names using backslashes work as input to Lisp primitives even on
+MS-DOS and MS-Windows, even if @code{directory-sep-char} has its default
+value of @code{?/}.
@end defvar
+@end ignore
+
+@defun file-name-extension filename &optional period
+This function returns @var{filename}'s final ``extension,'' if any,
+after applying @code{file-name-sans-versions} to remove any
+version/backup part. It returns @code{nil} for extensionless file
+names such as @file{foo}. If @var{period} is non-nil, then the
+returned value includes the period that delimits the extension, and if
+@var{filename} has no extension, the value is @code{""}. If the last
+component of a file name begins with a @samp{.}, that @samp{.} doesn't
+count as the beginning of an extension, so, for example,
+@file{.emacs}'s ``extension'' is @code{nil}, not @samp{.emacs}.
+@end defun
@node Directory Names
@comment node-name, next, previous, up
kind of file, and it has a file name, which is related to 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 most systems, this is simple: a
-directory name ends in a slash, whereas the directory's name as a file
-lacks that slash. On VMS, the relationship is more complicated.
+related by a syntactic transformation. On most systems, this is simple:
+a directory name ends in a slash (or backslash), whereas the directory's
+name as a file lacks that slash. On VMS, the relationship is more
+complicated.
The difference between a directory name and its name as a file is
subtle but crucial. When an Emacs variable or function argument is
@defun directory-file-name dirname
This function returns a string representing @var{dirname} in a form that
the operating system will interpret as the name of a file. On most
-systems, this means removing the final slash from the string. On VMS,
-the function converts a string of the form @file{[X.Y]} to
-@file{[X]Y.DIR.1}.
+systems, this means removing the final slash (or backslash) from the
+string. On VMS, the function converts a string of the form @file{[X.Y]}
+to @file{[X]Y.DIR.1}.
@example
@group
(file-relative-name "/foo/bar" "/foo/")
@result{} "bar"
(file-relative-name "/foo/bar" "/hack/")
- @result{} "/foo/bar"
+ @result{} "../foo/bar"
@end example
@end defun
information.
The argument @var{partial-filename} must be a file name containing no
-directory part and no slash. The current buffer's default directory is
-prepended to @var{directory}, if @var{directory} is not absolute.
+directory part and no slash (or backslash on some systems). The current
+buffer's default directory is prepended to @var{directory}, if
+@var{directory} is not absolute.
In the following example, suppose that @file{~rms/lewis} is the current
default directory, and has five files whose names begin with @samp{f}:
@result{} (".o" ".elc" "~" ".dvi")
@end group
@end example
+
+If an element of @code{completion-ignored-extensions} ends in a slash
+@samp{/}, it signals a directory. The elements which do @emph{not} end
+in a slash will never match a directory; thus, the above value will not
+filter out a directory named @file{foo.elc}.
@end defopt
@node Standard File Names
The first argument given to @var{handler} is the name of the primitive;
the remaining arguments are the arguments that were passed to that
-operation. (The first of these arguments is typically the file name
+primitive. (The first of these arguments is most often the file name
itself.) For example, if you do this:
@example
(funcall @var{handler} 'file-exists-p @var{filename})
@end example
+When a function takes two or more arguments that must be file names,
+it checks each of those names for a handler. For example, if you do
+this:
+
+@example
+(expand-file-name @var{filename} @var{dirname})
+@end example
+
+@noindent
+then it checks for a handler for @var{filename} and then for a handler
+for @var{dirname}. In either case, the @var{handler} is called like
+this:
+
+@example
+(funcall @var{handler} 'expand-file-name @var{filename} @var{dirname})
+@end example
+
+@noindent
+The @var{handler} then needs to figure out whether to handle
+@var{filename} or @var{dirname}.
+
Here are the operations that a magic file name handler gets to handle:
@ifnottex