[前][次][番号順一覧][スレッド一覧]

ruby-changes:18793

From: nobu <ko1@a...>
Date: Tue, 8 Feb 2011 00:56:47 +0900 (JST)
Subject: [ruby-changes:18793] Ruby:r30819 (trunk): * misc/ruby-mode.el (ruby-expr-beg, ruby-in-here-doc-p): tell

nobu	2011-02-08 00:56:34 +0900 (Tue, 08 Feb 2011)

  New Revision: 30819

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30819

  Log:
    * misc/ruby-mode.el (ruby-expr-beg, ruby-in-here-doc-p): tell
      singleton class definitions from here documents.

  Modified files:
    trunk/ChangeLog
    trunk/misc/ruby-mode.el

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30818)
+++ ChangeLog	(revision 30819)
@@ -1,5 +1,8 @@
-Tue Feb  8 00:53:14 2011  Nobuyoshi Nakada  <nobu@r...>
+Tue Feb  8 00:56:33 2011  Nobuyoshi Nakada  <nobu@r...>
 
+	* 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.
 
Index: misc/ruby-mode.el
===================================================================
--- misc/ruby-mode.el	(revision 30818)
+++ misc/ruby-mode.el	(revision 30819)
@@ -438,6 +438,12 @@
           ((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 @@
                (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 @@
       (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)))))))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]