* lisp/progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at
authorAdam Sokolnicki <adam.sokolnicki@gmail.com>
Sun, 17 Nov 2013 21:39:13 +0000 (23:39 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 17 Nov 2013 21:39:13 +0000 (23:39 +0200)
interpolation curlies.

Fixes: debbugs:15914

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

index faa2243..7017e3f 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-17  Adam Sokolnicki  <adam.sokolnicki@gmail.com>  (tiny change)
+
+       * progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at
+       interpolation curlies (Bug#15914).
+
 2013-11-17  Jay Belanger  <jay.p.belanger@gmail.com>
 
        * calc/calc.el (calc-context-sensitive-enter): New variable.
index ab9fdce..28c4430 100644 (file)
@@ -1590,8 +1590,9 @@ If the result is do-end block, it will always be multiline."
   (let ((start (point)) beg end)
     (end-of-line)
     (unless
-        (if (and (re-search-backward "\\({\\)\\|\\_<do\\(\\s \\|$\\||\\)")
+        (if (and (re-search-backward "\\(?:[^#]\\)\\({\\)\\|\\(\\_<do\\_>\\)")
                  (progn
+                   (goto-char (or (match-beginning 1) (match-beginning 2)))
                    (setq beg (point))
                    (save-match-data (ruby-forward-sexp))
                    (setq end (point))
index d5d2625..e84f55b 100644 (file)
@@ -309,6 +309,12 @@ VALUES-PLIST is a list with alternating index and value elements."
     (ruby-toggle-block)
     (should (string= "foo do |b|\n  b + 1\nend" (buffer-string)))))
 
+(ert-deftest ruby-toggle-block-with-interpolation ()
+  (ruby-with-temp-buffer "foo do\n  \"#{bar}\"\nend"
+    (beginning-of-line)
+    (ruby-toggle-block)
+    (should (string= "foo { \"#{bar}\" }" (buffer-string)))))
+
 (ert-deftest ruby-recognize-symbols-starting-with-at-character ()
   (ruby-assert-face ":@abc" 3 font-lock-constant-face))