aboutsummaryrefslogtreecommitdiffstats
path: root/misc/ruby-mode.el
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 15:56:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 15:56:34 +0000
commit5f3e191f958a1c49603da8f6275e91fb0ec84ec4 (patch)
treeb73a33456b4f9d661c1deda7bfefb28773da52ea /misc/ruby-mode.el
parent360e0b93fdd23e385e26d1fe60822c8779888b87 (diff)
downloadruby-5f3e191f958a1c49603da8f6275e91fb0ec84ec4.tar.gz
* 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
Diffstat (limited to 'misc/ruby-mode.el')
-rw-r--r--misc/ruby-mode.el13
1 files changed, 11 insertions, 2 deletions
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)))))))