]> code.delx.au - gnu-emacs/blobdiff - lispref/buffers.texi
*** empty log message ***
[gnu-emacs] / lispref / buffers.texi
index 670b147a3b8ef09b036f3c597e7b14cd61cc304f..c0eb2ee666491e00b46072d5ba96ecbf755624f5 100644 (file)
@@ -1,6 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. 
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2002, 2003,
+@c   2004, 2005, 2006 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/buffers
 @node Buffers, Windows, Backups and Auto-Saving, Top
@@ -36,7 +37,7 @@ not be displayed in any windows.
 @comment  node-name,  next,  previous,  up
 @section Buffer Basics
 
-@ifinfo
+@ifnottex
   A @dfn{buffer} is a Lisp object containing text to be edited.  Buffers
 are used to hold the contents of files that are being visited; there may
 also be buffers that are not visiting files.  Although several buffers
@@ -44,7 +45,7 @@ normally exist, only one buffer is designated the @dfn{current
 buffer} at any time.  Most editing commands act on the contents of the
 current buffer.  Each buffer, including the current buffer, may or may
 not be displayed in any windows.
-@end ifinfo
+@end ifnottex
 
   Buffers in Emacs editing are objects that have distinct names and hold
 text that can be edited.  Buffers appear to Lisp programs as a special
@@ -105,7 +106,7 @@ Emacs reads a command is the buffer that the command will apply to.
 switch visibly to a different buffer so that the user can edit it.  For
 that, you must use the functions described in @ref{Displaying Buffers}.
 
-  @strong{Note:} Lisp functions that change to a different current buffer
+  @strong{Warning:} Lisp functions that change to a different current buffer
 should not depend on the command loop to set it back afterwards.
 Editing commands written in Emacs Lisp can be called from other programs
 as well as from the command loop; it is convenient for the caller if
@@ -137,7 +138,7 @@ Next, @code{set-buffer} makes the specified buffer current.  Finally,
 @code{insert-buffer-substring} copies the string from the original
 current buffer to the specified (and now current) buffer.
 
-  If the buffer appended to happens to be displayed in some window, 
+  If the buffer appended to happens to be displayed in some window,
 the next redisplay will show how its text has changed.  Otherwise, you
 will not see the change immediately on the screen.  The buffer becomes
 current temporarily during the execution of the command, but this does
@@ -201,13 +202,12 @@ An error is signaled if @var{buffer-or-name} does not identify an
 existing buffer.
 @end defun
 
-@defspec save-current-buffer body...
-@tindex save-current-buffer
-The @code{save-current-buffer} macro 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 form in
-@var{body}.  The current buffer is restored even in case of an abnormal
-exit via @code{throw} or error (@pxref{Nonlocal Exits}).
+@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
+form in @var{body}.  The current buffer is restored even in case of an
+abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}).
 
 If the buffer that used to be current has been killed by the time of
 exit from @code{save-current-buffer}, then it is not made current again,
@@ -215,17 +215,20 @@ of course.  Instead, whichever buffer was current just before exit
 remains current.
 @end defspec
 
-@defmac with-current-buffer buffer body...
-@tindex with-current-buffer
+@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} current, evaluates the @var{body} forms, and
-finally restores the buffer.  The return value is the value of the last
-form in @var{body}.  The current buffer is restored even in case of an
-abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}).
+buffer, makes @var{buffer-or-name} current, evaluates the @var{body}
+forms, and finally restores the buffer.  The return value is the value
+of the last form in @var{body}.  The current buffer is restored even
+in case of an abnormal exit via @code{throw} or error (@pxref{Nonlocal
+Exits}).
+
+An error is signaled if @var{buffer-or-name} does not identify an
+existing buffer.
 @end defmac
 
-@defmac with-temp-buffer body...
-@tindex with-temp-buffer
+@defmac with-temp-buffer body@dots{}
+@anchor{Definition of with-temp-buffer}
 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,
@@ -238,9 +241,10 @@ return the contents of the temporary buffer by using
 
 The current buffer is restored even in case of an abnormal exit via
 @code{throw} or error (@pxref{Nonlocal Exits}).
