Next: Buffer File Name, Previous: Current Buffer, Up: Buffers [Contents][Index]
Each buffer has a unique name, which is a string. Many of the functions that work on buffers accept either a buffer or a buffer name as an argument. Any argument called buffer-or-name is of this sort, and an error is signaled if it is neither a string nor a buffer. Any argument called buffer must be an actual buffer object, not a name.
Buffers that are ephemeral and generally uninteresting to the user
have names starting with a space, so that the list-buffers
and
buffer-menu
commands don’t mention them. A name starting with
space also initially disables recording undo information; see
Undo.
This function returns the name of buffer as a string. If buffer is not supplied, it defaults to the current buffer.
If buffer-name
returns nil
, it means that buffer
has been killed. See Killing Buffers.
(buffer-name) ⇒ "buffers.texi"
(setq foo (get-buffer "temp")) ⇒ #<buffer temp>
(kill-buffer foo) ⇒ nil
(buffer-name foo) ⇒ nil
foo ⇒ #<killed buffer>
This function renames the current buffer to newname. An error
is signaled if newname is not a string, or if there is already a
buffer with that name. The function returns nil
.
Ordinarily, rename-buffer
signals an error if newname is
already in use. However, if unique is non-nil
, it modifies
newname to make a name that is not in use. Interactively, you can
make unique non-nil
with a numeric prefix argument.
One application of this command is to rename the ‘*shell*’ buffer to some other name, thus making it possible to create a second shell buffer under the name ‘*shell*’.
This function returns the buffer named buffer-or-name. If
buffer-or-name is a string and there is no buffer with that name,
the value is nil
. If buffer-or-name is actually a buffer,
it is returned as given. (That is not very useful, so the argument is
usually a name.) For example:
(setq b (get-buffer "lewis")) ⇒ #<buffer lewis>
(get-buffer b) ⇒ #<buffer lewis>
(get-buffer "Frazzle-nots") ⇒ nil
See also the function get-buffer-create
in Creating Buffers.
This function returns a name that would be unique for a new buffer—but does not create the buffer. It starts with starting-name, and produces a name not currently in use for any buffer by appending a number inside of ‘<…>’.
If ignore is given, it specifies a name that is okay to use (if it is in the sequence to be tried), even if a buffer with that name exists.
See the related function generate-new-buffer
in Creating Buffers.
Next: Buffer File Name, Previous: Current Buffer, Up: Buffers [Contents][Index]