]> code.delx.au - gnu-emacs/commitdiff
Do not mistake colon at the end of regexp for slash symbol
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 12 May 2016 00:18:45 +0000 (03:18 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 12 May 2016 00:18:45 +0000 (03:18 +0300)
* lisp/progmodes/ruby-mode.el (ruby-syntax-propertize):
Check the parse state in the "Symbols with special characters"
rule (bug#23515).

lisp/progmodes/ruby-mode.el
test/automated/ruby-mode-tests.el

index 972bf99145e392d8d3380d07d0f3b2a9d031bf4e..cd3b04de712de918df3d009f36a148935914f11f 100644 (file)
@@ -1858,7 +1858,9 @@ It will be properly highlighted even when the call omits parens.")
             (string-to-syntax "'"))))
       ;; Symbols with special characters.
       ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)\\)"
-       (3 (string-to-syntax "_")))
+       (3 (unless (nth 8 (syntax-ppss (match-beginning 3)))
+            (goto-char (match-end 0))
+            (string-to-syntax "_"))))
       ;; Part of method name when at the end of it.
       ("[!?]"
        (0 (unless (save-excursion
index 7e85fb83eddf25ada143a09665753a4e8a5a38c4..52126a3bdf142365eee3f57dfc39c4535079722a 100644 (file)
@@ -146,6 +146,9 @@ VALUES-PLIST is a list with alternating index and value elements."
 (ert-deftest ruby-slash-char-literal-is-not-mistaken-for-regexp ()
   (ruby-assert-state "?/" 3 nil))
 
+(ert-deftest ruby-regexp-is-not-mistaken-for-slash-symbol ()
+  (ruby-assert-state "x = /foo:/" 3 nil))
+
 (ert-deftest ruby-indent-simple ()
   (ruby-should-indent-buffer
    "if foo