-@end defmac
 
-See also @code{with-temp-file} in @ref{Writing to Files}.
+See also @code{with-temp-file} in @ref{Definition of with-temp-file,,
+Writing to Files}.
+@end defmac
 
 @node Buffer Names
 @section Buffer Names
@@ -255,7 +259,8 @@ object, not a name.
 
   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.  A name starting with
+@code{buffer-menu} commands don't mention them (but if such a buffer
+visits a file, it @strong{is} mentioned).  A name starting with
 space also initially disables recording undo information; see
 @ref{Undo}.
 
@@ -293,8 +298,7 @@ foo
 
 @deffn Command rename-buffer newname &optional unique
 This function renames the current buffer to @var{newname}.  An error
-is signaled if @var{newname} is not a string, or if there is already a
-buffer with that name.  The function returns @var{newname}.
+is signaled if @var{newname} is not a string.
 
 @c Emacs 19 feature
 Ordinarily, @code{rename-buffer} signals an error if @var{newname} is
@@ -302,13 +306,15 @@ already in use.  However, if @var{unique} is non-@code{nil}, it modifies
 @var{newname} to make a name that is not in use.  Interactively, you can
 make @var{unique} non-@code{nil} with a numeric prefix argument.
 (This is how the command @code{rename-uniquely} is implemented.)
+
+This function returns the name actually given to the buffer.
 @end deffn
 
 @defun get-buffer buffer-or-name
 This function returns the buffer specified by @var{buffer-or-name}.
 If @var{buffer-or-name} is a string and there is no buffer with that
 name, the value is @code{nil}.  If @var{buffer-or-name} is a buffer, it
-is returned as given; that is not very useful, so the argument is usually 
+is returned as given; that is not very useful, so the argument is usually
 a name.  For example:
 
 @example
@@ -330,11 +336,28 @@ See also the function @code{get-buffer-create} in @ref{Creating Buffers}.
 @end defun
 
 @c Emacs 19 feature
-@defun generate-new-buffer-name starting-name
+@defun generate-new-buffer-name starting-name &optional ignore
 This function returns a name that would be unique for a new buffer---but
 does not create the buffer.  It starts with @var{starting-name}, and
 produces a name not currently in use for any buffer by appending a
-number inside of @samp{<@dots{}>}.
+number inside of @samp{<@dots{}>}.  It starts at 2 and keeps
+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, 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")
+     @result{} "foo<5>"
+(generate-new-buffer-name "foo" "foo<3>")
+     @result{} "foo<3>"
+(generate-new-buffer-name "foo" "foo<6>")
+     @result{} "foo<5>"
+@end example
 
 See the related function @code{generate-new-buffer} in @ref{Creating
 Buffers}.
@@ -370,7 +393,8 @@ supplied, it defaults to the current buffer.
 @defvar buffer-file-name
 This buffer-local variable contains the name of the file being visited
 in the current buffer, or @code{nil} if it is not visiting a file.  It
-is a permanent local variable, unaffected by @code{kill-local-variables}.
+is a permanent local variable, unaffected by
+@code{kill-all-local-variables}.
 
 @example
 @group
@@ -387,22 +411,27 @@ Emacs.
 @end defvar
 
 @defvar buffer-file-truename
-This buffer-local variable holds the truename of the file visited in the
-current buffer, or @code{nil} if no file is visited.  It is a permanent
-local, unaffected by @code{kill-local-variables}.  @xref{Truenames}.
+This buffer-local variable holds the abbreviated truename of the file
+visited in the current buffer, or @code{nil} if no file is visited.
+It is a permanent local, unaffected by
+@code{kill-all-local-variables}.  @xref{Truenames}, and
+@ref{Definition of abbreviate-file-name}.
 @end defvar
 
 @defvar buffer-file-number
 This buffer-local variable holds the file number and directory device
 number of the file visited in the current buffer, or @code{nil} if no
 file or a nonexistent file is visited.  It is a permanent local,
