summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--misc/ruby-mode.el13
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2900259cc6..46747c1300 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-Tue Feb 8 00:53:14 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Feb 8 00:56:33 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * misc/ruby-mode.el (ruby-expr-beg, ruby-in-here-doc-p): tell
+ singleton class definitions from here documents.
* misc/ruby-mode.el (ruby-expr-beg, ruby-parse-partial): keyword
followed by colon is label.
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)))))))