emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: after-load-hook


From: Stefan Monnier
Subject: Re: after-load-hook
Date: Sat, 12 Sep 2009 00:16:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> In the thread for bug#4287 I proposed adding an after-load-hook hook
> to `load' (obviously :-).

Funny, I just wrote the following patch earlier today.


        Stefan


Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.652
diff -u -r1.652 subr.el
--- lisp/subr.el        12 Sep 2009 03:55:50 -0000      1.652
+++ lisp/subr.el        12 Sep 2009 04:13:28 -0000
@@ -1670,6 +1674,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.
@@ -1690,7 +1699,9 @@
                       (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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]