summaryrefslogtreecommitdiff
path: root/devdocs/elisp/subroutines-of-visiting.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/subroutines-of-visiting.html
new repository
Diffstat (limited to 'devdocs/elisp/subroutines-of-visiting.html')
-rw-r--r--devdocs/elisp/subroutines-of-visiting.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/devdocs/elisp/subroutines-of-visiting.html b/devdocs/elisp/subroutines-of-visiting.html
new file mode 100644
index 00000000..2a3befb2
--- /dev/null
+++ b/devdocs/elisp/subroutines-of-visiting.html
@@ -0,0 +1,23 @@
+ <h4 class="subsection">Subroutines of Visiting</h4> <p>The <code>find-file-noselect</code> function uses two important subroutines which are sometimes useful in user Lisp code: <code>create-file-buffer</code> and <code>after-find-file</code>. This section explains how to use them. </p> <dl> <dt id="create-file-buffer">Function: <strong>create-file-buffer</strong> <em>filename</em>
+</dt> <dd>
+<p>This function creates a suitably named buffer for visiting <var>filename</var>, and returns it. It uses <var>filename</var> (sans directory) as the name if that name is free; otherwise, it appends a string such as ‘<samp>&lt;2&gt;</samp>’ to get an unused name. See also <a href="creating-buffers">Creating Buffers</a>. Note that the <samp>uniquify</samp> library affects the result of this function. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html#Uniquify">Uniquify</a> in <cite>The GNU Emacs Manual</cite>. </p> <p><strong>Please note:</strong> <code>create-file-buffer</code> does <em>not</em> associate the new buffer with a file and does not select the buffer. It also does not use the default major mode. </p> <div class="example"> <pre class="example">(create-file-buffer "foo")
+ ⇒ #&lt;buffer foo&gt;
+</pre>
+<pre class="example">(create-file-buffer "foo")
+ ⇒ #&lt;buffer foo&lt;2&gt;&gt;
+</pre>
+<pre class="example">(create-file-buffer "foo")
+ ⇒ #&lt;buffer foo&lt;3&gt;&gt;
+</pre>
+</div> <p>This function is used by <code>find-file-noselect</code>. It uses <code>generate-new-buffer</code> (see <a href="creating-buffers">Creating Buffers</a>). </p>
+</dd>
+</dl> <dl> <dt id="after-find-file">Function: <strong>after-find-file</strong> <em>&amp;optional error warn noauto after-find-file-from-revert-buffer nomodes</em>
+</dt> <dd>
+<p>This function sets the buffer major mode, and parses local variables (see <a href="auto-major-mode">Auto Major Mode</a>). It is called by <code>find-file-noselect</code> and by the default revert function (see <a href="reverting">Reverting</a>). </p> <p>If reading the file got an error because the file does not exist, but its directory does exist, the caller should pass a non-<code>nil</code> value for <var>error</var>. In that case, <code>after-find-file</code> issues a warning: ‘<samp>(New file)</samp>’. For more serious errors, the caller should usually not call <code>after-find-file</code>. </p> <p>If <var>warn</var> is non-<code>nil</code>, then this function issues a warning if an auto-save file exists and is more recent than the visited file. </p> <p>If <var>noauto</var> is non-<code>nil</code>, that says not to enable or disable Auto-Save mode. The mode remains enabled if it was enabled before. </p> <p>If <var>after-find-file-from-revert-buffer</var> is non-<code>nil</code>, that means this call was from <code>revert-buffer</code>. This has no direct effect, but some mode functions and hook functions check the value of this variable. </p> <p>If <var>nomodes</var> is non-<code>nil</code>, that means don’t alter the buffer’s major mode, don’t process local variables specifications in the file, and don’t run <code>find-file-hook</code>. This feature is used by <code>revert-buffer</code> in some cases. </p> <p>The last thing <code>after-find-file</code> does is call all the functions in the list <code>find-file-hook</code>. </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/Subroutines-of-Visiting.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Subroutines-of-Visiting.html</a>
+ </p>
+</div>