summaryrefslogtreecommitdiff
path: root/devdocs/elisp/unloading.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/unloading.html
new repository
Diffstat (limited to 'devdocs/elisp/unloading.html')
-rw-r--r--devdocs/elisp/unloading.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/elisp/unloading.html b/devdocs/elisp/unloading.html
new file mode 100644
index 00000000..53caedff
--- /dev/null
+++ b/devdocs/elisp/unloading.html
@@ -0,0 +1,12 @@
+ <h3 class="section">Unloading</h3> <p>You can discard the functions and variables loaded by a library to reclaim memory for other Lisp objects. To do this, use the function <code>unload-feature</code>: </p> <dl> <dt id="unload-feature">Command: <strong>unload-feature</strong> <em>feature &amp;optional force</em>
+</dt> <dd>
+<p>This command unloads the library that provided feature <var>feature</var>. It undefines all functions, macros, and variables defined in that library with <code>defun</code>, <code>defalias</code>, <code>defsubst</code>, <code>defmacro</code>, <code>defconst</code>, <code>defvar</code>, and <code>defcustom</code>. It then restores any autoloads formerly associated with those symbols. (Loading saves these in the <code>autoload</code> property of the symbol.) </p> <p>Before restoring the previous definitions, <code>unload-feature</code> runs <code>remove-hook</code> to remove functions defined by the library from certain hooks. These hooks include variables whose names end in ‘<samp>-hook</samp>’ (or the deprecated suffix ‘<samp>-hooks</samp>’), plus those listed in <code>unload-feature-special-hooks</code>, as well as <code>auto-mode-alist</code>. This is to prevent Emacs from ceasing to function because important hooks refer to functions that are no longer defined. </p> <p>Standard unloading activities also undo ELP profiling of functions in that library, unprovides any features provided by the library, and cancels timers held in variables defined by the library. </p> <p>If these measures are not sufficient to prevent malfunction, a library can define an explicit unloader named <code><var>feature</var>-unload-function</code>. If that symbol is defined as a function, <code>unload-feature</code> calls it with no arguments before doing anything else. It can do whatever is appropriate to unload the library. If it returns <code>nil</code>, <code>unload-feature</code> proceeds to take the normal unload actions. Otherwise it considers the job to be done. </p> <p>Ordinarily, <code>unload-feature</code> refuses to unload a library on which other loaded libraries depend. (A library <var>a</var> depends on library <var>b</var> if <var>a</var> contains a <code>require</code> for <var>b</var>.) If the optional argument <var>force</var> is non-<code>nil</code>, dependencies are ignored and you can unload any library. </p>
+</dd>
+</dl> <p>The <code>unload-feature</code> function is written in Lisp; its actions are based on the variable <code>load-history</code>. </p> <dl> <dt id="unload-feature-special-hooks">Variable: <strong>unload-feature-special-hooks</strong>
+</dt> <dd><p>This variable holds a list of hooks to be scanned before unloading a library, to remove functions defined in the library. </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/Unloading.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Unloading.html</a>
+ </p>
+</div>