summaryrefslogtreecommitdiff
path: root/devdocs/elisp/creating-buffers.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/creating-buffers.html')
-rw-r--r--devdocs/elisp/creating-buffers.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/devdocs/elisp/creating-buffers.html b/devdocs/elisp/creating-buffers.html
new file mode 100644
index 00000000..a5b79b8c
--- /dev/null
+++ b/devdocs/elisp/creating-buffers.html
@@ -0,0 +1,26 @@
+ <h3 class="section">Creating Buffers</h3> <p>This section describes the two primitives for creating buffers. <code>get-buffer-create</code> creates a buffer if it finds no existing buffer with the specified name; <code>generate-new-buffer</code> always creates a new buffer and gives it a unique name. </p> <p>Both functions accept an optional argument <var>inhibit-buffer-hooks</var>. If it is non-<code>nil</code>, the buffer they create does not run the hooks <code>kill-buffer-hook</code>, <code>kill-buffer-query-functions</code> (see <a href="killing-buffers">Killing Buffers</a>), and <code>buffer-list-update-hook</code> (see <a href="buffer-list">Buffer List</a>). This avoids slowing down internal or temporary buffers that are never presented to users or passed on to other applications. </p> <p>Other functions you can use to create buffers include <code>with-output-to-temp-buffer</code> (see <a href="temporary-displays">Temporary Displays</a>) and <code>create-file-buffer</code> (see <a href="visiting-files">Visiting Files</a>). Starting a subprocess can also create a buffer (see <a href="processes">Processes</a>). </p> <dl> <dt id="get-buffer-create">Function: <strong>get-buffer-create</strong> <em>buffer-or-name &amp;optional inhibit-buffer-hooks</em>
+</dt> <dd>
+<p>This function returns a buffer named <var>buffer-or-name</var>. The buffer returned does not become the current buffer—this function does not change which buffer is current. </p> <p><var>buffer-or-name</var> must be either a string or an existing buffer. If it is a string and a live buffer with that name already exists, <code>get-buffer-create</code> returns that buffer. If no such buffer exists, it creates a new buffer. If <var>buffer-or-name</var> is a buffer instead of a string, it is returned as given, even if it is dead. </p> <div class="example"> <pre class="example">(get-buffer-create "foo")
+ ⇒ #&lt;buffer foo&gt;
+</pre>
+</div> <p>The major mode for a newly created buffer is set to Fundamental mode. (The default value of the variable <code>major-mode</code> is handled at a higher level; see <a href="auto-major-mode">Auto Major Mode</a>.) If the name begins with a space, the buffer initially disables undo information recording (see <a href="undo">Undo</a>). </p>
+</dd>
+</dl> <dl> <dt id="generate-new-buffer">Function: <strong>generate-new-buffer</strong> <em>name &amp;optional inhibit-buffer-hooks</em>
+</dt> <dd>
+<p>This function returns a newly created, empty buffer, but does not make it current. The name of the buffer is generated by passing <var>name</var> to the function <code>generate-new-buffer-name</code> (see <a href="buffer-names">Buffer Names</a>). Thus, if there is no buffer named <var>name</var>, then that is the name of the new buffer; if that name is in use, a suffix of the form ‘<samp>&lt;<var>n</var>&gt;</samp>’, where <var>n</var> is an integer, is appended to <var>name</var>. </p> <p>An error is signaled if <var>name</var> is not a string. </p> <div class="example"> <pre class="example">(generate-new-buffer "bar")
+ ⇒ #&lt;buffer bar&gt;
+</pre>
+<pre class="example">(generate-new-buffer "bar")
+ ⇒ #&lt;buffer bar&lt;2&gt;&gt;
+</pre>
+<pre class="example">(generate-new-buffer "bar")
+ ⇒ #&lt;buffer bar&lt;3&gt;&gt;
+</pre>
+</div> <p>The major mode for the new buffer is set to Fundamental mode. The default value of the variable <code>major-mode</code> is handled at a higher level. See <a href="auto-major-mode">Auto Major Mode</a>. </p>
+</dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Creating-Buffers.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffers.html</a>
+ </p>
+</div>