-unaffected by @code{kill-local-variables}.
+unaffected by @code{kill-all-local-variables}.
 
 The value is normally a list of the form @code{(@var{filenum}
 @var{devnum})}.  This pair of numbers uniquely identifies the file among
 all files accessible on the system.  See the function
 @code{file-attributes}, in @ref{File Attributes}, for more information
 about them.
+
+If @code{buffer-file-name} is the name of a symbolic link, then both
+numbers refer to the recursive target.
 @end defvar
 
 @defun get-file-buffer filename
@@ -410,7 +439,9 @@ This function returns the buffer visiting file @var{filename}.  If
 there is no such buffer, it returns @code{nil}.  The argument
 @var{filename}, which must be a string, is expanded (@pxref{File Name
 Expansion}), then compared against the visited file names of all live
-buffers.
+buffers.  Note that the buffer's @code{buffer-file-name} must match
+the expansion of @var{filename} exactly.  This function will not
+recognize other names for the same file.
 
 @example
 @group
@@ -424,25 +455,50 @@ the same file name.  In such cases, this function returns the first
 such buffer in the buffer list.
 @end defun
 
+@defun find-buffer-visiting filename &optional predicate
+This is like @code{get-file-buffer}, except that it can return any
+buffer visiting the file @emph{possibly under a different name}.  That
+is, the buffer's @code{buffer-file-name} does not need to match the
+expansion of @var{filename} exactly, it only needs to refer to the
+same file.  If @var{predicate} is non-@code{nil}, it should be a
+function of one argument, a buffer visiting @var{filename}.  The
+buffer is only considered a suitable return value if @var{predicate}
+returns non-@code{nil}.  If it can not find a suitable buffer to
+return, @code{find-buffer-visiting} returns @code{nil}.
+@end defun
+
 @deffn Command set-visited-file-name filename &optional no-query along-with-file
 If @var{filename} is a non-empty string, this function changes the
-name of the file visited in current buffer to @var{filename}.  (If the
+name of the file visited in the current buffer to @var{filename}.  (If the
 buffer had no visited file, this gives it one.)  The @emph{next time}
-the buffer is saved it will go in the newly-specified file.  This
-command marks the buffer as modified, since it does not (as far as Emacs
-knows) match the contents of @var{filename}, even if it matched the
-former visited file.
+the buffer is saved it will go in the newly-specified file.
+
+This command marks the buffer as modified, since it does not (as far
+as Emacs knows) match the contents of @var{filename}, even if it
+matched the former visited file.  It also renames the buffer to
+correspond to the new file name, unless the new name is already in
+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
-the buffer as having no visited file.
-
-Normally, this function asks the user for confirmation if the specified
-file already exists.  If @var{no-query} is non-@code{nil}, that prevents
-asking this question.
-
-If @var{along-with-file} is non-@code{nil}, that means to assume that the
-former visited file has been renamed to @var{filename}.
+the buffer as having no visited file, without changing the buffer's
+modified flag.
+
+Normally, this function asks the user for confirmation if there
+already is a buffer visiting @var{filename}.  If @var{no-query} is
+non-@code{nil}, that prevents asking this question.  If there already
+is a buffer visiting @var{filename}, and the user confirms or
+@var{query} is non-@code{nil}, this function makes the new buffer name
+unique by appending a number inside of @samp{<@dots{}>} to @var{filename}.
+
+If @var{along-with-file} is non-@code{nil}, that means to assume that
+the former visited file has been renamed to @var{filename}.  In this
+case, the command does not change the buffer's modified flag, nor the
+buffer's recorded last file modification time as reported by
+@code{visited-file-modtime} (@pxref{Modification Time}).  If
+@var{along-with-file} is @code{nil}, this function clears the recorded
+last file modification time, after which @code{visited-file-modtime}
+returns zero.
 
 @c Wordy to avoid overfull hbox.  --rjc 16mar92
 When the function @code{set-visited-file-name} is called interactively, it
@@ -498,10 +554,16 @@ function @code{force-mode-line-update} works by doing this:
 @end example
 @end defun
 
-@deffn Command not-modified
-This command marks the current buffer as unmodified, and not needing to
-be saved.  With prefix arg, it marks the buffer as modified, so that it
-will be saved at the next suitable occasion.
+@defun restore-buffer-modified-p flag
+Like @code{set-buffer-modified-p}, but does not force redisplay
+of mode lines.
+@end defun
+
+@deffn Command not-modified &optional arg
+This command marks the current buffer as unmodified, and not needing
+to be saved.  If @var{arg} is non-@code{nil}, it marks the buffer as
+modified, so that it will be saved at the next suitable occasion.
+Interactively, @var{arg} is the prefix argument.
 
 Don't use this function in programs, since it prints a message in the
 echo area; use @code{set-buffer-modified-p} (above) instead.
@@ -512,13 +574,14 @@ echo area; use @code{set-buffer-modified-p} (above) instead.
 This function returns @var{buffer}'s modification-count.  This is a
 counter that increments every time the buffer is modified.  If
 @var{buffer} is @code{nil} (or omitted), the current buffer is used.
+The counter can wrap around occasionally.
 @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 
+@cindex modification time, comparison of
 
   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
@@ -536,6 +599,16 @@ visited or saved it.
 
 The function returns @code{t} if the last actual modification time and
 Emacs's recorded modification time are the same, @code{nil} otherwise.
+It also returns @code{t} if the buffer has no recorded last
+modification time, that is if @code{visited-file-modtime} would return
+zero.
+
+It always returns @code{t} for buffers that are not visiting a file,
+even if @code{visited-file-modtime} returns a non-zero value.  For
+instance, it always returns @code{t} for dired buffers.  It returns
+@code{t} for buffers that are visiting a file that does not exist and
+never existed, but @code{nil} for file-visiting buffers whose file has
+been deleted.
 @end defun
 
 @defun clear-visited-file-modtime
@@ -551,10 +624,27 @@ file should not be done.
 
 @c Emacs 19 feature
 @defun visited-file-modtime
-This function returns the 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}.)
+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}.)
+
+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,
+@ifnottex
+@w{2**16 - 1.}
+@end ifnottex
+@tex
+@math{2^{16}-1}.
+@end tex
 @end defun
 
 @c Emacs 19 feature
