まつもと ゆきひろです.

In message "[ruby-list:4034] Re: ruby-mode.el ... _end problem"
    on 97/09/02, Yukihiro Matsumoto <matz / netlab.co.jp> writes:

|まつもと ゆきひろです

||バイトコンパイルはしてないし、ruby-mode.elをvisitして、
||eval-bufferしても同じですし...
|
|すみません.対応が不十分だったんですね (_ _)
|もうちょっと待って下さい.

というわけで以下のパッチでどうでしょう.もとのファイルに当て
直して下さい.

--- sample/ruby-mode.el~	Fri Aug 22 18:17:53 1997
+++ sample/ruby-mode.el	Tue Sep  2 09:55:04 1997
@@ -34,3 +34,5 @@
   (concat "[?$/%(){}#\"'`]\\|\\[\\|\\]\\|\\<\\("
-	    ruby-block-beg-re "\\|" ruby-block-end-re "\\)\\>")
+	  ruby-block-beg-re
+	  "\\|" ruby-block-end-re
+	  "\\)\\>\\|^=begin")
   )
@@ -39,3 +41,3 @@
   (concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\|\\("
-	    ruby-block-end-re "\\)\\>\\|\\}\\|\\]\\)")
+	    ruby-block-end-re "\\)\\>[^_]\\|\\}\\|\\]\\)")
   )
@@ -192,3 +194,5 @@
 		(looking-at ruby-block-op-re)
-		(looking-at ruby-block-mid-re)))))))
+		(looking-at ruby-block-mid-re))
+	       (goto-char (match-end 0))
+	       (looking-at "[^_]"))))))
 
@@ -286,9 +290,12 @@
 	       ((looking-at ruby-block-end-re)
-		(if (and (not (bolp))
-			 (progn
-			   (forward-char -1)
-			   (eq ?_ (char-after (point))))
+		(if (and (or (not (bolp))
+			     (progn
+			       (forward-char -1)
+			       (eq ?_ (char-after (point)))))
 			 (progn
 			   (goto-char pnt)
-			   (eq ?_ (char-after (point)))))
+			   (setq w (char-after (point)))
+			   (or (eq ?_ w)
+			       (eq ?! w)
+			       (eq ?? w))))
 		    nil
@@ -303,3 +310,3 @@
 		       (not (eq ?_ (char-after (point))))))
-		 (save-excursion
+		 (progn
 		   (goto-char pnt)
@@ -320,2 +327,7 @@
 		  (goto-char pnt)))
+	       ((looking-at "^=begin")
+		(if (re-search-forward "^=end" indent-point t)
+		    (forward-line 1)
+		  (setq in-string (match-end 0))
+		  (goto-char indent-point)))
 	       (t
@@ -466,3 +478,3 @@
   (interactive "p")
-  (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\b")
+  (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\b[^_]")
 			  nil 'move (or arg 1))