]> code.delx.au - gnu-emacs/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 4 Nov 2013 10:50:47 +0000 (12:50 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 4 Nov 2013 10:50:47 +0000 (12:50 +0200)
(ruby-smie--backward-token): Tokenize heredocs as semicolons.

* test/automated/ruby-mode-tests.el: Remove outdated comment.

* test/indent/ruby.rb: Add a statement on the line after heredoc.

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

index 9ff4ab8f04c430673b80f4def08630110e45e752..4c2c4cd5e07c4a368e015e7a64721e67b6c0082f 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-04  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--forward-token)
+       (ruby-smie--backward-token): Tokenize heredocs as semicolons.
+
 2013-11-04  Michal Nazarewicz  <mina86@mina86.com>
 
        * textmodes/fill.el (fill-single-char-nobreak-p): New function
index 75c59ebe1fd86e3aefa2a508720d024f2c5af866..1c9663cc22ce45f1869b3f2bd6d302ef59748169 100644 (file)
@@ -393,7 +393,12 @@ explicitly declared in magic comment."
   (let ((pos (point)))
     (skip-chars-forward " \t")
     (cond
-     ((looking-at "\\s\"") "")          ;A heredoc or a string.
+     ((looking-at "\\s\"") ;A heredoc or a string.
+      (if (not (looking-at "\n"))
+          ""
+        ;; Tokenize the whole heredoc as semicolon.
+        (goto-char (scan-sexps (point) 1))
+        ";"))
      ((and (looking-at "[\n#]")
            (ruby-smie--implicit-semi-p)) ;Only add implicit ; when needed.
       (if (eolp) (forward-char 1) (forward-comment 1))
@@ -435,7 +440,10 @@ explicitly declared in magic comment."
     (cond
      ((and (> pos (line-end-position)) (ruby-smie--implicit-semi-p))
       (skip-chars-forward " \t") ";")
-     ((and (bolp) (not (bobp))) "")         ;Presumably a heredoc.
+     ((and (bolp) (not (bobp)))         ;Presumably a heredoc.
+      ;; Tokenize the whole heredoc as semicolon.
+      (goto-char (scan-sexps (point) -1))
+      ";")
      ((and (> pos (point)) (not (bolp))
            (ruby-smie--args-separator-p pos))
       ;; We have "ID SPC ID", which is a method call, but it binds less tightly
index 1439ee12bb4a94318b7cff8077fc6d852481cf8e..3f9f4e8810a43cdc64c48fe687bc3b20a8c2bc83 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-04  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: Add a statement on the line after heredoc.
+
+       * automated/ruby-mode-tests.el: Remove outdated comment.
+
 2013-11-04  Glenn Morris  <rgm@gnu.org>
 
        * automated/Makefile.in (abs_srcdir): Remove.
index dc86b4a291470a69df49e88b6acae44524bf783f..d5d262590b6dcee7d9e522e7dbfb9ae2096b8a7a 100644 (file)
@@ -585,8 +585,6 @@ VALUES-PLIST is a list with alternating index and value elements."
     (end-of-defun)
     (should (= 5 (line-number-at-pos)))))
 
-;; Tests below fail when using SMIE.
-
 (defvar ruby-sexp-test-example
   (ruby-test-string
    "class C
index 65c33bb3ecf43a5dcb064654c2f23e1cfca5adba..4bf65ffcf27701e38a096f9e151215f56edd3e61 100644 (file)
@@ -3,6 +3,7 @@ if something_wrong?             # ruby-move-to-block-skips-heredoc
   boo hoo
   end
   eowarn
+  foo
 end
 
 # Percent literals.