From 8be3a09c4f4ed0eae2902b81e80856e917a81b2d Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 15 Aug 2012 21:18:07 -0400 Subject: [PATCH] * src/eval.c (eval_sub): Bind lexical-binding. * src/lread.c (Qlexical_binding): Make non-static. --- src/ChangeLog | 17 +++++++++++------ src/eval.c | 14 +++++++++++++- src/lread.c | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6e49dd44fde..b203908cdb6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-08-16 Stefan Monnier + + * eval.c (eval_sub): Bind lexical-binding. + * lread.c (Qlexical_binding): Make non-static. + 2012-08-15 Jan Djärv * nsmenu.m (popupSession): Remove. @@ -44,8 +49,8 @@ Generalize and cleanup font subsystem checks. * font.h (FONT_DEBUG, font_assert): Remove. - * font.c, fontset.c, w32font.c, xfont.c, xftfont.c: Change - font_assert to eassert. Use eassert where appropriate. + * font.c, fontset.c, w32font.c, xfont.c, xftfont.c: + Change font_assert to eassert. Use eassert where appropriate. 2012-08-15 Dmitry Antipov @@ -53,10 +58,10 @@ 2012-08-15 Chong Yidong - * gtkutil.c (xg_get_font): Rename from xg_get_font_name. When - using the new font chooser, use gtk_font_chooser_get_font_desc to - extract the font descriptor instead of just the font name. In - that case, return a font spec instead of a string. + * gtkutil.c (xg_get_font): Rename from xg_get_font_name. + When using the new font chooser, use gtk_font_chooser_get_font_desc to + extract the font descriptor instead of just the font name. + In that case, return a font spec instead of a string. (x_last_font_name): Move to this file from xfns.c. * xfns.c (Fx_select_font): The return value can also be a font diff --git a/src/eval.c b/src/eval.c index b531f790cc5..f3f14d60e1c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2217,7 +2217,19 @@ eval_sub (Lisp_Object form) goto retry; } if (EQ (funcar, Qmacro)) - val = eval_sub (apply1 (Fcdr (fun), original_args)); + { + ptrdiff_t count = SPECPDL_INDEX (); + extern Lisp_Object Qlexical_binding; + Lisp_Object exp; + /* Bind lexical-binding during expansion of the macro, so the + macro can know reliably if the code it outputs will be + interpreted using lexical-binding or not. */ + specbind (Qlexical_binding, + NILP (Vinternal_interpreter_environment) ? Qnil : Qt); + exp = apply1 (Fcdr (fun), original_args); + unbind_to (count, Qnil); + val = eval_sub (exp); + } else if (EQ (funcar, Qlambda) || EQ (funcar, Qclosure)) val = apply_lambda (fun, original_args); diff --git a/src/lread.c b/src/lread.c index 72991e92bae..94ae4dd4282 100644 --- a/src/lread.c +++ b/src/lread.c @@ -80,7 +80,7 @@ static Lisp_Object Qascii_character, Qload, Qload_file_name; Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; static Lisp_Object Qinhibit_file_name_operation; static Lisp_Object Qeval_buffer_list; -static Lisp_Object Qlexical_binding; +Lisp_Object Qlexical_binding; static Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */ /* Used instead of Qget_file_char while loading *.elc files compiled -- 2.39.2