# HG changeset patch # User Richard M. Stallman <rms@gnu.org> # Date 1129994580 0 # Node ID 138f9b1d6682ef54bef2cb647c642df2501c6826 # Parent 3fcb7f692502190f0238bc7c958d64a77a948c07 (eval-at-startup): New macro. diff -r 3fcb7f692502 -r 138f9b1d6682 lisp/subr.el --- a/lisp/subr.el Sat Oct 22 15:15:56 2005 +0000 +++ b/lisp/subr.el Sat Oct 22 15:23:00 2005 +0000 @@ -1322,7 +1322,23 @@ file))) -;;;; Specifying things to do after certain files are loaded. +;;;; Specifying things to do later. + +(defmacro eval-at-startup (&rest body) + "Make arrangements to evaluate BODY when Emacs starts up. +If this is run after Emacs startup, evaluate BODY immediately. +Always returns nil. + +This works by adding a function to `before-init-hook'. +That function's doc string says which file created it." + `(progn + (if command-line-processed + (progn . ,body) + (add-hook 'before-init-hook + '(lambda () ,(concat "From " (or load-file-name "no file")) + . ,body) + t)) + nil)) (defun eval-after-load (file form) "Arrange that, if FILE is ever loaded, FORM will be run at that time.