1
2
3
4
5
6
7
8
9
10
11
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 &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 © 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>
|