@@ -564,7 +654,7 @@ of the visited file, to the value specified by @var{time} if @var{time}
 is not @code{nil}, and otherwise to the last modification time of the
 visited file.
 
-If @var{time} is not @code{nil}, it should have the form
+If @var{time} is neither @code{nil} nor zero, it should have the form
 @code{(@var{high} . @var{low})} or @code{(@var{high} @var{low})}, in
 either case containing two integers, each of which holds 16 bits of the
 time.
@@ -586,7 +676,7 @@ some other program has probably altered the file.
 Depending on the user's answer, the function may return normally, in
 which case the modification of the buffer proceeds, or it may signal a
 @code{file-supersession} error with data @code{(@var{filename})}, in which
-case the proposed buffer modification is not allowed.  
+case the proposed buffer modification is not allowed.
 
 This function is called automatically by Emacs on the proper
 occasions.  It exists so you can customize Emacs by redefining it.
@@ -601,7 +691,7 @@ See also the file locking mechanism in @ref{File Locks}.
 @cindex buffer, read-only
 
   If a buffer is @dfn{read-only}, then you cannot change its contents,
-although you may change your view of the contents by scrolling and 
+although you may change your view of the contents by scrolling and
 narrowing.
 
   Read-only buffers are used in two kinds of situations:
@@ -630,12 +720,13 @@ The buffer is read-only if this variable is non-@code{nil}.
 @end defvar
 
 @defvar inhibit-read-only
