From dca01b092347246195d35c4bbce321f62323d8d8 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 4 Nov 2013 12:50:47 +0200 Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-smie--forward-token) (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 | 5 +++++ lisp/progmodes/ruby-mode.el | 12 ++++++++++-- test/ChangeLog | 6 ++++++ test/automated/ruby-mode-tests.el | 2 -- test/indent/ruby.rb | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ff4ab8f04c..4c2c4cd5e07 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-11-04 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-smie--forward-token) + (ruby-smie--backward-token): Tokenize heredocs as semicolons. + 2013-11-04 Michal Nazarewicz * textmodes/fill.el (fill-single-char-nobreak-p): New function diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 75c59ebe1fd..1c9663cc22c 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -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 diff --git a/test/ChangeLog b/test/ChangeLog index 1439ee12bb4..3f9f4e8810a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2013-11-04 Dmitry Gutov + + * indent/ruby.rb: Add a statement on the line after heredoc. + + * automated/ruby-mode-tests.el: Remove outdated comment. + 2013-11-04 Glenn Morris * automated/Makefile.in (abs_srcdir): Remove. diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index dc86b4a2914..d5d262590b6 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -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 diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 65c33bb3ecf..4bf65ffcf27 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -3,6 +3,7 @@ if something_wrong? # ruby-move-to-block-skips-heredoc boo hoo end eowarn + foo end # Percent literals. -- 2.39.2