- (if (or (and (boundp x) ; Random hooks.
- (consp (symbol-value x))
- (string-match "-hooks?\\'" (symbol-name x)))
- (and (boundp x) ; Known abnormal hooks etc.
- (memq x unload-feature-special-hooks)))
- (dolist (y (cdr unload-hook-features-list))
- (remove-hook x y))))))
- (if (fboundp 'elp-restore-function) ; remove ELP stuff first
- (dolist (elt (cdr unload-hook-features-list))
- (if (symbolp elt)
- (elp-restore-function elt))))
- (dolist (x (cdr unload-hook-features-list))
- (when (consp x)
- ;; Remove any feature names that this file provided.
- (if (eq (car x) 'provide)
+ (when (and (boundp x)
+ (or (and (consp (symbol-value x)) ; Random hooks.
+ (string-match "-hooks?\\'" (symbol-name x)))
+ (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc.
+ (dolist (y unload-hook-features-list)
+ (when (and (eq (car-safe y) 'defun)
+ (not (get (cdr y) 'autoload)))
+ (remove-hook x (cdr y)))))))
+ ;; Remove any feature-symbols from auto-mode-alist as well.
+ (dolist (y unload-hook-features-list)
+ (when (and (eq (car-safe y) 'defun)
+ (not (get (cdr y) 'autoload)))
+ (setq auto-mode-alist
+ (rassq-delete-all (cdr y) auto-mode-alist)))))
+ (when (fboundp 'elp-restore-function) ; remove ELP stuff first
+ (dolist (elt unload-hook-features-list)
+ (when (symbolp elt)
+ (elp-restore-function elt))))
+ (dolist (x unload-hook-features-list)
+ (if (consp x)
+ (cond
+ ;; Remove any feature names that this file provided.
+ ((eq (car x) 'provide)