Next: , Previous: , Up: Buffers and Textual Representation   [Contents][Index]

17.3 Buffer Lists

Recall earlier that buffers are permanent objects, i.e. that they remain around until explicitly deleted. This entails that there is a list of all the buffers in existence. This list is actually an assoc-list (mapping from the buffer’s name to the buffer) and is stored in the global variable Vbuffer_alist.

The order of the buffers in the list is important: the buffers are ordered approximately from most-recently-used to least-recently-used. Switching to a buffer using switch-to-buffer, pop-to-buffer, etc. and switching windows using other-window, etc. usually brings the new current buffer to the front of the list. switch-to-buffer, other-buffer, etc. look at the beginning of the list to find an alternative buffer to suggest. You can also explicitly move a buffer to the end of the list using bury-buffer.

In addition to the global ordering in Vbuffer_alist, each frame has its own ordering of the list. These lists always contain the same elements as in Vbuffer_alist although possibly in a different order. buffer-list normally returns the list for the selected frame. This allows you to work in separate frames without things interfering with each other.

The standard way to look up a buffer given a name is get-buffer, and the standard way to create a new buffer is get-buffer-create, which looks up a buffer with a given name, creating a new one if necessary. These operations correspond exactly with the symbol operations intern-soft and intern, respectively. You can also force a new buffer to be created using generate-new-buffer, which takes a name and (if necessary) makes a unique name from this by appending a number, and then creates the buffer. This is basically like the symbol operation gensym.

Next: , Previous: , Up: Buffers and Textual Representation   [Contents][Index]