Function: get-file-buffer

get-file-buffer is a function defined in buffer.c.

Signature

(get-file-buffer FILENAME)

Documentation

Return the buffer visiting file FILENAME (a string).

The buffer's buffer-file-name(var)/buffer-file-name(fun) must match exactly the expansion of FILENAME. If there is no such live buffer, return nil. See also find-buffer-visiting.

View in manual

Source Code

// Defined in /usr/src/emacs/src/buffer.c
{
  register Lisp_Object tail, buf, handler;

  CHECK_STRING (filename);
  filename = Fexpand_file_name (filename, Qnil);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (filename, Qget_file_buffer);
  if (!NILP (handler))
    {
      Lisp_Object handled_buf = calln (handler, Qget_file_buffer,
				       filename);
      return BUFFERP (handled_buf) ? handled_buf : Qnil;
    }

  FOR_EACH_LIVE_BUFFER (tail, buf)
    {
      if (!STRINGP (BVAR (XBUFFER (buf), filename))) continue;
      if (!NILP (Fstring_equal (BVAR (XBUFFER (buf), filename), filename)))
	return buf;
    }
  return Qnil;
}