[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19. Using Multiple Buffers

The messages you are processing in af reside in an object called a buffer. Each time you visit a folder, a buffer is created to hold the messages in the folder.

At any time, one and only one buffer is selected. It is also called the current buffer. Often we say that a command operates on "the buffer" as if there were only one; but really this means that the command operates on the selected buffer (most commands do).

When af has multiple windows, each window has a chosen buffer which is displayed there, but at any time only one of the windows is selected and its chosen buffer is the selected buffer. Each window's mode line displays the name of the buffer that the window is displaying (see section 20. Multiple Windows).

Each buffer has a name, which can be of any length, and you can select any buffer by giving its name. Most buffers are made by visiting files, and their names are derived from the files' names. But you can also create an empty buffer with any name you want. A newly started af has a buffer named `*scratch*' which can be used as a temporary place to store messages. The distinction between upper and lower case matters in buffer names.

Each buffer records individually what folder it is visiting, whether it is modified, and what major mode and minor modes are in effect in it (see section 3.3 Major Modes).

19.1 Creating and Selecting Buffers  Creating a new buffer or reselecting an old one.
19.2 Listing Existing Buffers  Getting a list of buffers that exist.
19.3 Killing Buffers  Killing buffers you no longer need.
19.4 Inserting a Buffer  You can insert one buffer into another.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.1 Creating and Selecting Buffers

C-x b buffer RET
Select or create a buffer named buffer (switch-to-buffer).
C-x 4 b buffer RET
Similar, but select buffer in another window (switch-to-buffer-other-window).

To select the buffer named bufname, type C-x b bufname RET. This runs the command switch-to-buffer with argument bufname. You can use completion on an abbreviation for the buffer name you want (see section 7.6 Completion). An empty argument to C-x b specifies the most recently selected buffer that is not displayed in any window.

Most buffers are created by visiting files, but you can also create a buffer explicitly by typing C-x b bufname RET. This makes a new, empty buffer which is not visiting any file, and selects it. If you try and save a buffer created in this way, you are asked for the file name to use.

Note that C-x C-f, and any other command for visiting a file, can also be used to switch to an existing file-visiting buffer. See section 18.3 Visiting Files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.2 Listing Existing Buffers

To display a list of all the buffers that exist, type C-x C-b. Each line in the list shows one buffer's name, major mode and visited file. The buffers are listed in the order, most recently visited first.

`*' or `+' at the beginning of a line indicates the buffer is modified or status modified. If several buffers are modified, it may be time to save some with C-x s (see section 18.6 Saving Files). `%' indicates a read-only buffer. `.' marks the selected buffer. Here is an example of a buffer list:

 
 MR Buffer         Size  Mode           File
 -- ------         ----  ----           ----
.*  malc             12  Mail           /var/spool/mail/malc
 +  af               21  Mail           /home/malc/Mail/af
    *scratch*         0  Mail


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.3 Killing Buffers

If you continue an af session for a while, you may accumulate a large number of buffers. You may then find it convenient to kill the buffers you no longer need. On most operating systems, killing a buffer releases its space back to the operating system so that other programs can use it. Here are some commands for killing buffers:

C-x k bufname RET
Kill buffer bufname (kill-buffer).
M-x kill-some-buffers
Offer to kill each buffer, one by one.

C-x k (kill-buffer) kills one buffer, whose name you specify in the minibuffer. The default, used if you type just RET in the minibuffer, is to kill the current buffer. If you kill the current buffer, another buffer is selected; one that has been selected recently but does not appear in any window now. If you ask to kill a file-visiting buffer that is modified, then you must confirm with yes before the buffer is killed.

The command M-x kill-some-buffers asks about each buffer, one by one. An answer of y means to kill the buffer. Killing the current buffer or a buffer containing unsaved changes selects a new buffer or asks for confirmation just like kill-buffer.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

19.4 Inserting a Buffer

Sometimes you may want to merge two buffers. An easy way to do this is to use M-x insert-buffer), which inserts the contents of the specified buffer into the current buffer at point, leaving mark at the start of the inserted contents and point after them. The buffer will still be visiting the folder you originally read, and so will be saved to its original folder.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Malc Arnold on August, 22 2002 using texi2html