Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled

From: Stefan Monnier <[email-masked]>
Date: Fri, 08 Feb 2013 11:18:42 -0500

>>> Maybe the better way to fix it (for trunk) is to change eval-and-compile
>>> (and probably eval-when-compile) so that it evaluates its argument during
>>> macro-expansion.

I've installed the patch below which fixes this problem and hopefully
won't introduce others.

        Stefan

=== modified file 'lisp/emacs-lisp/byte-run.el'
--- lisp/emacs-lisp/byte-run.el	2013-01-03 02:37:57 +0000
+++ lisp/emacs-lisp/byte-run.el	2013-02-08 16:13:13 +0000
@@ -392,15 +392,15 @@
 Thus, the result of the body appears to the compiler as a quoted constant.
 In interpreted code, this is entirely equivalent to `progn'."
   (declare (debug t) (indent 0))
-  ;; Not necessary because we have it in b-c-initial-macro-environment
-  ;; (list 'quote (eval (cons 'progn body)))
-  (cons 'progn body))
+  (list 'quote (eval (cons 'progn body) lexical-binding)))
 
 (defmacro eval-and-compile (&rest body)
   "Like `progn', but evaluates the body at compile time and at load time."
   (declare (debug t) (indent 0))
-  ;; Remember, it's magic.
-  (cons 'progn body))
+  ;; When the byte-compiler expands code, this macro is not used, so we're
+  ;; either about to run `body' (plain interpretation) or we're doing eager
+  ;; macroexpansion.
+  (list 'quote (eval (cons 'progn body) lexical-binding)))
 
 (put 'with-no-warnings 'lisp-indent-function 0)
 (defun with-no-warnings (&rest body)