]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): Only
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 6 Mar 2013 18:56:29 +0000 (22:56 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 6 Mar 2013 18:56:29 +0000 (22:56 +0400)
propertize regexp when not inside a string.

Fixes: debbugs:13885
lisp/ChangeLog
lisp/progmodes/ruby-mode.el
test/automated/ruby-mode-tests.el

index 18242539ccaee39295696100238fa28d7127b521..cef47715dc01a3160db7095cae73b00ab15d27b4 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-06  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-syntax-propertize-function): Only
+       propertize regexp when not inside a string (Bug#13885).
+
 2013-03-06  Alan Mackenzie  <acm@muc.de>
 
        Correct the position of point in some line-up functions.
index 9b007c0063a19ada85b569196bee5ecb93ada47e..6e471d1aa2a1b8451a0d703c37af62e42ffd5955 100644 (file)
@@ -1276,8 +1276,10 @@ It will be properly highlighted even when the call omits parens."))
             "\\)\\s *"
             ;; The regular expression itself.
             "\\(/\\)[^/\n\\\\]*\\(?:\\\\.[^/\n\\\\]*\\)*\\(/\\)")
-           (2 (string-to-syntax "\"/"))
-           (3 (string-to-syntax "\"/")))
+           (3 (unless (nth 3 (syntax-ppss (match-beginning 2)))
+                (put-text-property (match-beginning 2) (match-end 2)
+                                   'syntax-table (string-to-syntax "\"/"))
+                (string-to-syntax "\"/"))))
           ("^=en\\(d\\)\\_>" (1 "!"))
           ("^\\(=\\)begin\\_>" (1 "!"))
           ;; Handle here documents.
index c67f92e6ed9c2af9802fcf1c7431e965afcc7321..81bae187218ec96fd17cfc2001dcbe496233e34b 100644 (file)
@@ -47,17 +47,16 @@ The whitespace before and including \"|\" on each line is removed."
 (defun ruby-test-string (s &rest args)
   (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args))
 
-(defun ruby-assert-state (content &rest values-plist)
+(defun ruby-assert-state (content index value &optional point)
   "Assert syntax state values at the end of CONTENT.
 
 VALUES-PLIST is a list with alternating index and value elements."
   (ruby-with-temp-buffer content
+    (when point (goto-char point))
     (syntax-propertize (point))
-    (while values-plist
-      (should (eq (nth (car values-plist)
-                       (parse-partial-sexp (point-min) (point)))
-                  (cadr values-plist)))
-      (setq values-plist (cddr values-plist)))))
+    (should (eq (nth index
+                     (parse-partial-sexp (point-min) (point)))
+                value))))
 
 (defun ruby-assert-face (content pos face)
   (ruby-with-temp-buffer content
@@ -104,6 +103,12 @@ VALUES-PLIST is a list with alternating index and value elements."
   (ruby-should-indent "a = %w[abc\n       def]\n  " 0)
   (ruby-should-indent "a = \"abc\n      def\"\n  " 0))
 
+(ert-deftest ruby-regexp-doest-start-in-string ()
+  (ruby-assert-state "'(/', /\d+/" 3 nil))
+
+(ert-deftest ruby-regexp-starts-after-string ()
+  (ruby-assert-state "'(/', /\d+/" 3 ?/ 8))
+
 (ert-deftest ruby-indent-simple ()
   (ruby-should-indent-buffer
    "if foo