Previous: , Up: Buffers   [Contents][Index]


37.11 Indirect Buffers

An indirect buffer shares the text of some other buffer, which is called the base buffer of the indirect buffer. In some ways it is the analogue, for buffers, of a symbolic link among files. The base buffer may not itself be an indirect buffer. One base buffer may have several indirect children.

The text of the indirect buffer is always identical to the text of its base buffer; changes made by editing either one are visible immediately in the other.

But in all other respects, the indirect buffer and its base buffer are completely separate. They have different names, different values of point and mark, different narrowing, different markers and extents (though inserting or deleting text in either buffer relocates the markers and extents for both), different font-locking, different major modes, and different local variables.

Note: Unlike in FSF Emacs, SXEmacs indirect buffers do not automatically share text properties among themselves and their base buffer.

An indirect buffer cannot visit a file, but its base buffer can. If you try to save the indirect buffer, that actually works by saving the base buffer.

Killing an indirect buffer has no effect on its base buffer. Killing the base buffer kills all its indirect children.

Command: make-indirect-buffer base-buffer name

This creates an indirect buffer named name whose base buffer is base-buffer. The argument base-buffer may be a buffer or a string.

If base-buffer is an indirect buffer, its base buffer is used as the base for the new buffer.

(make-indirect-buffer "*scratch*" "indirect")
     ⇒ #<buffer "indirect">
Function: buffer-base-buffer &optional buffer

This function returns the base buffer of buffer. If buffer is not indirect, the value is nil. Otherwise, the value is another buffer, which is never an indirect buffer. If buffer is not supplied, it defaults to the current buffer.

(buffer-base-buffer (get-buffer "indirect"))
     ⇒ #<buffer "*scratch*">
Function: buffer-indirect-children &optional buffer

This function returns a list of all indirect buffers whose base buffer is buffer. If buffer is indirect, the return value will always be nil; see make-indirect-buffer. If buffer is not supplied, it defaults to the current buffer.

(buffer-indirect-children (get-buffer "*scratch*"))
     ⇒ (#<buffer "indirect">)

Previous: , Up: Buffers   [Contents][Index]