From 4dd3c4d53af81b017363cb778ac6fd5abea2d132 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 6 May 2014 03:18:18 +0400 Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): Backtrack one char if the global/char-literal var matcher hits inside a string. The next char could be the beginning of an expression expansion. * test/automated/ruby-mode-tests.el (ruby-interpolation-after-dollar-sign): New test. --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/ruby-mode.el | 7 ++++--- test/ChangeLog | 5 +++++ test/automated/ruby-mode-tests.el | 4 ++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3bbacb85e9..7c838a61fe 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-05-05 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-syntax-propertize-function): + Backtrack one char if the global/char-literal var matcher hits + inside a string. The next char could be the beginning of an + expression expansion. + 2014-05-05 Glenn Morris * help-fns.el (describe-function-1): Test for an autoload before a diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 912736707e..74edf7a680 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1804,9 +1804,10 @@ It will be properly highlighted even when the call omits parens.") ;; $' $" $` .... are variables. ;; ?' ?" ?` are character literals (one-char strings in 1.9+). ("\\([?$]\\)[#\"'`]" - (1 (unless (save-excursion - ;; Not within a string. - (nth 3 (syntax-ppss (match-beginning 0)))) + (1 (if (save-excursion + (nth 3 (syntax-ppss (match-beginning 0)))) + ;; Within a string, skip. + (goto-char (match-end 1)) (string-to-syntax "\\")))) ;; Part of symbol when at the end of a method name. ("[!?]" diff --git a/test/ChangeLog b/test/ChangeLog index a02b8e8039..0a3e89e738 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2014-05-05 Dmitry Gutov + + * automated/ruby-mode-tests.el + (ruby-interpolation-after-dollar-sign): New test. + 2014-05-05 Glenn Morris * automated/help-fns.el: New file. diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index f6fddb5ef4..0ad5650cd7 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -452,6 +452,10 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby-assert-face "%w{foo #@bar}" 8 font-lock-string-face) (ruby-assert-face "%s{foo #@bar}" 8 font-lock-string-face)) +(ert-deftest ruby-interpolation-after-dollar-sign () + (ruby-assert-face "\"$#{balance}\"" 2 'font-lock-string-face) + (ruby-assert-face "\"$#{balance}\"" 3 'font-lock-variable-name-face)) + (ert-deftest ruby-no-unknown-percent-literals () ;; No folding of case. (ruby-assert-face "%S{foo}" 4 nil) -- 2.20.1