unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
@ 2013-02-01 21:25 Dmitry Gutov
  2013-02-01 23:30 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2013-02-01 21:25 UTC (permalink / raw)
  To: 13605

This applies both to trunk and emacs-24.

ruby-mode compiles without warnings, and ruby-syntax-propertize-function
works fine either way, but when ruby-mode is not compiled, it shows the
subject warning upon loading, and ruby-syntax-propertize-function is an
order of magnitude slower (not very noticeable in the simple cased, though),
due to syntax-propertize-rules not being expanded.

The constant in question is defined in an `eval-and-compile' block, I
can't see what else could the interpreter need. Help?

In GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.6.0)
 of 2013-01-27 on vbx
Bzr revision: 111609 michael.albinus@gmx.de-20130127104333-93qmx98ovt4m0y5q
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
System Description:	Ubuntu 12.10





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-01 21:25 bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled Dmitry Gutov
@ 2013-02-01 23:30 ` Stefan Monnier
  2013-02-02  2:22   ` Stefan Monnier
  2013-02-02 10:07   ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2013-02-01 23:30 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 13605

> The constant in question is defined in an `eval-and-compile' block, I
> can't see what else could the interpreter need. Help?

Eager macro expansion works at the granularity of top-level expressions,
so the whole (if (eval-when-compile (fboundp #'syntax-propertize-rules)) ...)
block is macro-expanded before it gets run.

The patch below should work around the problem (probably best option
for emacs-24).

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.


        Stefan


=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el	2013-01-28 02:07:42 +0000
+++ lisp/progmodes/ruby-mode.el	2013-02-01 23:24:39 +0000
@@ -1211,10 +1211,8 @@
 (declare-function ruby-syntax-enclosing-percent-literal "ruby-mode" (limit))
 (declare-function ruby-syntax-propertize-percent-literal "ruby-mode" (limit))
 
-(if (eval-when-compile (fboundp #'syntax-propertize-rules))
-    ;; New code that works independently from font-lock.
-    (progn
-      (eval-and-compile
+
+(eval-and-compile
         (defconst ruby-percent-literal-beg-re
           "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)"
           "Regexp to match the beginning of percent literal.")
@@ -1225,6 +1223,10 @@
           "Methods that can take regexp as the first argument.
 It will be properly highlighted even when the call omits parens."))
 
+(if (eval-when-compile (fboundp #'syntax-propertize-rules))
+    ;; New code that works independently from font-lock.
+    (progn
+
       (defun ruby-syntax-propertize-function (start end)
         "Syntactic keywords for Ruby mode.  See `syntax-propertize-function'."
         (goto-char start)






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-01 23:30 ` Stefan Monnier
@ 2013-02-02  2:22   ` Stefan Monnier
  2013-02-02 10:07   ` Dmitry Gutov
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2013-02-02  2:22 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 13605

> The patch below should work around the problem (probably best option
> for emacs-24).

Actually, this is sufficiently minor that it's not worth fixing for
emacs-24, I think.


        Stefan





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-01 23:30 ` Stefan Monnier
  2013-02-02  2:22   ` Stefan Monnier
@ 2013-02-02 10:07   ` Dmitry Gutov
  2013-02-04  3:08     ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2013-02-02 10:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13605

On 02.02.2013 3:30, Stefan Monnier wrote:
>> The constant in question is defined in an `eval-and-compile' block, I
>> can't see what else could the interpreter need. Help?
>
> Eager macro expansion works at the granularity of top-level expressions,
> so the whole (if (eval-when-compile (fboundp #'syntax-propertize-rules)) ...)
> block is macro-expanded before it gets run.
>
> The patch below should work around the problem (probably best option
> for emacs-24).

The patch works fine, thank you, but looks like it's not for emacs-24 
anyway.

> 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.

Sounds good.
Do I install the patch (after fixing indentation), or wait for the 
better fix?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-02 10:07   ` Dmitry Gutov
@ 2013-02-04  3:08     ` Stefan Monnier
  2013-02-08 16:18       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-02-04  3:08 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 13605

>> 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.
> Sounds good.
> Do I install the patch (after fixing indentation), or wait for the
> better fix?

I think we'd better aim for the better fix.


        Stefan





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-04  3:08     ` Stefan Monnier
@ 2013-02-08 16:18       ` Stefan Monnier
  2013-02-08 19:15         ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-02-08 16:18 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 13605-done

>>> 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)






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
  2013-02-08 16:18       ` Stefan Monnier
@ 2013-02-08 19:15         ` Dmitry Gutov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2013-02-08 19:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13605-done

On 08.02.2013 20:18, Stefan Monnier wrote:
>>>> 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.

Thanks!





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-08 19:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-01 21:25 bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled Dmitry Gutov
2013-02-01 23:30 ` Stefan Monnier
2013-02-02  2:22   ` Stefan Monnier
2013-02-02 10:07   ` Dmitry Gutov
2013-02-04  3:08     ` Stefan Monnier
2013-02-08 16:18       ` Stefan Monnier
2013-02-08 19:15         ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).