aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorStefan Monnier2012-09-04 13:40:25 -0400
committerStefan Monnier2012-09-04 13:40:25 -0400
commit972debf2e7381b4fd2c70f9c1fd585d8bd137917 (patch)
tree6e9da9768df8fc4e29ce881a6b64e91806a7a564 /src/lread.c
parent1088b9226e7dac7314dab52ef0696a5f540900cd (diff)
downloademacs-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/lread.c')
-rw-r--r--src/lread.c13
1 files changed, 13 insertions, 0 deletions
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)