Two structures (see
buffer.h) are used to represent buffers in C. The
buffer_text structure contains fields describing the text of a buffer; the
buffer structure holds other fields. In the case of indirect buffers, two or more
buffer structures reference the same
Here are some of the fields in
The address of the buffer contents. The buffer contents is a linear C array of
char, with the gap somewhere in its midst.
The character and byte positions of the buffer gap. See Buffer Gap.
The character and byte positions of the end of the buffer text.
The size of buffer’s gap. See Buffer Gap.
These fields count the number of buffer-modification events performed in this buffer.
modiff is incremented after each buffer-modification event, and is never otherwise changed;
save_modiff contains the value of
modiff the last time the buffer was visited or saved;
chars_modiff counts only modifications to the characters in the buffer, ignoring all other kinds of changes (such as text properties); and
overlay_modiff counts only modifications to the buffer’s overlays.
The number of characters at the start and end of the text that are known to be unchanged since the last complete redisplay.
The values of
overlay_modiff, respectively, after the last complete redisplay. If their current values match
overlay_modiff, that means
end_unchanged contain no useful information.
The markers that refer to this buffer. This is actually a single marker, and successive elements in its marker chain (a linked list) are the other markers referring to this buffer text.
The interval tree which records the text properties of this buffer.
Some of the fields of
struct buffer are:
A header of type
union vectorlike_header is common to all vectorlike objects.
struct buffer_text structure that ordinarily holds the buffer contents. In indirect buffers, this field is not used.
A pointer to the
buffer_text structure for this buffer. In an ordinary buffer, this is the
own_text field above. In an indirect buffer, this is the
own_text field of the base buffer.
A pointer to the next buffer, in the chain of all buffers, including killed buffers. This chain is used only for allocation and garbage collection, in order to collect killed buffers properly.
The character and byte positions of point in a buffer.
The character and byte positions of the beginning of the accessible range of text in the buffer.
The character and byte positions of the end of the accessible range of text in the buffer.
In an indirect buffer, this points to the base buffer. In an ordinary buffer, it is null.
This field contains flags indicating that certain variables are local in this buffer. Such variables are declared in the C code using
DEFVAR_PER_BUFFER, and their buffer-local bindings are stored in fields in the buffer structure itself. (Some of these fields are described in this table.)
The modification time of the visited file. It is set when the file is written or read. Before writing the buffer into a file, this field is compared to the modification time of the file to see if the file has changed on disk. See Buffer Modification.
The time when the buffer was last auto-saved.
window-start position in the buffer as of the last time the buffer was displayed in a window.
This flag indicates that narrowing has changed in the buffer. See Narrowing.
This flag indicates that redisplay optimizations should not be used to display this buffer.
This field holds the current overlay center position. See Managing Overlays.
These fields hold, respectively, a list of overlays that end at or before the current overlay center, and a list of overlays that end after the current overlay center. See Managing Overlays.
overlays_before is sorted in order of decreasing end position, and
overlays_after is sorted in order of increasing beginning position.
A Lisp string that names the buffer. It is guaranteed to be unique. See Buffer Names. This and the following fields have their names in the C struct definition end in a
_ to indicate that they should not be accessed directly, but via the
BVAR macro, like this:
Lisp_Object buf_name = BVAR (buffer, name);
The length of the file this buffer is visiting, when last read or saved. It can have 2 special values: -1 means auto-saving was turned off in this buffer, and -2 means don’t turn off auto-saving if buffer text shrinks a lot. This and other fields concerned with saving are not kept in the
buffer_text structure because indirect buffers are never saved.
The directory for expanding relative file names. This is the value of the buffer-local variable
default-directory (see File Name Expansion).
The name of the file visited in this buffer, or
nil. This is the value of the buffer-local variable
buffer-file-name (see Buffer File Name).
These fields store the values of Lisp variables that are automatically buffer-local (see Buffer-Local Variables), whose corresponding variable names have the additional prefix
buffer- and have underscores replaced with dashes. For instance,
undo_list stores the value of
The mark for the buffer. The mark is a marker, hence it is also included on the list
markers. See The Mark.
The association list describing the buffer-local variable bindings of this buffer, not including the built-in buffer-local bindings that have special slots in the buffer object. (Those slots are omitted from this table.) See Buffer-Local Variables.
Symbol naming the major mode of this buffer, e.g.,
Pretty name of the major mode, e.g.,
These fields store the buffer’s local keymap (see Keymaps), abbrev table (see Abbrev Tables), syntax table (see Syntax Tables), category table (see Categories), and display table (see Display Tables).
These fields store the conversion tables for converting text to lower case, upper case, and for canonicalizing text for case-fold search. See Case Tables.
An alist of the minor modes of this buffer.
These fields are only used in an indirect buffer, or in a buffer that is the base of an indirect buffer. Each holds a marker that records
zv respectively, for this buffer when the buffer is not current.
These fields store the values of Lisp variables that are automatically buffer-local (see Buffer-Local Variables), whose corresponding variable names have underscores replaced with dashes. For instance,
mode_line_format stores the value of
This is the last window that was selected with this buffer in it, or
nil if that window no longer displays this buffer.