Before a file can be edited it must be read into a buffer, this buffer can then be modified and later saved over the original contents of the file. Note that editing a buffer makes no changes to the contents of the file on disk; the buffer will have to be written back to the file on the disk first. See section Writing Buffers.
If an existing buffer contains the file called file-name that buffer is returned. Otherwise a new buffer is created and the file read into it.
When the file has successfully been read into the new buffer any local
variables defined at the end of the file are processed
(see section File Variables) and the function init-mode is used to try
to install a major mode for the new buffer. See section Installing Modes.
If file may not be written to the buffer is marked to be read-only.
Note that the hook, read-file-hook, can be used to read the contents
of the file into the buffer if necessary. See the documentation of this
hook for more details.
open-file function when it wants to
read a file into a buffer. If the hook returns a non-nil value
open-file assumes that one member of the hook was successful
in reading the file, otherwise the file will be read verbatim into the
buffer.
The hook is called with two arguments: the name of the file and the buffer to read it into respectively.
If any members of the hook decide to read the file they're responsible
for setting the buffer-file-name component of the buffer and
the buffer's buffer-file-modtime variables to suitable values.
See the `gzip.jl' file in the Lisp library directory for an example of how this hook can be used (in this case to automatically decompress gzip'ed files).
The following commands are used to read a file into a buffer then display that buffer in the current buffer.
When called interactively file-name will be prompted for.
When called interactively this function will prompt for its argument.
This will prompt for its argument when called interactively.
There is also a command to insert the contents of a file into a buffer.
The hook insert-file-hook is called with file-name as an
argument to try and insert the file (into the current buffer at the
current position). If this hook returns nil (i.e. none of the
functions in the hook inserted the file) it will be inserted
normally.
If called interactively, file-name will be prompted for.
Go to the first, previous, next, last section, table of contents.