From: Dmitry Gutov Date: Tue, 18 Jun 2013 22:17:56 +0000 (+0400) Subject: * lisp/progmodes/ruby-mode.el (ruby-syntax-before-regexp-re): X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2016^2~61 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d1bbba4fa5de77c3bdfb01901b697ead748a4ba6;p=emacs.git * lisp/progmodes/ruby-mode.el (ruby-syntax-before-regexp-re): Distinguish ternary operator tokens from slash symbol and slash char literal. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 44d8a2a82bd..ce507cfff9f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-06-18 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-syntax-before-regexp-re): + Distinguish ternary operator tokens from slash symbol and slash + char literal. + 2013-06-18 Juanma Barranquero Convert symbol prettification into minor mode and global minor mode. diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index fa4efe49b7b..8a1548bc940 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1368,7 +1368,10 @@ It will be properly highlighted even when the call omits parens.") (defvar ruby-syntax-before-regexp-re (concat ;; Special tokens that can't be followed by a division operator. - "\\(^\\|[[=(,~?:;<>]" + "\\(^\\|[[=(,~;<>]" + ;; Distinguish ternary operator tokens. + ;; FIXME: They don't really have to be separated with spaces. + "\\|[?:] " ;; Control flow keywords and operators following bol or whitespace. "\\|\\(?:^\\|\\s \\)" (regexp-opt '("if" "elsif" "unless" "while" "until" "when" "and" diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 77dd62821f7..ad13d01a674 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -124,6 +124,12 @@ VALUES-PLIST is a list with alternating index and value elements." (ert-deftest ruby-regexp-can-be-multiline () (ruby-assert-state "/bars\ntees # toots \nfoos/" 3 nil)) +(ert-deftest ruby-slash-symbol-is-not-mistaken-for-regexp () + (ruby-assert-state ":/" 3 nil)) + +(ert-deftest ruby-slash-char-literal-is-not-mistaken-for-regexp () + (ruby-assert-state "?/" 3 nil)) + (ert-deftest ruby-indent-simple () (ruby-should-indent-buffer "if foo