(riece-mixi-message-filter): Rename from
[elisp/mixi.git] / mixi-gnus.el
index 4e7c72c..1d00893 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mixi-gnus.el --- Gnus integration for mixi
 
-;; Copyright (C) 2007 OHASHI Akira
+;; Copyright (C) 2007, 2008 OHASHI Akira
 
 ;; Author: OHASHI Akira <bg66@koka-in.org>
 ;; Keywords: news
@@ -18,9 +18,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, you can either send email to this
-;; program's maintainer or write to: The Free Software Foundation,
-;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -34,7 +34,7 @@
 
 ;;; Code:
 
-(require 'sb-mixi)
+(require 'mixi-utils)
 (require 'message)
 
 (defun message-mixi-p ()
@@ -44,8 +44,7 @@
         (save-restriction
           (message-narrow-to-headers)
           (or (message-fetch-field "mixi-to")
-              (string-match shimbun-mixi-to-regexp
-                            (message-fetch-field "to")))))))
+              (string-match mixi-to-regexp (message-fetch-field "to")))))))
 
 (defun message-send-via-mixi (arg)
   "Send the current message via mixi."
@@ -55,8 +54,9 @@
     ;; Avoid matching with message-mail-p.
     (with-current-buffer mailbuf
       (goto-char (point-min))
-      (when (search-forward "\nTo: " nil t)
-       (replace-match "\nMixi-To: ")))
+      (unless (search-forward "\nMixi-To: " nil t)
+       (when (search-forward "\nTo: " nil t)
+         (replace-match "\nMixi-To: "))))
     (unwind-protect
        (save-excursion
          (set-buffer tembuf)
          (insert (with-current-buffer mailbuf
                    (mml-buffer-substring-no-properties-except-hard-newlines
                     (point-min) (point-max))))
-         (shimbun-mixi-send-mail (message-fetch-field "mixi-to")
-                                 (message-fetch-field "subject")
-                                 (buffer-substring (message-goto-body)
-                                                   (point-max))))
+         (mixi-send-mail (message-fetch-field "mixi-to")
+                         (message-fetch-field "subject")
+                         (buffer-substring (message-goto-body)
+                                           (point-max))))
       (kill-buffer tembuf))
     (set-buffer mailbuf)
     (push 'mixi message-sent-message-via)))
   (let ((method '(mixi message-mixi-p message-send-via-mixi)))
     (unless (member method message-send-method-alist)
       (setq message-send-method-alist
-           (cons '(mixi message-mixi-p message-send-via-mixi)
-                 message-send-method-alist)))))
+           (cons method message-send-method-alist))))
+  ;; Avoid matching with bogus addresses for `message-send-via-mixi'.
+  (setq message-bogus-addresses
+       (remove "[ \t]" message-bogus-addresses)))
 
 (provide 'mixi-gnus)