[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: sb-ruby.el (non-member post)



From: NAKAJIMA Mikio <minakaji@osaka.email.ne.jp>
Subject: Re: sb-ruby.el (non-member post)
Date: Tue, 12 Mar 2002 06:11:57 +0900

>   お手数ですが、ChangeLog を書いていただけないでしょうか?  代理 commit
> させていただきますので。

ChangeLogの書式を全く知らないのですが、過去のものを参考に書いてみました。
前回のメールの一つ目:

	* shimbun/sb-ruby.el (shimbun-index-url): Search articles
	from `(point-max)' for checking all articles.

二つ目についても一応書いておきます。
ただ、前回のパッチは問題が多かったので、新しく添付します。

	* shimbun/sb-ruby.el (shimbun-index-url): Fixed regexp and
	indentation.
	(shimbun-make-contents): Add Message-Id
	 and References header to articles.
	(shimbun-ruby-convert-link-to-id): New function.

これでよろしいでしょうか。

---
SAITO Takuya <reed@lily.freemail.ne.jp>
--- sb-ruby.el.fix	Mon Mar 11 23:10:30 2002
+++ sb-ruby.el	Tue Mar 12 15:19:34 2002
@@ -57,6 +57,16 @@
 				  (match-string 4 str))
       str)))
 
+(defun shimbun-ruby-convert-link-to-id (str regexp)
+  (while (string-match regexp str)
+    (setq str (replace-match (format "<%s:%s@ruby-lang.org>"
+				     (match-string 1 str)
+				     (match-string 2 str))
+			     t t str)))
+  (while (string-match "\\* " str)
+    (setq str (replace-match "" t t str)))
+  str)
+
 (luna-define-method shimbun-index-url ((shimbun shimbun-ruby))
   (concat (shimbun-url-internal shimbun)
 	  "/"
@@ -67,7 +77,7 @@
 (luna-define-method shimbun-get-headers ((shimbun shimbun-ruby)
 					 &optional range)
   (let ((case-fold-search t)
-	(start (progn (re-search-forward "^<table" nil t nil)
+	(start (progn (re-search-forward "<table" nil t nil)
 		      (forward-line 1) (beginning-of-line 1)
 		      (point)))
 	(end (progn (re-search-forward "</table>" nil t nil)
@@ -87,7 +97,7 @@
 		   "/"
 		   (cdr (assoc (shimbun-current-group-internal shimbun)
 			       shimbun-ruby-group-path-alist))
-	   "/"
+		   "/"
 		   (setq aux (car auxs))))
 	  (subst-char-in-region (point-min) (point-max) ?\t ?  t)
 	  (let ((case-fold-search t)
@@ -116,7 +126,7 @@
 
 (luna-define-method shimbun-make-contents ((shimbun shimbun-ruby) header)
   (let ((headers '(("^Subject: \\(.+\\)$" . shimbun-header-set-subject)
-		   ("^From:\\(.+\\)$" . shimbun-header-set-from)
+		   ("^From: \\(.+\\)$" . shimbun-header-set-from)
 		   ("^Date: \\(.+\\)$" . shimbun-header-set-date)))
 	;; any other headers to be included?
 	;;<A NAME=head></A><pre><A HREF="/cgi-bin/scat.rb/ruby/ruby-list/29726">...<a href="/ruby/ruby-list/29727">o</a> <a href="/cgi-bin/scat.rb/ruby/ruby-list/29727?help">HELP</a>
@@ -126,26 +136,45 @@
 	;;In-reply-to: <a href="/cgi-bin/scat.rb/ruby/ruby-list/29724">29724</a>
 	;;References: <a href="/cgi-bin/scat.rb/ruby/ruby-list/29720">29720</a> <a href="/cgi-bin/scat.rb/ruby/ruby-list/29724">29724</a>
 	;;<hr>
-	headerstart value)
+	headerend value)
     (if (not (re-search-forward "^Subject:" nil t nil))
 	nil
-      (setq headerstart (progn (beginning-of-line) (point-marker)))
-      (delete-region headerstart (point-min)))
+      (beginning-of-line)
+      (delete-region (point-min) (point)))
     (if (re-search-forward "^<hr><a name=tail>" nil t nil)
 	(delete-region (progn (beginning-of-line) (point)) (point-max)))
+    (goto-char (point-min))
+    (when (search-forward "<hr>" nil t nil)
+      (goto-char (match-beginning 0))
+      (insert "\n") ;;References sometimes does not end with "\n"
+      (forward-char 4)
+      (setq headerend (point)))
     (while headers
       (goto-char (point-min))
-      (if (re-search-forward (car (car headers)) nil t nil)
+      (if (re-search-forward (car (car headers)) headerend t nil)
 	  (and
 	   (setq value (match-string-no-properties 1))
 	   (setq value (with-temp-buffer (insert value)
 					 (shimbun-remove-markup)
 					 (shimbun-decode-entities)
 					 (buffer-string)))
+	   (setq value (shimbun-mime-encode-string value))
 	   (funcall (cdr (car headers)) header value)))
       (setq headers (cdr headers)))
-    (search-forward "<hr>" nil t nil)
-    (delete-region (point) headerstart)
+    ;;Message-Id:
+    (setq value (shimbun-ruby-convert-link-to-id
+		 (shimbun-article-url shimbun header)
+		 "http://[^ ]*/\\([^/]+\\)/\\([0-9]+\\)"))
+    (shimbun-header-set-id header value)
+    ;;References:
+    (goto-char (point-min))
+    (when (or (re-search-forward "^References: \\(.+\\)$" headerend t)
+	      (re-search-forward "^In-reply-to: \\(.+\\)$" headerend t))
+      (setq value (shimbun-ruby-convert-link-to-id
+		   (match-string-no-properties 1)
+		   "<a [^ ]*/\\([^/]+\\)/\\([0-9]+\\)\">[0-9]+</a>"))
+      (shimbun-header-set-references header value))
+    (delete-region (point-min) (or headerend (point-min)))
     (shimbun-header-insert shimbun header)
     (insert
      "Content-Type: text/html; charset=ISO-2022-JP\nMIME-Version: 1.0\n")