@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
-@c Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002,
+@c 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/buffers
@node Buffers, Windows, Backups and Auto-Saving, Top
existing buffer.
@end defun
-@defspec save-current-buffer body...
+@defspec save-current-buffer body@dots{}
The @code{save-current-buffer} special form saves the identity of the
current buffer, evaluates the @var{body} forms, and finally restores
that buffer as current. The return value is the value of the last
remains current.
@end defspec
-@defmac with-current-buffer buffer-or-name body...
+@defmac with-current-buffer buffer-or-name body@dots{}
The @code{with-current-buffer} macro saves the identity of the current
buffer, makes @var{buffer-or-name} current, evaluates the @var{body}
forms, and finally restores the buffer. The return value is the value
existing buffer.
@end defmac
+@defmac with-temp-buffer body@dots{}
@anchor{Definition of with-temp-buffer}
-@defmac with-temp-buffer body...
The @code{with-temp-buffer} macro evaluates the @var{body} forms
with a temporary buffer as the current buffer. It saves the identity of
the current buffer, creates a temporary buffer and makes it current,
evaluates the @var{body} forms, and finally restores the previous
-current buffer while killing the temporary buffer.
+current buffer while killing the temporary buffer. By default, undo
+information (@pxref{Undo}) is not recorded in the buffer created by
+this macro (but @var{body} can enable that, if needed).
The return value is the value of the last form in @var{body}. You can
return the contents of the temporary buffer by using
Any argument called @var{buffer} must be an actual buffer
object, not a name.
+@cindex hidden buffers
+@cindex buffers without undo information
Buffers that are ephemeral and generally uninteresting to the user
have names starting with a space, so that the @code{list-buffers} and
@code{buffer-menu} commands don't mention them (but if such a buffer
incrementing the number until it is not the name of an existing buffer.
If the optional second argument @var{ignore} is non-@code{nil}, it
-should be a string; it makes a difference if it is a name in the
-sequence of names to be tried. That name will be considered acceptable,
-if it is tried, even if a buffer with that name exists. Thus, if
-buffers named @samp{foo}, @samp{foo<2>}, @samp{foo<3>} and @samp{foo<4>}
-exist,
+should be a string, a potential buffer name. It means to consider
+that potential buffer acceptable, if it is tried, even it is the name
+of an existing buffer (which would normally be rejected). Thus, if
+buffers named @samp{foo}, @samp{foo<2>}, @samp{foo<3>} and
+@samp{foo<4>} exist,
@example
(generate-new-buffer-name "foo")
use.
If @var{filename} is @code{nil} or the empty string, that stands for
-``no visited file''. In this case, @code{set-visited-file-name} marks
+``no visited file.'' In this case, @code{set-visited-file-name} marks
the buffer as having no visited file, without changing the buffer's
modified flag.
echo area; use @code{set-buffer-modified-p} (above) instead.
@end deffn
-@c Emacs 19 feature
@defun buffer-modified-tick &optional buffer
This function returns @var{buffer}'s modification-count. This is a
counter that increments every time the buffer is modified. If
The counter can wrap around occasionally.
@end defun
+@defun buffer-chars-modified-tick &optional buffer
+This function returns @var{buffer}'s character-change modification-count.
+Changes to text properties leave this counter unchanged; however, each
+time text is inserted or removed from the buffer, the counter is reset
+to the value that would be returned by @code{buffer-modified-tick}.
+By comparing the values returned by two @code{buffer-chars-modified-tick}
+calls, you can tell whether a character change occurred in that buffer
+in between the calls. If @var{buffer} is @code{nil} (or omitted), the
+current buffer is used.
+@end defun
+
@node Modification Time
@comment node-name, next, previous, up
-@section Comparison of Modification Time
-@cindex comparison of modification time
-@cindex modification time, comparison of
+@section Buffer Modification Time
+@cindex comparing file modification time
+@cindex modification time of buffer
Suppose that you visit a file and make changes in its buffer, and
meanwhile the file itself is changed on disk. At this point, saving the
buffer would overwrite the changes in the file. Occasionally this may
be what you want, but usually it would lose valuable information. Emacs
therefore checks the file's modification time using the functions
-described below before saving the file.
+described below before saving the file. (@xref{File Attributes},
+for how to examine a file's modification time.)
@defun verify-visited-file-modtime buffer
This function compares what @var{buffer} has recorded for the
@c Emacs 19 feature
@defun visited-file-modtime
This function returns the current buffer's recorded last file
-modification time, as a list of the form @code{(@var{high} .
-@var{low})}. (This is the same format that @code{file-attributes}
-uses to return time values; see @ref{File Attributes}.)
-
-The function returns zero if the buffer has no recorded last
-modification time, which can happen, for instance, if the record has
-been explicitly cleared by @code{clear-visited-file-modtime} or if the
-buffer is not visiting a file. Note, however, that
-@code{visited-file-modtime} can return a non-zero value for some
-buffers that are not visiting files, but are nevertheless closely
-associated with a file. This happens, for instance, with dired
-buffers listing a directory. For such buffers,
-@code{visited-file-modtime} returns the last modification time of that
-directory, as recorded by dired.
+modification time, as a list of the form @code{(@var{high} @var{low})}.
+(This is the same format that @code{file-attributes} uses to return
+time values; see @ref{File Attributes}.)
+
+If the buffer has no recorded last modification time, this function
+returns zero. This case occurs, for instance, if the buffer is not
+visiting a file or if the time has been explicitly cleared by
+@code{clear-visited-file-modtime}. Note, however, that
+@code{visited-file-modtime} returns a list for some non-file buffers
+too. For instance, in a Dired buffer listing a directory, it returns
+the last modification time of that directory, as recorded by Dired.
For a new buffer visiting a not yet existing file, @var{high} is
@minus{}1 and @var{low} is 65535, that is,
@end defun
@defun ask-user-about-supersession-threat filename
-@cindex obsolete buffer
This function is used to ask a user how to proceed after an attempt to
-modify an obsolete buffer visiting file @var{filename}. An
-@dfn{obsolete buffer} is an unmodified buffer for which the associated
-file on disk is newer than the last save-time of the buffer. This means
-some other program has probably altered the file.
+modify an buffer visiting file @var{filename} when the file is newer
+than the buffer text. Emacs detects this because the modification
+time of the file on disk is newer than the last save-time of the
+buffer. This means some other program has probably altered the file.
@kindex file-supersession
Depending on the user's answer, the function may return normally, in
of the list (comparison is done with @code{eq}).
@end defvar
-@deffn Command toggle-read-only
-This command changes whether the current buffer is read-only. It is
+@deffn Command toggle-read-only &optional arg
+This command toggles whether the current buffer is read-only. It is
intended for interactive use; do not use it in programs. At any given
point in a program, you should know whether you want the read-only flag
on or off; so you can set @code{buffer-read-only} explicitly to the
proper value, @code{t} or @code{nil}.
+
+If @var{arg} is non-@code{nil}, it should be a raw prefix argument.
+@code{toggle-read-only} sets @code{buffer-read-only} to @code{t} if
+the numeric value of that prefix argument is positive and to
+@code{nil} otherwise. @xref{Prefix Command Arguments}.
@end deffn
@defun barf-if-buffer-read-only
@section The Buffer List
@cindex buffer list
- The @dfn{buffer list} is a list of all live buffers. Creating a
-buffer adds it to this list, and killing a buffer removes it. The
-order of the buffers in the list is based primarily on how recently
-each buffer has been displayed in the selected window. Buffers move
-to the front of the list when they are selected (selecting a window
-that already displays the buffer counts as selecting the buffer), and
+ The @dfn{buffer list} is a list of all live buffers. The order of
+the buffers in the list is based primarily on how recently each buffer
+has been displayed in a window. Several functions, notably
+@code{other-buffer}, use this ordering. A buffer list displayed for
+the user also follows this order.
+
+ Creating a buffer adds it to the end of the buffer list, and killing
+a buffer removes it. Buffers move to the front of the list when they
+are selected for display in a window (@pxref{Displaying Buffers}), and
to the end when they are buried (see @code{bury-buffer}, below).
-Several functions, notably @code{other-buffer}, use this ordering. A
-buffer list displayed for the user also follows this order.
+There are no functions available to the Lisp programmer which directly
+manipulate the buffer list.
In addition to the fundamental Emacs buffer list, each frame has its
own version of the buffer list, in which the buffers that have been
selected in that frame come first, starting with the buffers most
recently selected @emph{in that frame}. (This order is recorded in
-@var{frame}'s @code{buffer-list} frame parameter; see @ref{Window Frame
+@var{frame}'s @code{buffer-list} frame parameter; see @ref{Buffer
Parameters}.) The buffers that were never selected in @var{frame} come
afterward, ordered according to the fundamental Emacs buffer list.
If @var{frame} has a non-@code{nil} @code{buffer-predicate} parameter,
then @code{other-buffer} uses that predicate to decide which buffers to
consider. It calls the predicate once for each buffer, and if the value
-is @code{nil}, that buffer is ignored. @xref{Window Frame Parameters}.
+is @code{nil}, that buffer is ignored. @xref{Buffer Parameters}.
@c Emacs 19 feature
If @var{visible-ok} is @code{nil}, @code{other-buffer} avoids returning
This function puts @var{buffer-or-name} at the end of the buffer list,
without changing the order of any of the other buffers on the list.
This buffer therefore becomes the least desirable candidate for
-@code{other-buffer} to return.
+@code{other-buffer} to return. The argument can be either a buffer
+itself or the name of one.
@code{bury-buffer} operates on each frame's @code{buffer-list} parameter
as well as the frame-independent Emacs buffer list; therefore, the
@end example
The major mode for a newly created buffer is set to Fundamental mode.
-The variable @code{default-major-mode} is handled at a higher level.
-@xref{Auto Major Mode}.
+(The variable @code{default-major-mode} is handled at a higher level;
+see @ref{Auto Major Mode}.) If the name begins with a space, the
+buffer initially disables undo information recording (@pxref{Undo}).
@end defun
@defun generate-new-buffer name
@cindex killing buffers
@cindex buffers, killing
- @dfn{Killing a buffer} makes its name unknown to Emacs and makes its
-text space available for other use.
+ @dfn{Killing a buffer} makes its name unknown to Emacs and makes the
+memory space it occupied available for other use.
The buffer object for the buffer that has been killed remains in
existence as long as anything refers to it, but it is specially marked
for any reason. @xref{Buffer-Local Variables}.
@end defvar
+@defvar buffer-save-without-query
+This variable, if non-@code{nil} in a particular buffer, tells
+@code{save-buffers-kill-emacs} and @code{save-some-buffers} to save
+this buffer (if it's modified) without asking the user. The variable
+automatically becomes buffer-local when set for any reason.
+@end defvar
+
@defun buffer-live-p object
This function returns @code{t} if @var{object} is a buffer which has
not been killed, @code{nil} otherwise.
themselves.
In all other respects, the indirect buffer and its base buffer are
-completely separate. They have different names, different values of
-point, different narrowing, different markers and overlays (though
+completely separate. They have different names, independent values of
+point, independent narrowing, independent markers and overlays (though
inserting or deleting text in either buffer relocates the markers and
-overlays for both), different major modes, and different buffer-local
-variables.
+overlays for both), independent major modes, and independent
+buffer-local variable bindings.
An indirect buffer cannot visit a file, but its base buffer can. If
you try to save the indirect buffer, that actually saves the base
buffer, not from @var{base-buffer}.
@end deffn
+@defun clone-indirect-buffer newname display-flag &optional norecord
+This function creates and returns a new indirect buffer that shares
+the current buffer's base buffer and copies the rest of the current
+buffer's attributes. (If the current buffer is not indirect, it is
+used as the base buffer.)
+
+If @var{display-flag} is non-@code{nil}, that means to display the new
+buffer by calling @code{pop-to-buffer}. If @var{norecord} is
+non-@code{nil}, that means not to put the new buffer to the front of
+the buffer list.
+@end defun
+
@defun buffer-base-buffer &optional buffer
This function returns the base buffer of @var{buffer}, which defaults
to the current buffer. If @var{buffer} is not indirect, the value is