From: Richard M. Stallman Date: Wed, 22 Feb 1995 01:30:19 +0000 (+0000) Subject: (eval-after-load): Run FORM now if FILE's already loaded. X-Git-Tag: emacs-19.34~5064 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=909149386e5118fc29eb45769ff7f63dad19f360;p=emacs.git (eval-after-load): Run FORM now if FILE's already loaded. --- diff --git a/lisp/subr.el b/lisp/subr.el index 07bbdb45b5e..11abcdc3aa1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -730,13 +730,20 @@ other hooks, such as major mode hooks, can do the job." (defun eval-after-load (file form) "Arrange that, if FILE is ever loaded, FORM will be run at that time. This makes or adds to an entry on `after-load-alist'. +If FILE is already loaded, evaluate FORM right now. It does nothing if FORM is already on the list for FILE. FILE should be the name of a library, with no directory name." + ;; Make sure there is an element for FILE. (or (assoc file after-load-alist) (setq after-load-alist (cons (list file) after-load-alist))) + ;; Add FORM to the element if it isn't there. (let ((elt (assoc file after-load-alist))) (or (member form (cdr elt)) - (nconc elt (list form)))) + (progn + (nconc elt (list form)) + ;; If the file has been loaded already, run FORM right away. + (and (assoc file load-history) + (eval form))))) form) (defun eval-next-after-load (file)