Mercurial > emacs
comparison lisp/loadhist.el @ 85688:b210bba3f477
Merge from emacs--rel--22
Patches applied:
* emacs--rel--22 (patch 131-137)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 261-262)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-908
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 27 Oct 2007 09:07:17 +0000 |
parents | cb2dd077ba75 8f2e292b71d0 |
children | 018f2968e81d 4bc33ffdda1a |
comparison
equal
deleted
inserted
replaced
85687:666ace46440f | 85688:b210bba3f477 |
---|---|
131 window-scroll-functions window-size-change-functions | 131 window-scroll-functions window-size-change-functions |
132 write-contents-functions write-file-functions | 132 write-contents-functions write-file-functions |
133 write-region-annotate-functions) | 133 write-region-annotate-functions) |
134 "A list of special hooks from Info node `(elisp)Standard Hooks'. | 134 "A list of special hooks from Info node `(elisp)Standard Hooks'. |
135 | 135 |
136 These are symbols with hook-type values whose names don't end in | 136 These are symbols with hooklike values whose names don't end in |
137 `-hook' or `-hooks', from which `unload-feature' tries to remove | 137 `-hook' or `-hooks', from which `unload-feature' should try to remove |
138 pertinent symbols.") | 138 pertinent symbols.") |
139 | 139 |
140 (defvar unload-function-features-list nil | 140 (defvar unload-function-defs-list nil |
141 "List of features of the package being unloaded. | 141 "List of defintions in the Lisp library being unloaded. |
142 | 142 |
143 This is meant to be used by FEATURE-unload-function, see the | 143 This is meant to be used by `FEATURE-unload-function'; see the |
144 documentation of `unload-feature' for details.") | 144 documentation of `unload-feature' for details.") |
145 (define-obsolete-variable-alias 'unload-hook-features-list | 145 (define-obsolete-variable-alias 'unload-hook-features-list |
146 'unload-function-features-list "22.2") | 146 'unload-function-defs-list "22.2") |
147 | 147 |
148 ;;;###autoload | 148 ;;;###autoload |
149 (defun unload-feature (feature &optional force) | 149 (defun unload-feature (feature &optional force) |
150 "Unload the library that provided FEATURE, restoring all its autoloads. | 150 "Unload the library that provided FEATURE. |
151 If the feature is required by any other loaded code, and prefix arg FORCE | 151 If the feature is required by any other loaded code, and prefix arg FORCE |
152 is nil, raise an error. | 152 is nil, raise an error. |
153 | 153 |
154 This function tries to undo any modifications that the package has | 154 Standard unloading activities include restoring old autoloads for |
155 made to hook values in Emacs. Normally it does this using heuristics. | 155 functions defined by the library, undoing any additions that the |
156 The packages may define a hook `FEATURE-unload-hook'; if that exists, | 156 library has made to hook variables or to `auto-mode-alist', undoing |
157 it is called instead of the normal heuristics. | 157 ELP profiling of functions in that library, unproviding any features |
158 | 158 provided by the library, and canceling timers held in variables |
159 Such a hook should undo all the relevant global state changes that may | 159 defined by the library. |
160 have been made by loading the package or executing functions in it. | 160 |
161 It has access to the package's feature list (before anything is unbound) | 161 If a function `FEATURE-unload-function' is defined, this function |
162 in the variable `unload-hook-features-list' and could remove features | 162 calls it with no arguments, before doing anything else. That function |
163 from it in the event that the package has done something strange, | 163 can do whatever is appropriate to undo the loading of the library. If |
164 such as redefining an Emacs function." | 164 `FEATURE-unload-function' returns non-nil, that suppresses the |
165 standard unloading of the library. Otherwise the standard unloading | |
166 proceeds. | |
167 | |
168 `FEATURE-unload-function' has access to the package's list of | |
169 definitions in the variable `unload-function-defs-list' and could | |
170 remove symbols from it in the event that the package has done | |
171 something strange, such as redefining an Emacs function." | |
165 (interactive | 172 (interactive |
166 (list | 173 (list |
167 (read-feature "Unload feature: " t) | 174 (read-feature "Unload feature: " t) |
168 current-prefix-arg)) | 175 current-prefix-arg)) |
169 (unless (featurep feature) | 176 (unless (featurep feature) |
172 (let* ((file (feature-file feature)) | 179 (let* ((file (feature-file feature)) |
173 (dependents (delete file (copy-sequence (file-dependents file))))) | 180 (dependents (delete file (copy-sequence (file-dependents file))))) |
174 (when dependents | 181 (when dependents |
175 (error "Loaded libraries %s depend on %s" | 182 (error "Loaded libraries %s depend on %s" |
176 (prin1-to-string dependents) file)))) | 183 (prin1-to-string dependents) file)))) |
177 (let* ((unload-function-features-list (feature-symbols feature)) | 184 (let* ((unload-function-defs-list (feature-symbols feature)) |
178 (file (pop unload-function-features-list)) | 185 (file (pop unload-function-defs-list)) |
179 ;; If non-nil, this is a symbol for which we should | 186 ;; If non-nil, this is a symbol for which we should |
180 ;; restore a previous autoload if possible. | 187 ;; restore a previous autoload if possible. |
181 restore-autoload | 188 restore-autoload |
182 (name (symbol-name feature)) | 189 (name (symbol-name feature)) |
183 (unload-hook (intern-soft (concat name "-unload-hook"))) | 190 (unload-hook (intern-soft (concat name "-unload-hook"))) |
205 (lambda (x) | 212 (lambda (x) |
206 (when (and (boundp x) | 213 (when (and (boundp x) |
207 (or (and (consp (symbol-value x)) ; Random hooks. | 214 (or (and (consp (symbol-value x)) ; Random hooks. |
208 (string-match "-hooks?\\'" (symbol-name x))) | 215 (string-match "-hooks?\\'" (symbol-name x))) |
209 (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc. | 216 (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc. |
210 (dolist (y unload-function-features-list) | 217 (dolist (y unload-function-defs-list) |
211 (when (and (eq (car-safe y) 'defun) | 218 (when (and (eq (car-safe y) 'defun) |
212 (not (get (cdr y) 'autoload))) | 219 (not (get (cdr y) 'autoload))) |
213 (remove-hook x (cdr y))))))) | 220 (remove-hook x (cdr y))))))) |
214 ;; Remove any feature-symbols from auto-mode-alist as well. | 221 ;; Remove any feature-symbols from auto-mode-alist as well. |
215 (dolist (y unload-function-features-list) | 222 (dolist (y unload-function-defs-list) |
216 (when (and (eq (car-safe y) 'defun) | 223 (when (and (eq (car-safe y) 'defun) |
217 (not (get (cdr y) 'autoload))) | 224 (not (get (cdr y) 'autoload))) |
218 (setq auto-mode-alist | 225 (setq auto-mode-alist |
219 (rassq-delete-all (cdr y) auto-mode-alist))))) | 226 (rassq-delete-all (cdr y) auto-mode-alist))))) |
220 (when (fboundp 'elp-restore-function) ; remove ELP stuff first | 227 (when (fboundp 'elp-restore-function) ; remove ELP stuff first |
221 (dolist (elt unload-function-features-list) | 228 (dolist (elt unload-function-defs-list) |
222 (when (symbolp elt) | 229 (when (symbolp elt) |
223 (elp-restore-function elt)))) | 230 (elp-restore-function elt)))) |
224 | 231 |
225 (dolist (x unload-function-features-list) | 232 (dolist (x unload-function-defs-list) |
226 (if (consp x) | 233 (if (consp x) |
227 (case (car x) | 234 (case (car x) |
228 ;; Remove any feature names that this file provided. | 235 ;; Remove any feature names that this file provided. |
229 (provide | 236 (provide |
230 (setq features (delq (cdr x) features))) | 237 (setq features (delq (cdr x) features))) |