emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 1a5a05c: Do not mistake colon at the end of regex


From: Dmitry Gutov
Subject: [Emacs-diffs] emacs-25 1a5a05c: Do not mistake colon at the end of regexp for slash symbol
Date: Thu, 12 May 2016 00:20:05 +0000 (UTC)

branch: emacs-25
commit 1a5a05cf6f68277c142fe3753581d3b0c6470156
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Do not mistake colon at the end of regexp for slash symbol
    
    * 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       |    4 +++-
 test/automated/ruby-mode-tests.el |    3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 972bf99..cd3b04d 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1858,7 +1858,9 @@ It will be properly highlighted even when the call omits 
parens.")
             (string-to-syntax "'"))))
       ;; Symbols with special characters.
       
("\\(^\\|[^:]\\)\\(:\\(address@hidden|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)\\)"
-       (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
diff --git a/test/automated/ruby-mode-tests.el 
b/test/automated/ruby-mode-tests.el
index 7e85fb8..52126a3 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]