Next: , Previous: , Up: Files, Buffers, and Windows   [Contents][Index]


3.2 Buffers

In addition to some text, a buffer has several other user-visible attributes:

A name

A buffer is identified by its name, which allows it to be selected, destroyed, or otherwise manipulated.

A collection of modes

The modes present in a buffer alter the set of commands available and otherwise alter the behavior of the editor. For details see page

A modification flag

This flag is set whenever the text in a buffer is modified. It is often useful to know whether a buffer has been changed, since if it has it should probably be saved in its associated file eventually.

A write-protect flag

If this flag is true, then any attempt to modify the buffer will result in an error.

Command: Select Buffer (bound to C-x b)

This command prompts for the name of a existing buffer and makes that buffer the current buffer. The newly selected buffer is displayed in the current window, and editing commands now edit the text in that buffer. Each buffer has its own point, thus the point will be in the place it was the last time the buffer was selected. When prompting for the buffer, the default is the buffer that was selected before the current one.

Command: Select Previous Buffer (bound to C-M-l)
Command: Circulate Buffers (bound to C-M-L)

With no prefix argument, Select Previous Buffer selects the buffer that has been selected most recently, similar to C-x b Return. If given a prefix argument, then it does the same thing as Circulate Buffers.

Circulate Buffers moves back into successively earlier buffers in the buffer history. If the previous command was not Circulate Buffers or Select Previous Buffer, then it does the same thing as Select Previous Buffer, otherwise it moves to the next most recent buffer. The original buffer at the start of the excursion is made the previous buffer, so Select Previous Buffer will always take you back to where you started.

These commands are generally used together. Often Select Previous Buffer will take you where you want to go. If you don’t end up there, then using Circulate Buffers will do the trick.

Command: Create Buffer (bound to C-x M-b)

This command is very similar to Select Buffer, but the buffer need not already exist. If the buffer does not exist, a new empty buffer is created with the specified name.

Command: Kill Buffer (bound to C-x k)

This command is used to make a buffer go away. There is no way to restore a buffer that has been accidentally deleted, so the user is given a chance to save the hapless buffer if it has been modified. This command is poorly named, since it has nothing to do with killing text.

Command: List Buffers (bound to C-x C-b)

This command displays a list of all existing buffers in a pop-up window. A "*" is displayed before the name of each modified buffer. A buffer with no associated file is represented by the buffer name followed by the number of lines in the buffer. A buffer with an associated file are is represented by the name and type of the file, a space, and the device and directory. If the buffer name doesn’t match the associated file, then the buffer name is also displayed. When given a prefix argument, this command lists only the modified buffers.

Command: Buffer Not Modified (bound to M-~)

This command resets the current buffer’s modification flag — it does not save any changes. This is primarily useful in cases where a user accidentally modifies a buffer and then undoes the change. Resetting the modified flag indicates that the buffer has no changes that need to be written out.

Command: Check Buffer Modified (bound to C-x ~)

This command displays a message indicating whether the current buffer is modified.

Command: Set Buffer Read-Only

This command changes the flag that allows the current buffer to be modified. If a buffer is read-only, any attempt to modify it will result in an error. The buffer may be made writable again by repeating this command.

Command: Set Buffer Writable

This command ensures the current buffer is modifiable.

Command: Insert Buffer

This command prompts for the name of a buffer and inserts its contents at the point, pushing a buffer mark before inserting. The buffer inserted is unaffected.

Command: Rename Buffer

This command prompts for a new name for the current buffer, which defaults to a name derived from the associated filename.


Next: Files, Previous: Introduction, Up: Files, Buffers, and Windows   [Contents][Index]