Sync up with gnus-6_2_3 to gnus-6_4_0
[elisp/gnus.git-] / lisp / gnus-draft.el
index f5e5d6c..fce8744 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-draft.el --- draft message support for Semi-gnus
 ;; Copyright (C) 1997,98 Free Software Foundation, Inc.
 
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;         MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Keywords: mail, news, MIME, offline
 
@@ -31,6 +31,7 @@
 (require 'message)
 (require 'gnus-msg)
 (require 'nndraft)
+(require 'gnus-agent)
 (eval-when-compile (require 'cl))
 
 ;;; Draft minor mode
   "Send message ARTICLE."
   (gnus-draft-setup article (or group "nndraft:queue"))
   (let ((message-syntax-checks 'dont-check-for-anything-just-trust-me)
-       message-send-hook)
-    (message-send-and-exit)))
+       message-send-hook type method)
+    ;; We read the meta-information that says how and where
+    ;; this message is to be sent.
+    (save-restriction
+      (message-narrow-to-head)
+      (when (re-search-forward
+            (concat "^" (regexp-quote gnus-agent-meta-information-header) ":")
+            nil t)
+       (setq type (ignore-errors (read (current-buffer)))
+             method (ignore-errors (read (current-buffer))))
+       (message-remove-header gnus-agent-meta-information-header)))
+    ;; Then we send it.  If we have no meta-information, we just send
+    ;; it and let Message figure out how.
+    (if type
+       (let ((message-this-is-news (eq type 'news))
+             (message-this-is-mail (eq type 'mail))
+             (gnus-post-method method)
+             (message-post-method method))
+         (message-send-and-exit))
+      (message-send-and-exit))))
 
 (defun gnus-draft-send-all-messages ()
   "Send all the sendable drafts."