-If this variable is non-@code{nil}, then read-only buffers and read-only
-characters may be modified.  Read-only characters in a buffer are those
-that have non-@code{nil} @code{read-only} properties (either text
-properties or overlay properties).  @xref{Special Properties}, for more
-information about text properties.  @xref{Overlays}, for more
-information about overlays and their properties.
+If this variable is non-@code{nil}, then read-only buffers and,
+depending on the actual value, some or all read-only characters may be
+modified.  Read-only characters in a buffer are those that have
+non-@code{nil} @code{read-only} properties (either text properties or
+overlay properties).  @xref{Special Properties}, for more information
+about text properties.  @xref{Overlays}, for more information about
+overlays and their properties.
 
 If @code{inhibit-read-only} is @code{t}, all @code{read-only} character
 properties have no effect.  If @code{inhibit-read-only} is a list, then
@@ -643,17 +734,22 @@ properties have no effect.  If @code{inhibit-read-only} is a list, then
 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
 This function signals a @code{buffer-read-only} error if the current
-buffer is read-only.  @xref{Interactive Call}, for another way to
+buffer is read-only.  @xref{Using Interactive}, for another way to
 signal an error if the current buffer is read-only.
 @end defun
 
@@ -661,20 +757,24 @@ signal an error if the current buffer is 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 excises 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 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.
-
+  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).
+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.
 
@@ -700,7 +800,7 @@ which frames they were selected in.
 ;; @r{Note that the name of the minibuffer}
 ;;   @r{begins with a space!}
 (mapcar (function buffer-name) (buffer-list))
-    @result{} ("buffers.texi" " *Minibuf-1*" 
+    @result{} ("buffers.texi" " *Minibuf-1*"
         "buffer.c" "*Help*" "TAGS")
 @end group
 @end example
@@ -730,9 +830,9 @@ live buffer.
 @defun other-buffer &optional buffer visible-ok frame
 This function returns the first buffer in the buffer list other than
 @var{buffer}.  Usually this is the buffer selected most recently (in
-frame @var{frame} or else the currently selected frame), aside from
-@var{buffer}.  Buffers whose names start with a space are not considered
-at all.
+frame @var{frame} or else the currently selected frame, @pxref{Input
+Focus}), aside from @var{buffer}.  Buffers whose names start with a
+space are not considered at all.
 
 If @var{buffer} is not supplied (or if it is not a buffer), then
 @code{other-buffer} returns the first buffer in the selected frame's
@@ -741,7 +841,7 @@ buffer list that is not now visible in any window in a visible frame.
 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
@@ -757,7 +857,8 @@ If no suitable buffer exists, the buffer @samp{*scratch*} is returned
 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
@@ -790,12 +891,14 @@ buffer and gives it a unique name.
 subprocess can also create a buffer (@pxref{Processes}).
 
 @defun get-buffer-create name
-This function returns a buffer named @var{name}.  It returns an existing
+This function returns a buffer named @var{name}.  It returns a live
 buffer with that name, if one exists; otherwise, it creates a new
 buffer.  The buffer does not become the current buffer---this function
 does not change which buffer is current.
 
-An error is signaled if @var{name} is not a string.
+If @var{name} is a buffer instead of a string, it is returned, even if
+it is dead.  An error is signaled if @var{name} is neither a string
+nor a buffer.
 
 @example
 @group
@@ -804,8 +907,8 @@ An error is signaled if @var{name} is not a string.
 @end group
 @end example
 
-The major mode for the new buffer is set to Fundamental mode.  The
-variable @code{default-major-mode} is handled at a higher level.
+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}.
 @end defun
 
@@ -847,8 +950,8 @@ Names}.
 @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
@@ -879,13 +982,13 @@ this feature to test whether a buffer has been killed:
 
 @deffn Command kill-buffer buffer-or-name
 This function kills the buffer @var{buffer-or-name}, freeing all its
-memory for other uses or to be returned to the operating system.  It
-returns @code{nil}.
+memory for other uses or to be returned to the operating system.  If
+@var{buffer-or-name} is @code{nil}, it kills the current buffer.
 
 Any processes that have this buffer as the @code{process-buffer} are
 sent the @code{SIGHUP} signal, which normally causes them to terminate.
 (The basic meaning of @code{SIGHUP} is that a dialup line has been
-disconnected.)  @xref{Deleting Processes}.
+disconnected.)  @xref{Signals to Processes}.
 
 If the buffer is visiting a file and contains unsaved changes,
 @code{kill-buffer} asks the user to confirm before the buffer is killed.
