]> code.delx.au - gnu-emacs/blobdiff - lisp/loadhist.el
*** empty log message ***
[gnu-emacs] / lisp / loadhist.el
index 95208bc7908774b00e9be76ed098ebeaffd39cbd..e609596e4a8e0c4502aa970548cdfa783a28c351 100644 (file)
@@ -32,7 +32,9 @@
 ;;; Code:
 
 (defun feature-symbols (feature)
-  "Return the file and list of symbols associated with a given FEATURE."
+  "Return the file and list of definitions associated with FEATURE.
+The value is actually the element of `load-history'
+for the file that did (provide FEATURE)."
    (catch 'foundit
      (mapc (lambda (x)
             (if (member (cons 'provide feature) (cdr x))
@@ -98,16 +100,16 @@ return the feature \(symbol\)."
 
 (defvar loadhist-hook-functions
   '(after-change-functions
-after-insert-file-functions auto-fill-function
-before-change-functions blink-paren-function
-buffer-access-fontify-functions command-line-functions
-comment-indent-function kill-buffer-query-functions
-kill-emacs-query-functions lisp-indent-function
-mouse-position-function
-redisplay-end-trigger-functions temp-buffer-show-function
-window-scroll-functions window-size-change-functions
-write-region-annotate-functions)
-  "A list of special hooks from the `Standard Hooks' node of the Lisp manual.
+    after-insert-file-functions auto-fill-function
+    before-change-functions blink-paren-function
+    buffer-access-fontify-functions command-line-functions
+    comment-indent-function kill-buffer-query-functions
+    kill-emacs-query-functions lisp-indent-function
+    mouse-position-function
+    redisplay-end-trigger-functions temp-buffer-show-function
+    window-scroll-functions window-size-change-functions
+    write-region-annotate-functions)
+  "A list of special hooks from Info node `(elisp)Standard Hooks'.
 
 These are symbols with hook-type values whose names don't end in
 `-hook' or `-hooks', from which `unload-feature' tries to remove
@@ -150,21 +152,33 @@ is nil, raise an error."
          (if (or (and (boundp x)        ; Random hooks.
                       (consp (symbol-value x))
                       (string-match "-hooks?\\'" (symbol-name x)))
-                 (and (fboundp x)       ; Known abnormal hooks etc.
+                 (and (boundp x)       ; Known abnormal hooks etc.
                       (memq x loadhist-hook-functions)))
             (dolist (y (cdr flist))
               (remove-hook x y))))))
+    (if (fboundp 'elp-restore-function)        ; remove ELP stuff first
+       (dolist (elt (cdr flist))
+         (if (symbolp elt)
+             (elp-restore-function elt))))
     (mapc
      (lambda (x)
        (cond ((stringp x) nil)
              ((consp x)
               ;; Remove any feature names that this file provided.
               (if (eq (car x) 'provide)
-                  (setq features (delq (cdr x) features))))
+                  (setq features (delq (cdr x) features)))
+              (when (eq (car x) 'defvar)
+               ;; Kill local values as much as possible.
+               (dolist (buf (buffer-list))
+                 (with-current-buffer buf
+                   (kill-local-variable (cdr x))))
+               ;; Get rid of the default binding if we can.
+               (unless (local-variable-if-set-p (cdr x))
+                 (makunbound (cdr x)))))
             (t
-             (when (boundp x)
-               (makunbound x))
              (when (fboundp x)
+               (if (fboundp 'ad-unadvise)
+                   (ad-unadvise x))
                (fmakunbound x)
                (let ((aload (get x 'autoload)))
                  (if aload (fset x (cons 'autoload aload))))))))