# HG changeset patch # User Richard M. Stallman # Date 793416619 0 # Node ID 4443f78a2117954599f600ca93296668379008a8 # Parent b3ff283889760373ef3e191d5ab02001c68dfc13 (eval-after-load): Run FORM now if FILE's already loaded. diff -r b3ff28388976 -r 4443f78a2117 lisp/subr.el --- a/lisp/subr.el Wed Feb 22 00:38:59 1995 +0000 +++ b/lisp/subr.el Wed Feb 22 01:30:19 1995 +0000 @@ -730,13 +730,20 @@ (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)