@@ -895,16 +998,20 @@ for confirmation, clear the modified flag before calling
 
 Killing a buffer that is already dead has no effect.
 
+This function returns @code{t} if it actually killed the buffer.  It
+returns @code{nil} if the user refuses to confirm or if
+@var{buffer-or-name} was already dead.
+
 @smallexample
 (kill-buffer "foo.unchanged")
-     @result{} nil
+     @result{} t
 (kill-buffer "foo.changed")
 
 ---------- Buffer: Minibuffer ----------
 Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes}
 ---------- Buffer: Minibuffer ----------
 
-     @result{} nil
+     @result{} t
 @end smallexample
 @end deffn
 
@@ -921,17 +1028,32 @@ ask for confirmation from the user.  If any of them returns @code{nil},
 This is a normal hook run by @code{kill-buffer} after asking all the
 questions it is going to ask, just before actually killing the buffer.
 The buffer to be killed is current when the hook functions run.
-@xref{Hooks}.
+@xref{Hooks}.  This variable is a permanent local, so its local binding
+is not cleared by changing major modes.
 @end defvar
 
 @defvar buffer-offer-save
 This variable, if non-@code{nil} in a particular buffer, tells
-@code{save-buffers-kill-emacs} and @code{save-some-buffers} to offer to
-save that buffer, just as they offer to save file-visiting buffers.  The
-variable @code{buffer-offer-save} automatically becomes buffer-local
-when set for any reason.  @xref{Buffer-Local Variables}.
+@code{save-buffers-kill-emacs} and @code{save-some-buffers} (if the
+second optional argument to that function is @code{t}) to offer to
+save that buffer, just as they offer to save file-visiting buffers.
+@xref{Definition of save-some-buffers}.  The variable
+@code{buffer-offer-save} automatically becomes buffer-local when set
+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.
+@end defun
+
 @node Indirect Buffers
 @section Indirect Buffers
 @cindex indirect buffers
@@ -948,11 +1070,11 @@ in the other.  This includes the text properties as well as the characters
 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
@@ -962,19 +1084,41 @@ buffer.
 the base buffer effectively kills the indirect buffer in that it cannot
 ever again be the current buffer.
 
-@deffn Command make-indirect-buffer base-buffer name
-This creates an indirect buffer named @var{name} whose base buffer
-is @var{base-buffer}.  The argument @var{base-buffer} may be a buffer
-or a string.
+@deffn Command make-indirect-buffer base-buffer name &optional clone
+This creates and returns an indirect buffer named @var{name} whose
+base buffer is @var{base-buffer}.  The argument @var{base-buffer} may
+be a live buffer or the name (a string) of an existing buffer.  If
+@var{name} is the name of an existing buffer, an error is signaled.
+
+If @var{clone} is non-@code{nil}, then the indirect buffer originally
+shares the ``state'' of @var{base-buffer} such as major mode, minor
+modes, buffer local variables and so on.  If @var{clone} is omitted
+or @code{nil} the indirect buffer's state is set to the default state
+for new buffers.
+
 If @var{base-buffer} is an indirect buffer, its base buffer is used as
-the base for the new buffer.
+the base for the new buffer.  If, in addition, @var{clone} is
+non-@code{nil}, the initial state is copied from the actual base
+buffer, not from @var{base-buffer}.
 @end deffn
 
-@defun buffer-base-buffer buffer
-This function returns the base buffer of @var{buffer}.  If @var{buffer}
-is not indirect, the value is @code{nil}.  Otherwise, the value is
-another buffer, which is never an indirect buffer.
+@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
+@code{nil}.  Otherwise, the value is another buffer, which is never an
+indirect buffer.
 @end defun
 
 @node Buffer Gap
@@ -1000,3 +1144,7 @@ This function returns the current gap position in the current buffer.
 @defun gap-size
 This function returns the current gap size of the current buffer.
 @end defun
+
+@ignore
+   arch-tag: 2e53cfab-5691-41f6-b5a8-9c6a3462399c
+@end ignore