diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/buffer-names.html | |
new repository
Diffstat (limited to 'devdocs/elisp/buffer-names.html')
| -rw-r--r-- | devdocs/elisp/buffer-names.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/devdocs/elisp/buffer-names.html b/devdocs/elisp/buffer-names.html new file mode 100644 index 00000000..dcd9dbaa --- /dev/null +++ b/devdocs/elisp/buffer-names.html @@ -0,0 +1,53 @@ + <h3 class="section">Buffer Names</h3> <p>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 <var>buffer-or-name</var> is of this sort, and an error is signaled if it is neither a string nor a buffer. Any argument called <var>buffer</var> must be an actual buffer object, not a name. </p> <p>Buffers that are ephemeral and generally uninteresting to the user have names starting with a space, so that the <code>list-buffers</code> and <code>buffer-menu</code> commands don’t mention them (but if such a buffer visits a file, it <strong>is</strong> mentioned). A name starting with space also initially disables recording undo information; see <a href="undo">Undo</a>. </p> <dl> <dt id="buffer-name">Function: <strong>buffer-name</strong> <em>&optional buffer</em> +</dt> <dd> +<p>This function returns the name of <var>buffer</var> as a string. <var>buffer</var> defaults to the current buffer. </p> <p>If <code>buffer-name</code> returns <code>nil</code>, it means that <var>buffer</var> has been killed. See <a href="killing-buffers">Killing Buffers</a>. </p> <div class="example"> <pre class="example">(buffer-name) + ⇒ "buffers.texi" +</pre> + +<pre class="example">(setq foo (get-buffer "temp")) + ⇒ #<buffer temp> +</pre> +<pre class="example">(kill-buffer foo) + ⇒ nil +</pre> +<pre class="example">(buffer-name foo) + ⇒ nil +</pre> +<pre class="example">foo + ⇒ #<killed buffer> +</pre> +</div> </dd> +</dl> <dl> <dt id="rename-buffer">Command: <strong>rename-buffer</strong> <em>newname &optional unique</em> +</dt> <dd> +<p>This function renames the current buffer to <var>newname</var>. An error is signaled if <var>newname</var> is not a string. </p> <p>Ordinarily, <code>rename-buffer</code> signals an error if <var>newname</var> is already in use. However, if <var>unique</var> is non-<code>nil</code>, it modifies <var>newname</var> to make a name that is not in use. Interactively, you can make <var>unique</var> non-<code>nil</code> with a numeric prefix argument. (This is how the command <code>rename-uniquely</code> is implemented.) </p> <p>This function returns the name actually given to the buffer. </p> +</dd> +</dl> <dl> <dt id="get-buffer">Function: <strong>get-buffer</strong> <em>buffer-or-name</em> +</dt> <dd> +<p>This function returns the buffer specified by <var>buffer-or-name</var>. If <var>buffer-or-name</var> is a string and there is no buffer with that name, the value is <code>nil</code>. If <var>buffer-or-name</var> is a buffer, it is returned as given; that is not very useful, so the argument is usually a name. For example: </p> <div class="example"> <pre class="example">(setq b (get-buffer "lewis")) + ⇒ #<buffer lewis> +</pre> +<pre class="example">(get-buffer b) + ⇒ #<buffer lewis> +</pre> +<pre class="example">(get-buffer "Frazzle-nots") + ⇒ nil +</pre> +</div> <p>See also the function <code>get-buffer-create</code> in <a href="creating-buffers">Creating Buffers</a>. </p> +</dd> +</dl> <dl> <dt id="generate-new-buffer-name">Function: <strong>generate-new-buffer-name</strong> <em>starting-name &optional ignore</em> +</dt> <dd> +<p>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</var>, and produces a name not currently in use for any buffer by appending a number inside of ‘<samp><…></samp>’. It starts at 2 and keeps incrementing the number until it is not the name of an existing buffer. </p> <p>If the optional second argument <var>ignore</var> is non-<code>nil</code>, it should be a string, a potential buffer name. It means to consider that potential buffer acceptable, if it is tried, even if it is the name of an existing buffer (which would normally be rejected). Thus, if buffers named ‘<samp>foo</samp>’, ‘<samp>foo<2></samp>’, ‘<samp>foo<3></samp>’ and ‘<samp>foo<4></samp>’ exist, </p> <div class="example"> <pre class="example">(generate-new-buffer-name "foo") + ⇒ "foo<5>" +(generate-new-buffer-name "foo" "foo<3>") + ⇒ "foo<3>" +(generate-new-buffer-name "foo" "foo<6>") + ⇒ "foo<5>" +</pre> +</div> <p>See the related function <code>generate-new-buffer</code> in <a href="creating-buffers">Creating Buffers</a>. </p> +</dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Names.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Names.html</a> + </p> +</div> |
