[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the functions normally used to visit files. For historical reasons, these functions have names starting with `find-' rather than `visit-'. See section 27.4 Buffer File Name, for functions and variables that access the visited file name of a buffer or that find an existing buffer by its visited file name.
In a Lisp program, if you want to look at the contents of a file but
not alter it, the fastest way is to use insert-file-contents
in a
temporary buffer. Visiting the file is not necessary and takes longer.
See section 25.3 Reading from Files.
The body of the find-file
function is very simple and looks
like this:
(switch-to-buffer (find-file-noselect filename)) |
(See switch-to-buffer
in 28.7 Displaying Buffers in Windows.)
If wildcards is non-nil
, which is always true in an
interactive call, then find-file
expands wildcard characters in
filename and visits all the matching files.
When find-file
is called interactively, it prompts for
filename in the minibuffer.
If wildcards is non-nil
,
then find-file-noselect
expands wildcard
characters in filename and visits all the matching files.
When find-file-noselect
uses an existing buffer, it first
verifies that the file has not changed since it was last visited or
saved in that buffer. If the file has changed, then this function asks
the user whether to reread the changed file. If the user says
`yes', any changes previously made in the buffer are lost.
This function displays warning or advisory messages in various peculiar
cases, unless the optional argument nowarn is non-nil
. For
example, if it needs to create a buffer, and there is no file named
filename, it displays the message `(New file)' in the echo
area, and leaves the buffer empty.
The find-file-noselect
function normally calls
after-find-file
after reading the file (see section 25.1.2 Subroutines of Visiting). That function sets the buffer major mode, parses local
variables, warns the user if there exists an auto-save file more recent
than the file just visited, and finishes by running the functions in
find-file-hooks
.
If the optional argument rawfile is non-nil
, then
after-find-file
is not called, and the
find-file-not-found-hooks
are not run in case of failure. What's
more, a non-nil
rawfile value suppresses coding system
conversion (see section 33.10 Coding Systems) and format conversion (see section 25.12 File Format Conversion).
The find-file-noselect
function usually returns the buffer that
is visiting the file filename. But, if wildcards are actually
used and expanded, it returns a list of buffers that are visiting the
various files.
(find-file-noselect "/etc/fstab") => #<buffer fstab> |
When this command is called interactively, it prompts for filename.
find-file
, but it marks the buffer as read-only. See section 27.7 Read-Only Buffers, for related functions and variables.
When this command is called interactively, it prompts for filename.
view-mode-hook
. See section 23.6 Hooks.
When view-file
is called interactively, it prompts for
filename.
nil
, then the various find-file
commands check for wildcard characters and visit all the files that
match them. If this is nil
, then wildcard characters are
not treated specially.
This variable works just like a normal hook, but we think that renaming it would not be advisable. See section 23.6 Hooks.
find-file
or find-file-noselect
is passed a nonexistent
file name. find-file-noselect
calls these functions as soon as
it detects a nonexistent file. It calls them in the order of the list,
until one of them returns non-nil
. buffer-file-name
is
already set up.
This is not a normal hook because the values of the functions are used, and in many cases only some of the functions are called.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |