* .cvsignore: Add mkinstalldirs entry.
[elisp/mixi.git] / mixi-gnus.el
index 5557ea4..82fb1cc 100644 (file)
 ;;; Code:
 
 (require 'sb-mixi)
-(require 'message)
+
+;; Functions and variables which should be defined in the other module
+;; at run-time.
+(eval-when-compile
+  (defvar message-this-is-news)
+  (defvar message-sent-message-via)
+  (defvar message-send-method-alist)
+  (autoload 'message-narrow-to-headers "message")
+  (autoload 'message-fetch-field "message")
+  (autoload 'message-generate-new-buffer-clone-locals "message")
+  (autoload 'message-goto-body "message")
+  (autoload 'mml-buffer-substring-no-properties-except-hard-newlines "mml"))
 
 (defun message-mixi-p ()
   "Say whether the current buffer contains a mixi message."
@@ -43,7 +54,7 @@
        (save-excursion
         (save-restriction
           (message-narrow-to-headers)
-          (or (message-fetch-field "mixi")
+          (or (message-fetch-field "mixi-to")
               (string-match shimbun-mixi-to-regexp
                             (message-fetch-field "to")))))))
 
@@ -55,8 +66,9 @@
     ;; Avoid matching with message-mail-p.
     (with-current-buffer mailbuf
       (goto-char (point-min))
-      (when (search-forward "\nTo: " nil t)
-       (replace-match "\nMixi: ")))
+      (unless (search-forward "\nMixi-To: " nil t)
+       (when (search-forward "\nTo: " nil t)
+         (replace-match "\nMixi-To: "))))
     (unwind-protect
        (save-excursion
          (set-buffer tembuf)
@@ -65,7 +77,7 @@
          (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")
+         (shimbun-mixi-send-mail (message-fetch-field "mixi-to")
                                  (message-fetch-field "subject")
                                  (buffer-substring (message-goto-body)
                                                    (point-max))))
@@ -77,8 +89,7 @@
   (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)))))
 
 (provide 'mixi-gnus)