diff options
| author | Stefan Monnier | 2012-09-04 13:40:25 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-09-04 13:40:25 -0400 |
| commit | 972debf2e7381b4fd2c70f9c1fd585d8bd137917 (patch) | |
| tree | 6e9da9768df8fc4e29ce881a6b64e91806a7a564 /src | |
| parent | 1088b9226e7dac7314dab52ef0696a5f540900cd (diff) | |
| download | emacs-972debf2e7381b4fd2c70f9c1fd585d8bd137917.tar.gz emacs-972debf2e7381b4fd2c70f9c1fd585d8bd137917.zip | |
Macro-expand interpreted code during load.
* src/lread.c (readevalloop): Call internal-macroexpand-for-load to perform
eager (load-time) macro-expansion.
* src/lisp.mk (lisp): Add macroexp.
* lisp/loadup.el: Load macroexp. Remove hack.
* lisp/emacs-lisp/macroexp.el (macroexp--eval-if-compile): New function.
(macroexp--expand-all): Use it to get better warnings.
(macroexp--backtrace, macroexp--trim-backtrace-frame)
(internal-macroexpand-for-load): New functions.
(macroexp--pending-eager-loads): New var.
(emacs-startup-hook): New hack to replace one in loadup.el.
* lisp/emacs-lisp/cl-macs.el (cl--compiler-macro-list*)
(cl--compiler-macro-cXXr): Move to top, before they can be used.
(cl-psetf): Simplify.
(cl-defstruct): Add indent rule.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/lisp.mk | 1 | ||||
| -rw-r--r-- | src/lread.c | 13 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1dd307b16de..b2634c4fdc4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-09-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * lread.c (readevalloop): Call internal-macroexpand-for-load to perform | ||
| 4 | eager (load-time) macro-expansion. | ||
| 5 | * lisp.mk (lisp): Add macroexp. | ||
| 6 | |||
| 1 | 2012-09-04 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2012-09-04 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Simplify redefinition of 'abort' (Bug#12316). | 9 | Simplify redefinition of 'abort' (Bug#12316). |
diff --git a/src/lisp.mk b/src/lisp.mk index 162d8819917..3d60e07dea3 100644 --- a/src/lisp.mk +++ b/src/lisp.mk | |||
| @@ -65,6 +65,7 @@ lisp = \ | |||
| 65 | $(lispsource)/format.elc \ | 65 | $(lispsource)/format.elc \ |
| 66 | $(lispsource)/bindings.elc \ | 66 | $(lispsource)/bindings.elc \ |
| 67 | $(lispsource)/files.elc \ | 67 | $(lispsource)/files.elc \ |
| 68 | $(lispsource)/emacs-lisp/macroexp.elc \ | ||
| 68 | $(lispsource)/cus-face.elc \ | 69 | $(lispsource)/cus-face.elc \ |
| 69 | $(lispsource)/faces.elc \ | 70 | $(lispsource)/faces.elc \ |
| 70 | $(lispsource)/button.elc \ | 71 | $(lispsource)/button.elc \ |
diff --git a/src/lread.c b/src/lread.c index c15c8da3f7b..4f3a93b16b4 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1680,6 +1680,17 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1680 | int whole_buffer = 0; | 1680 | int whole_buffer = 0; |
| 1681 | /* 1 on the first time around. */ | 1681 | /* 1 on the first time around. */ |
| 1682 | int first_sexp = 1; | 1682 | int first_sexp = 1; |
| 1683 | Lisp_Object macroexpand = intern ("internal-macroexpand-for-load"); | ||
| 1684 | |||
| 1685 | if (NILP (Ffboundp (macroexpand)) | ||
| 1686 | /* Don't macroexpand in .elc files, since it should have been done | ||
| 1687 | already. We actually don't know whether we're in a .elc file or not, | ||
| 1688 | so we use circumstancial evidence: .el files normally go through | ||
| 1689 | Vload_source_file_function -> load-with-code-conversion | ||
| 1690 | -> eval-buffer. */ | ||
| 1691 | || EQ (readcharfun, Qget_file_char) | ||
| 1692 | || EQ (readcharfun, Qget_emacs_mule_file_char)) | ||
| 1693 | macroexpand = Qnil; | ||
| 1683 | 1694 | ||
| 1684 | if (MARKERP (readcharfun)) | 1695 | if (MARKERP (readcharfun)) |
| 1685 | { | 1696 | { |
| @@ -1809,6 +1820,8 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1809 | unbind_to (count1, Qnil); | 1820 | unbind_to (count1, Qnil); |
| 1810 | 1821 | ||
| 1811 | /* Now eval what we just read. */ | 1822 | /* Now eval what we just read. */ |
| 1823 | if (!NILP (macroexpand)) | ||
| 1824 | val = call1 (macroexpand, val); | ||
| 1812 | val = eval_sub (val); | 1825 | val = eval_sub (val); |
| 1813 | 1826 | ||
| 1814 | if (printflag) | 1827 | if (printflag) |