Mercurial > emacs
comparison lisp/subr.el @ 66306:138f9b1d6682
(eval-at-startup): New macro.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 22 Oct 2005 15:23:00 +0000 |
parents | f754be327a7e |
children | cf092daa39de |
comparison
equal
deleted
inserted
replaced
66305:3fcb7f692502 | 66306:138f9b1d6682 |
---|---|
1320 (setq file (car (car files)) files nil)) | 1320 (setq file (car (car files)) files nil)) |
1321 (setq files (cdr files))) | 1321 (setq files (cdr files))) |
1322 file))) | 1322 file))) |
1323 | 1323 |
1324 | 1324 |
1325 ;;;; Specifying things to do after certain files are loaded. | 1325 ;;;; Specifying things to do later. |
1326 | |
1327 (defmacro eval-at-startup (&rest body) | |
1328 "Make arrangements to evaluate BODY when Emacs starts up. | |
1329 If this is run after Emacs startup, evaluate BODY immediately. | |
1330 Always returns nil. | |
1331 | |
1332 This works by adding a function to `before-init-hook'. | |
1333 That function's doc string says which file created it." | |
1334 `(progn | |
1335 (if command-line-processed | |
1336 (progn . ,body) | |
1337 (add-hook 'before-init-hook | |
1338 '(lambda () ,(concat "From " (or load-file-name "no file")) | |
1339 . ,body) | |
1340 t)) | |
1341 nil)) | |
1326 | 1342 |
1327 (defun eval-after-load (file form) | 1343 (defun eval-after-load (file form) |
1328 "Arrange that, if FILE is ever loaded, FORM will be run at that time. | 1344 "Arrange that, if FILE is ever loaded, FORM will be run at that time. |
1329 This makes or adds to an entry on `after-load-alist'. | 1345 This makes or adds to an entry on `after-load-alist'. |
1330 If FILE is already loaded, evaluate FORM right now. | 1346 If FILE is already loaded, evaluate FORM right now. |