diff lisp/subr.el @ 105027:8cbad31101f6

(after-load-functions): New hook. (do-after-load-evaluation): Run it. Use string-match-p to detect `obsolete' packages, rather than painfully extracting the relevant directory name.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 15 Sep 2009 03:39:40 +0000
parents a4c2188bd87d
children 78c0a7ca3aaf
line wrap: on
line diff
--- a/lisp/subr.el	Tue Sep 15 02:38:20 2009 +0000
+++ b/lisp/subr.el	Tue Sep 15 03:39:40 2009 +0000
@@ -1670,6 +1670,11 @@
 	  (featurep file))
 	(eval form))))
 
+(defvar after-load-functions nil
+  "Special hook run after loading a file.
+Each function there is called with a single argument, the absolute
+name of the file just loaded.")
+
 (defun do-after-load-evaluation (abs-file)
   "Evaluate all `eval-after-load' forms, if any, for ABS-FILE.
 ABS-FILE, a string, should be the absolute true name of a file just loaded.
@@ -1682,15 +1687,15 @@
 	      (mapc #'eval (cdr a-l-element))))
 	after-load-alist)
   ;; Complain when the user uses obsolete files.
-  (when (equal "obsolete"
-               (file-name-nondirectory
-                (directory-file-name (file-name-directory abs-file))))
+  (when (string-match-p "/obsolete/[^/]*\\'" abs-file)
     (run-with-timer 0 nil
                     (lambda (file)
                       (message "Package %s is obsolete!"
                                (substring file 0
                                           (string-match "\\.elc?\\>" file))))
-                    (file-name-nondirectory abs-file))))
+                    (file-name-nondirectory abs-file)))
+  ;; Finally, run any other hook.
+  (run-hook-with-args 'after-load-functions abs-file))
 
 (defun eval-next-after-load (file)
   "Read the following input sexp, and run it whenever FILE is loaded.