From 5f3e191f958a1c49603da8f6275e91fb0ec84ec4 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 7 Feb 2011 15:56:34 +0000 Subject: * misc/ruby-mode.el (ruby-expr-beg, ruby-in-here-doc-p): tell singleton class definitions from here documents. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- misc/ruby-mode.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'misc/ruby-mode.el') diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 3b0103c3a0..c795773032 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -438,6 +438,12 @@ The variable ruby-indent-level controls the amount of indentation. ((and (eq c ?:) (or (not b) (eq (char-syntax b) ? )))) ((eq c ?\\) (eq b ??))))) +(defun ruby-singleton-class-p () + (save-excursion + (forward-word -1) + (and (or (bolp) (not (eq (char-before (point)) ?_))) + (looking-at "class\\s *<<")))) + (defun ruby-expr-beg (&optional option) (save-excursion (store-match-data nil) @@ -451,7 +457,9 @@ The variable ruby-indent-level controls the amount of indentation. (or (eq (char-syntax (char-before (point))) ?w) (ruby-special-char-p)))) nil) - ((and (eq option 'heredoc) (< space 0)) t) + ((and (progn (goto-char start) (eq option 'heredoc)) + (not (ruby-singleton-class-p))) + t) ((or (looking-at ruby-operator-re) (looking-at "[\\[({,;]") (and (looking-at "[!?]") @@ -1229,7 +1237,8 @@ balanced expression is found." (let ((old-point (point)) (case-fold-search nil)) (beginning-of-line) (catch 'found-beg - (while (re-search-backward ruby-here-doc-beg-re nil t) + (while (and (re-search-backward ruby-here-doc-beg-re nil t) + (not (ruby-singleton-class-p))) (if (not (or (ruby-in-ppss-context-p 'anything) (ruby-here-doc-find-end old-point))) (throw 'found-beg t))))))) -- cgit v1.2.3