Subject: Re: General delimited literals in ruby-mode patch

From: Dmitry Gutov <[email-masked]>
Date: Thu, 03 May 2012 09:39:40 +0400

Hi again,

I missed the byte compilation error, arising from the fact that 
`syntax-propertize-rules` evaluates regular expressions at compile time.

Options:
1) Remove customizability (see attached patch).
2) Regexp matches any method, then we check against the whitelist in a 
new function.

-- Dmitry
>From bb9ffe72bcb874aec06ca06b62576af8eca5f9f2 Mon Sep 17 00:00:00 2001
From: Dmitry Gutov <[email-masked]>
Date: Thu, 3 May 2012 09:11:20 +0400
Subject: [PATCH 3/3] * lisp/progmodes/ruby-mode.el: Fix byte compilation
 error

ruby-syntax-methods-before-regexp: make constant
ruby-syntax-methods-before-regexp, ruby-percent-literal-beg-re: wrap
together in (eval-and-compile)
---
 lisp/progmodes/ruby-mode.el |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 14ce846..15c8246 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -226,13 +226,6 @@ Also ignores spaces after parenthesis when 'space."
   "Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
   :type 'boolean :group 'ruby)
 
-(defcustom ruby-syntax-methods-before-regexp
-  '("gsub" "gsub!" "sub" "sub!" "scan" "split" "split!" "index" "match"
-    "assert_match" "Given" "Then" "When")
-  "Methods that can take regexp as the first argument.
-It will be properly highlighted even when the call omits parens."
-  :group 'ruby)
-
 ;; Safe file variables
 (put 'ruby-indent-tabs-mode 'safe-local-variable 'booleanp)
 (put 'ruby-indent-level 'safe-local-variable 'integerp)
@@ -1124,9 +1117,16 @@ See `add-log-current-defun-function'."
 (if (eval-when-compile (fboundp #'syntax-propertize-rules))
     ;; New code that works independently from font-lock.
     (progn
-      (defconst ruby-percent-literal-beg-re
-        "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)"
-        "Regexp to match the beginning of percent literal.")
+      (eval-and-compile
+        (defconst ruby-percent-literal-beg-re
+          "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)"
+          "Regexp to match the beginning of percent literal.")
+
+        (defconst ruby-syntax-methods-before-regexp
+          '("gsub" "gsub!" "sub" "sub!" "scan" "split" "split!" "index" "match"
+            "assert_match" "Given" "Then" "When")
+          "Methods that can take regexp as the first argument.
+It will be properly highlighted even when the call omits parens."))
 
       (defun ruby-syntax-propertize-function (start end)
         "Syntactic keywords for Ruby mode.  See `syntax-propertize-function'."
-- 
1.7.10.msysgit.1