summaryrefslogtreecommitdiff
path: root/devdocs/elisp/when-to-autoload.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/when-to-autoload.html
new repository
Diffstat (limited to 'devdocs/elisp/when-to-autoload.html')
-rw-r--r--devdocs/elisp/when-to-autoload.html10
1 files changed, 10 insertions, 0 deletions
diff --git a/devdocs/elisp/when-to-autoload.html b/devdocs/elisp/when-to-autoload.html
new file mode 100644
index 00000000..ae8d1746
--- /dev/null
+++ b/devdocs/elisp/when-to-autoload.html
@@ -0,0 +1,10 @@
+ <h4 class="subsection">When to Use Autoload</h4> <p>Do not add an autoload comment unless it is really necessary. Autoloading code means it is always globally visible. Once an item is autoloaded, there is no compatible way to transition back to it not being autoloaded (after people become accustomed to being able to use it without an explicit load). </p> <ul> <li> The most common items to autoload are the interactive entry points to a library. For example, if <samp>python.el</samp> is a library defining a major-mode for editing Python code, autoload the definition of the <code>python-mode</code> function, so that people can simply use <kbd>M-x python-mode</kbd> to load the library. </li>
+<li> Variables usually don’t need to be autoloaded. An exception is if the variable on its own is generally useful without the whole defining library being loaded. (An example of this might be something like <code>find-exec-terminator</code>.) </li>
+<li> Don’t autoload a user option just so that a user can set it. </li>
+<li> Never add an autoload <em>comment</em> to silence a compiler warning in another file. In the file that produces the warning, use <code>(defvar foo)</code> to silence an undefined variable warning, and <code>declare-function</code> (see <a href="declaring-functions">Declaring Functions</a>) to silence an undefined function warning; or require the relevant library; or use an explicit autoload <em>statement</em>. </li>
+</ul><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/When-to-Autoload.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/When-to-Autoload.html</a>
+ </p>
+</div>