]> git.eshelyaron.com Git - emacs.git/commitdiff
(after-load-functions): New hook.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 15 Sep 2009 03:39:40 +0000 (03:39 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 15 Sep 2009 03:39:40 +0000 (03:39 +0000)
(do-after-load-evaluation): Run it.  Use string-match-p to detect
`obsolete' packages, rather than painfully extracting the relevant
directory name.

etc/NEWS
lisp/ChangeLog
lisp/subr.el

index 3339915e2ba73a01640cb5ae02fed724d84464ec..3db3f5342ad31b7e50d7624f21d869a9d1b18c42 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -210,6 +210,8 @@ functions and variables.
 \f
 * Lisp changes in Emacs 23.2
 
+** New hook `after-load-functions' run after loading an Elisp file.
+
 ** You can control which binding is preferentially shown in menus and
 docstrings by adding a `:advertised-binding' property to the corresponding
 command's symbol.  That property can hold a single binding or a list
index a40aa7a932f6d6bf46d59b28ecdbf35c03a301c6..5b52b49ef7869ae3f3a54e6b0696778f21fb47a0 100644 (file)
@@ -1,3 +1,10 @@
+2009-09-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * subr.el (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.
+
 2009-09-15  Glenn Morris  <rgm@gnu.org>
 
        * apropos.el (apropos-documentation-check-doc-file): Avoid assignment to
index 85a74183a8de0424ea4fb2ed27e36dd1a1aa56ed..560ab5695bdb475d7fae3ec6ef0a6e3b6f920957 100644 (file)
@@ -1670,6 +1670,11 @@ This function makes or adds to an entry on `after-load-alist'."
          (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 @@ This function is called directly from the C code."
              (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.