aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2007-10-24 08:12:40 +0000
committerRichard M. Stallman2007-10-24 08:12:40 +0000
commit8ed7fe5cf40becaa68d3bcdffe1c167c13c4918a (patch)
tree7a2caa58fb5a8cfe9753b6e45596a9cbe8bdc874
parentcaadec436df8b452370bd24187ef56b90bf55918 (diff)
downloademacs-8ed7fe5cf40becaa68d3bcdffe1c167c13c4918a.tar.gz
emacs-8ed7fe5cf40becaa68d3bcdffe1c167c13c4918a.zip
(unload-function-defs-list): Renamed from unload-function-features-list.
(unload-feature-special-hooks, unload-feature): Doc fixes.
-rw-r--r--lisp/loadhist.el53
1 files changed, 30 insertions, 23 deletions
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 5d92f84e9fb..8f21e683a19 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -142,35 +142,42 @@ from a file."
142 write-region-annotate-functions) 142 write-region-annotate-functions)
143 "A list of special hooks from Info node `(elisp)Standard Hooks'. 143 "A list of special hooks from Info node `(elisp)Standard Hooks'.
144 144
145These are symbols with hook-type values whose names don't end in 145These are symbols with hooklike values whose names don't end in
146`-hook' or `-hooks', from which `unload-feature' tries to remove 146`-hook' or `-hooks', from which `unload-feature' should try to remove
147pertinent symbols.") 147pertinent symbols.")
148 148
149(defvar unload-function-features-list nil 149(defvar unload-function-defs-list nil
150 "List of features of the package being unloaded. 150 "List of defintions in the Lisp library being unloaded.
151 151
152This is meant to be used by FEATURE-unload-function, see the 152This is meant to be used by `FEATURE-unload-function'; see the
153documentation of `unload-feature' for details.") 153documentation of `unload-feature' for details.")
154(define-obsolete-variable-alias 'unload-hook-features-list 154(define-obsolete-variable-alias 'unload-hook-features-list
155 'unload-function-features-list "22.2") 155 'unload-function-defs-list "22.2")
156 156
157;;;###autoload 157;;;###autoload
158(defun unload-feature (feature &optional force) 158(defun unload-feature (feature &optional force)
159 "Unload the library that provided FEATURE, restoring all its autoloads. 159 "Unload the library that provided FEATURE.
160If the feature is required by any other loaded code, and prefix arg FORCE 160If the feature is required by any other loaded code, and prefix arg FORCE
161is nil, raise an error. 161is nil, raise an error.
162 162
163This function tries to undo any modifications that the package has 163Standard unloading activities include restoring old autoloads for
164made to hook values in Emacs. Normally it does this using heuristics. 164functions defined by the library, undoing any additions that the
165The packages may define a hook `FEATURE-unload-hook'; if that exists, 165library has made to hook variables or to `auto-mode-alist', undoing
166it is called instead of the normal heuristics. 166ELP profiling of functions in that library, unproviding any features
167provided by the library, and canceling timers held in variables
168defined by the library.
167 169
168Such a hook should undo all the relevant global state changes that may 170If a function `FEATURE-unload-function' is defined, this function
169have been made by loading the package or executing functions in it. 171calls it with no arguments, before doing anything else. That function
170It has access to the package's feature list (before anything is unbound) 172can do whatever is appropriate to undo the loading of the library. If
171in the variable `unload-hook-features-list' and could remove features 173`FEATURE-unload-function' returns non-nil, that suppresses the
172from it in the event that the package has done something strange, 174standard unloading of the library. Otherwise the standard unloading
173such as redefining an Emacs function." 175proceeds.
176
177`FEATURE-unload-function' has access to the package's list of
178definitions in the variable `unload-function-defs-list' and could
179remove symbols from it in the event that the package has done
180something strange, such as redefining an Emacs function."
174 (interactive 181 (interactive
175 (list 182 (list
176 (read-feature "Unload feature: " t) 183 (read-feature "Unload feature: " t)
@@ -183,8 +190,8 @@ such as redefining an Emacs function."
183 (when dependents 190 (when dependents
184 (error "Loaded libraries %s depend on %s" 191 (error "Loaded libraries %s depend on %s"
185 (prin1-to-string dependents) file)))) 192 (prin1-to-string dependents) file))))
186 (let* ((unload-function-features-list (feature-symbols feature)) 193 (let* ((unload-function-defs-list (feature-symbols feature))
187 (file (pop unload-function-features-list)) 194 (file (pop unload-function-defs-list))
188 ;; If non-nil, this is a symbol for which we should 195 ;; If non-nil, this is a symbol for which we should
189 ;; restore a previous autoload if possible. 196 ;; restore a previous autoload if possible.
190 restore-autoload 197 restore-autoload
@@ -216,22 +223,22 @@ such as redefining an Emacs function."
216 (or (and (consp (symbol-value x)) ; Random hooks. 223 (or (and (consp (symbol-value x)) ; Random hooks.
217 (string-match "-hooks?\\'" (symbol-name x))) 224 (string-match "-hooks?\\'" (symbol-name x)))
218 (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc. 225 (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc.
219 (dolist (y unload-function-features-list) 226 (dolist (y unload-function-defs-list)
220 (when (and (eq (car-safe y) 'defun) 227 (when (and (eq (car-safe y) 'defun)
221 (not (get (cdr y) 'autoload))) 228 (not (get (cdr y) 'autoload)))
222 (remove-hook x (cdr y))))))) 229 (remove-hook x (cdr y)))))))
223 ;; Remove any feature-symbols from auto-mode-alist as well. 230 ;; Remove any feature-symbols from auto-mode-alist as well.
224 (dolist (y unload-function-features-list) 231 (dolist (y unload-function-defs-list)
225 (when (and (eq (car-safe y) 'defun) 232 (when (and (eq (car-safe y) 'defun)
226 (not (get (cdr y) 'autoload))) 233 (not (get (cdr y) 'autoload)))
227 (setq auto-mode-alist 234 (setq auto-mode-alist
228 (rassq-delete-all (cdr y) auto-mode-alist))))) 235 (rassq-delete-all (cdr y) auto-mode-alist)))))
229 (when (fboundp 'elp-restore-function) ; remove ELP stuff first 236 (when (fboundp 'elp-restore-function) ; remove ELP stuff first
230 (dolist (elt unload-function-features-list) 237 (dolist (elt unload-function-defs-list)
231 (when (symbolp elt) 238 (when (symbolp elt)
232 (elp-restore-function elt)))) 239 (elp-restore-function elt))))
233 240
234 (dolist (x unload-function-features-list) 241 (dolist (x unload-function-defs-list)
235 (if (consp x) 242 (if (consp x)
236 (case (car x) 243 (case (car x)
237 ;; Remove any feature names that this file provided. 244 ;; Remove any feature names that this file provided.