@c This is part of the Emacs manual.
-@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
+@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012
@c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
-@node Buffers, Windows, Files, Top
+@node Buffers
@chapter Using Multiple Buffers
@cindex buffers
the file's text. Each time you invoke Dired, a buffer is used to hold
the directory listing. If you send a message with @kbd{C-x m}, a
buffer is used to hold the text of the message. When you ask for a
-command's documentation, that appears in a buffer named @samp{*Help*}.
+command's documentation, that appears in a buffer named @file{*Help*}.
Each buffer has a unique name, which can be of any length. When a
buffer is displayed in a window, its name is shown in the mode line
matters in buffer names. Most buffers are made by visiting files, and
their names are derived from the files' names; however, you can also
create an empty buffer with any name you want. A newly started Emacs
-has several buffers, including one named @samp{*scratch*}, which can
+has several buffers, including one named @file{*scratch*}, which can
be used for evaluating Lisp expressions and is not associated with any
file (@pxref{Lisp Interaction}).
For typical 64-bit machines, this maximum buffer size is @math{2^61 -
2} bytes, or about 2 EiB. For typical 32-bit machines, the maximum is
usually @math{2^29 - 2} bytes, or about 512 MiB. Buffer sizes are
-also limited by the amount of memory present in the system.
+also limited by the amount of memory in the system.
@menu
* Select Buffer:: Creating a new buffer or reselecting an old one.
name using the minibuffer. Then it makes that buffer current, and
displays it in the currently-selected window. An empty input
specifies the buffer that was current most recently among those not
-now displayed in any window. If you specify a buffer that does not
-exist, @kbd{C-x b} creates a new, empty buffer that is not visiting
-any file, and selects it for editing.
+now displayed in any window.
While entering the buffer name, you can use the usual completion and
history commands (@pxref{Minibuffer}). Note that @kbd{C-x b}, and
@samp{[Confirm]} and you must type a second @key{RET} to submit that
buffer name. @xref{Completion Exit}, for details.
- One reason to create a new buffer is to use it for making temporary
-notes. If you try to save it, Emacs asks for the file name to use.
-The default value of the variable @code{major-mode} determines the new
-buffer's major mode; the default value is Fundamental mode. @xref{Major
-Modes}.
+ If you specify a buffer that does not exist, @kbd{C-x b} creates a
+new, empty buffer that is not visiting any file, and selects it for
+editing. The default value of the variable @code{major-mode}
+determines the new buffer's major mode; the default value is
+Fundamental mode. @xref{Major Modes}. One reason to create a new
+buffer is to use it for making temporary notes. If you try to save
+it, Emacs asks for the file name to use, and the buffer's major mode
+is re-established taking that file name into account (@pxref{Choosing
+Modes}).
@kindex C-x @key{LEFT}
@kindex C-x @key{RIGHT}
@findex next-buffer
@findex previous-buffer
For conveniently switching between a few buffers, use the commands
-@kbd{C-x @key{LEFT}} and @kbd{C-x @key{RIGHT}}. @kbd{C-x @key{RIGHT}}
-(@code{previous-buffer}) selects the previous buffer (following the order
-of most recent selection in the current frame), while @kbd{C-x @key{LEFT}}
-(@code{next-buffer}) moves through buffers in the reverse direction.
+@kbd{C-x @key{LEFT}} and @kbd{C-x @key{RIGHT}}. @kbd{C-x @key{LEFT}}
+(@code{previous-buffer}) selects the previous buffer (following the
+order of most recent selection in the current frame), while @kbd{C-x
+@key{RIGHT}} (@code{next-buffer}) moves through buffers in the reverse
+direction.
@kindex C-x 4 b
@findex switch-to-buffer-other-window
@samp{.} in the first field of a line indicates that the buffer is
current. @samp{%} indicates a read-only buffer. @samp{*} indicates
-that the buffer is ``modified.'' If several buffers are modified, it
+that the buffer is ``modified''. If several buffers are modified, it
may be time to save some with @kbd{C-x s} (@pxref{Save Commands}).
Here is an example of a buffer list:
@end smallexample
@noindent
-The buffer @samp{*Help*} was made by a help request (@pxref{Help}); it
+The buffer @file{*Help*} was made by a help request (@pxref{Help}); it
is not visiting any file. The buffer @code{src} was made by Dired on
the directory @file{~/cvs/emacs/src/}. You can list only buffers that
are visiting files by giving the command a prefix argument, as in
@table @kbd
@item C-x C-q
-Toggle read-only status of buffer (@code{toggle-read-only}).
+Toggle read-only status of buffer (@code{read-only-mode}).
@item M-x rename-buffer @key{RET} @var{name} @key{RET}
Change the name of the current buffer.
@item M-x rename-uniquely
Rename the current buffer by adding @samp{<@var{number}>} to the end.
@item M-x view-buffer @key{RET} @var{buffer} @key{RET}
-Scroll through buffer @var{buffer}.
+Scroll through buffer @var{buffer}. @xref{View Mode}.
@end table
@kindex C-x C-q
have special commands to operate on the text; also by visiting a file
whose access control says you cannot write it.
-@findex toggle-read-only
- The command @kbd{C-x C-q} (@code{toggle-read-only}) makes a read-only
+@findex read-only-mode
+@vindex view-read-only
+ The command @kbd{C-x C-q} (@code{read-only-mode}) makes a read-only
buffer writable, and makes a writable buffer read-only. This works by
setting the variable @code{buffer-read-only}, which has a local value
in each buffer and makes the buffer read-only if its value is
-non-@code{nil}.
+non-@code{nil}. If you change the option @code{view-read-only} to a
+non-@code{nil} value, making the buffer read-only with @kbd{C-x C-q}
+also enables View mode in the buffer (@pxref{View Mode}).
@findex rename-buffer
@kbd{M-x rename-buffer} changes the name of the current buffer. You
@kbd{M-x rename-uniquely} renames the current buffer to a similar
name with a numeric suffix added to make it both different and unique.
This command does not need an argument. It is useful for creating
-multiple shell buffers: if you rename the @samp{*shell*} buffer, then
+multiple shell buffers: if you rename the @file{*shell*} buffer, then
do @kbd{M-x shell} again, it makes a new shell buffer named
-@samp{*shell*}; meanwhile, the old shell buffer continues to exist
+@file{*shell*}; meanwhile, the old shell buffer continues to exist
under its new name. This method is also good for mail buffers,
compilation buffers, and most Emacs features that create special
buffers with particular names. (With some of these features, such as
-@kbd{M-x compile}, @kbd{M-x grep} an @kbd{M-x info}, you need to
-switch to some other buffer before using the command, in order for it
-to make a different buffer.)
+@kbd{M-x compile}, @kbd{M-x grep}, you need to switch to some other
+buffer before using the command again, otherwise it will reuse the
+current buffer despite the name change.)
The commands @kbd{M-x append-to-buffer} and @kbd{M-x insert-buffer}
-can be used to copy text from one buffer to another. @xref{Accumulating
-Text}.
+can also be used to copy text from one buffer to another.
+@xref{Accumulating Text}.
@node Kill Buffer
@section Killing Buffers
@cindex Midnight mode
@vindex midnight-mode
@vindex midnight-hook
- You can also have this buffer purging done for you, every day at
-midnight, by enabling Midnight mode. Midnight mode operates each day
+ You can also have this buffer purging done for you, once a day,
+by enabling Midnight mode. Midnight mode operates each day
at midnight; at that time, it runs @code{clean-buffer-list}, or
whichever functions you have placed in the normal hook
@code{midnight-hook} (@pxref{Hooks}). To enable Midnight mode, use
@findex buffer-menu
@findex buffer-menu-other-window
To use the buffer menu, type @kbd{C-x C-b} and switch to the window
-displaying the @samp{*Buffer List*} buffer. You can also type
+displaying the @file{*Buffer List*} buffer. You can also type
@kbd{M-x buffer-menu} to open the buffer menu in the selected window.
Alternatively, the command @kbd{M-x buffer-menu-other-window} opens
the buffer menu in another window, and selects that window.
The buffer menu is a read-only buffer, and can be changed only
through the special commands described in this section. The usual
-Emacs cursor motion commands can be used in this buffer. The
+cursor motion commands can be used in this buffer. The
following commands apply to the buffer described on the current line:
@table @kbd
@table @kbd
@item ~
-Mark the buffer ``unmodified.'' The command @kbd{~} does this
+Mark the buffer ``unmodified''. The command @kbd{~} does this
immediately when you type it.
@item %
Toggle the buffer's read-only flag. The command @kbd{%} does
visible buffer in its place.
@item @key{RET}
@itemx f
-Immediately select this line's buffer in place of the @samp{*Buffer
+Immediately select this line's buffer in place of the @file{*Buffer
List*} buffer.
@item o
Immediately select this line's buffer in another window as if by
-@kbd{C-x 4 b}, leaving @samp{*Buffer List*} visible.
+@kbd{C-x 4 b}, leaving @file{*Buffer List*} visible.
@item C-o
Immediately display this line's buffer in another window, but don't
select the window.
@item 2
Immediately set up two windows, with this line's buffer selected in
one, and the previously current buffer (aside from the buffer
-@samp{*Buffer List*}) displayed in the other.
+@file{*Buffer List*}) displayed in the other.
@item b
Bury the buffer listed on this line.
@item m
suitable buffer, and turn on Buffer Menu mode in it. Everything else
described above is implemented by the special commands provided in
Buffer Menu mode. One consequence of this is that you can switch from
-the @samp{*Buffer List*} buffer to another Emacs buffer, and edit
-there. You can reselect the @samp{*Buffer List*} buffer later, to
+the @file{*Buffer List*} buffer to another Emacs buffer, and edit
+there. You can reselect the @file{*Buffer List*} buffer later, to
perform the operations already requested, or you can kill it, or pay
no further attention to it.
- Normally, the buffer @samp{*Buffer List*} is not updated
+ Normally, the buffer @file{*Buffer List*} is not updated
automatically when buffers are created and killed; its contents are
just text. If you have created, deleted or renamed buffers, the way
-to update @samp{*Buffer List*} to show what you have done is to type
+to update @file{*Buffer List*} to show what you have done is to type
@kbd{g} (@code{revert-buffer}). You can make this happen regularly
every @code{auto-revert-interval} seconds if you enable Auto Revert
mode in this buffer, as long as it is not marked modified. Global
-Auto Revert mode applies to the @samp{*Buffer List*} buffer only if
+Auto Revert mode applies to the @file{*Buffer List*} buffer only if
@code{global-auto-revert-non-file-buffers} is non-@code{nil}.
@iftex
@inforef{Autorevert,, emacs-xtra}, for details.
An @dfn{indirect buffer} shares the text of some other buffer, which
is called the @dfn{base buffer} of the indirect buffer. In some ways it
-is the analogue, for buffers, of a symbolic link between files.
+is a buffer analogue of a symbolic link between files.
@table @kbd
@findex make-indirect-buffer
@item M-x make-indirect-buffer @key{RET} @var{base-buffer} @key{RET} @var{indirect-name} @key{RET}
-Create an indirect buffer named @var{indirect-name} whose base buffer
-is @var{base-buffer}.
+Create an indirect buffer named @var{indirect-name} with base buffer
+@var{base-buffer}.
@findex clone-indirect-buffer
@item M-x clone-indirect-buffer @key{RET}
Create an indirect buffer that is a twin copy of the current buffer.
@code{clone-indirect-buffer-hook} after creating the indirect buffer.
The more general way to make an indirect buffer is with the command
-@kbd{M-x make-indirect-buffer}. It creates an indirect buffer from
-buffer @var{base-buffer}, under the name @var{indirect-name}. It
-prompts for both @var{base-buffer} and @var{indirect-name} using the
-minibuffer.
+@kbd{M-x make-indirect-buffer}. It creates an indirect buffer
+named @var{indirect-name} from a buffer @var{base-buffer}, prompting for
+both using the minibuffer.
@node Buffer Convenience
@section Convenience Features and Customization of Buffer Handling
Iswitchb global minor mode provides convenient switching between
buffers using substrings of their names. It replaces the normal
definitions of @kbd{C-x b}, @kbd{C-x 4 b}, @kbd{C-x 5 b}, and @kbd{C-x
-4 C-o} with alternative commands that are somewhat ``smarter.''
+4 C-o} with alternative commands that are somewhat ``smarter''.
When one of these commands prompts you for a buffer name, you can
type in just a substring of the name you want to choose. As you enter