diff options
| author | Richard M. Stallman | 2005-10-22 15:23:00 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-10-22 15:23:00 +0000 |
| commit | adbe2d11a711ef2175f76bb8ed149117837b59e3 (patch) | |
| tree | 8293ab374b424933450ec01d5f0307a83b4765c0 | |
| parent | 55f77e1ce3460637b96ff9f376120fe6735086e6 (diff) | |
| download | emacs-adbe2d11a711ef2175f76bb8ed149117837b59e3.tar.gz emacs-adbe2d11a711ef2175f76bb8ed149117837b59e3.zip | |
(eval-at-startup): New macro.
| -rw-r--r-- | lisp/subr.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 2348c1e3c5d..0e9d3c2b5b0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1322,7 +1322,23 @@ definition only or variable definition only. | |||
| 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. |