GNU Emacs Lisp Reference Manual
The buffer file name is the name of the file that is visited in
that buffer. When a buffer is not visiting a file, its buffer file name
is nil. Most of the time, the buffer name is the same as the
nondirectory part of the buffer file name, but the buffer file name and
the buffer name are distinct and can be set independently.
See Visiting Files.
buffer-file-name returns nil. If buffer is not
supplied, it defaults to the current buffer.
(buffer-file-name (other-buffer))
=> "/usr/user/lewis/manual/files.texi"
nil if it is not visiting a file. It
is a permanent local, unaffected by kill-local-variables.
buffer-file-name
=> "/usr/user/lewis/manual/buffers.texi"
It is risky to change this variable's value without doing various other
things. See the definition of set-visited-file-name in
files.el; some of the things done there, such as changing the
buffer name, are not strictly necessary, but others are essential to
avoid confusing Emacs.
nil if no file is visited. It is a permanent
local, unaffected by kill-local-variables. See Truenames.
nil if no
file or a nonexistent file is visited. It is a permanent local,
unaffected by kill-local-variables. See Truenames.
The value is normally a list of the form (filenum devnum). This pair of numbers uniquely identifies the file among
all files accessible on the system. See the function
file-attributes, in File Attributes, for more information
about them.
nil. The argument
filename, which must be a string, is expanded (see File Name Expansion), then compared against the visited file names of all live
buffers.
(get-file-buffer "buffers.texi")
=> #<buffer buffers.texi>
In unusual circumstances, there can be more than one buffer visiting the same file name. In such cases, this function returns the first such buffer in the buffer list.
If filename is nil or the empty string, that stands for
``no visited file''. In this case, set-visited-file-name marks
the buffer as having no visited file.
When the function set-visited-file-name is called interactively, it
prompts for filename in the minibuffer.
See also clear-visited-file-modtime and
verify-visited-file-modtime in Buffer Modification.