* wl-draft.el (wl-draft-edit-string): Fetch From: field value and
[elisp/wanderlust.git] / wl / wl-draft.el
index 3ff553d..e7d7787 100644 (file)
 (defun wl-draft-insert-x-face-field ()
   "Insert X-Face header."
   (interactive)
-  (if (not (file-exists-p wl-x-face-file))
-      (error "File %s does not exist" wl-x-face-file)
-    (beginning-of-buffer)
-    (search-forward mail-header-separator nil t)
-    (beginning-of-line)
-    (wl-draft-insert-x-face-field-here)
-    (run-hooks 'wl-draft-insert-x-face-field-hook))) ; highlight it if you want.
+  (unless (file-exists-p wl-x-face-file)
+    (error "File %s does not exist" wl-x-face-file))
+  (beginning-of-buffer)
+  (search-forward mail-header-separator nil t)
+  (beginning-of-line)
+  (wl-draft-insert-x-face-field-here)
+  (run-hooks 'wl-draft-insert-x-face-field-hook)) ; highlight it if you want.
 
 (defun wl-draft-insert-x-face-field-here ()
   "Insert X-Face field at point."
@@ -453,15 +453,11 @@ Reply to author if WITH-ARG is non-nil."
 (defun wl-draft-confirm ()
   "Confirm send message."
   (interactive)
-  (y-or-n-p (format "Send current draft as %s? "
-                   (cond ((and (wl-message-mail-p) (wl-message-news-p))
-                          "Mail and News")
-                         ((wl-message-mail-p) "Mail")
-                         ((wl-message-news-p) "News")))))
-
-(defun wl-message-news-p ()
-  "If exist valid Newsgroups field, return non-nil."
-  (std11-field-body "Newsgroups"))
+  (y-or-n-p
+   (cond ((and (wl-message-mail-p) (wl-message-news-p))
+         "Send current draft as Mail and News? ")
+        ((wl-message-mail-p) "Send current draft as Mail? ")
+        ((wl-message-news-p) "Send current draft as News? "))))
 
 (defun wl-message-field-exists-p (field)
   "If FIELD exist and FIELD value is not empty, return non-nil."
@@ -469,6 +465,10 @@ Reply to author if WITH-ARG is non-nil."
     (and value
         (not (string= value "")))))
 
+(defun wl-message-news-p ()
+  "If exist valid Newsgroups field, return non-nil."
+  (std11-field-body "Newsgroups"))
+
 (defun wl-message-mail-p ()
   "If exist To, Cc or Bcc field, return non-nil."
   (or (wl-message-field-exists-p "To")
@@ -491,9 +491,8 @@ Reply to author if WITH-ARG is non-nil."
   (let ((cur-buf (current-buffer))
        (tmp-buf (get-buffer-create " *wl-draft-edit-string*"))
        to subject in-reply-to cc references newsgroups mail-followup-to
-       content-type content-transfer-encoding
-       body-beg buffer-read-only
-       )
+       content-type content-transfer-encoding from
+       body-beg buffer-read-only)
     (set-buffer tmp-buf)
     (erase-buffer)
     (insert string)
@@ -509,6 +508,12 @@ Reply to author if WITH-ARG is non-nil."
                        (decode-mime-charset-string
                         subject
                         wl-mime-charset))))
+    (setq from (std11-field-body "From")
+         from (and from
+                   (eword-decode-string
+                    (decode-mime-charset-string
+                     from
+                     wl-mime-charset))))    
     (setq in-reply-to (std11-field-body "In-Reply-To"))
     (setq cc (std11-field-body "Cc"))
     (setq cc (and cc
@@ -530,8 +535,10 @@ Reply to author if WITH-ARG is non-nil."
                   mail-followup-to
                   content-type content-transfer-encoding
                   (buffer-substring (point) (point-max))
-                  'edit-again
-                  ))
+                  'edit-again nil
+                  (if (member (nth 1 (std11-extract-address-components from))
+                              wl-user-mail-address-list)
+                      from)))
       (and to (mail-position-on-field "To"))
       (delete-other-windows)
       (kill-buffer tmp-buf)))
@@ -671,7 +678,7 @@ Reply to author if WITH-ARG is non-nil."
            (let ((msg (and wl-draft-buffer-file-name
                            (string-match "[0-9]+$" wl-draft-buffer-file-name)
                            (string-to-int
-                            (elmo-match-string 0 wl-draft-buffer-file-name)))))
+                            (match-string 0 wl-draft-buffer-file-name)))))
              (wl-draft-config-info-operation msg 'delete))))
       (set-buffer-modified-p nil)              ; force kill
       (kill-buffer editing-buffer))))
@@ -1032,11 +1039,11 @@ If FORCE-MSGID, ignore 'wl-insert-message-id'."
        (if (and sent-via wl-draft-fcc-list)
            (progn
              (wl-draft-do-fcc (wl-draft-get-header-delimiter) wl-draft-fcc-list)
-             (setq wl-draft-fcc-list nil))
-         (if wl-draft-use-cache
-             (let ((id (std11-field-body "Message-ID"))
-                   (elmo-enable-disconnected-operation t))
-               (elmo-cache-save id nil nil nil))))
+             (setq wl-draft-fcc-list nil)))
+       (if wl-draft-use-cache
+           (let ((id (std11-field-body "Message-ID"))
+                 (elmo-enable-disconnected-operation t))
+             (elmo-cache-save id nil nil nil)))
        ;; If one unplugged, append queue.
        (when (and unplugged-via
                   wl-sent-message-modified)
@@ -1132,7 +1139,7 @@ If optional argument is non-nil, current draft buffer is killed"
   (wl-draft-config-info-operation
    (and (string-match "[0-9]+$" wl-draft-buffer-file-name)
        (string-to-int
-        (elmo-match-string 0 wl-draft-buffer-file-name)))
+        (match-string 0 wl-draft-buffer-file-name)))
    'save))
 
 (defun wl-draft-mimic-kill-buffer ()
@@ -1270,15 +1277,11 @@ If optional argument is non-nil, current draft buffer is killed"
                nil
              (if (re-search-forward ":" pos t) nil t)))))))
 
-(defun wl-draft-random-alphabet ()
-  (let ((alphabet '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z)))
-    (nth (abs (% (random) 26)) alphabet)))
-
 ;;;###autoload
 (defun wl-draft (&optional to subject in-reply-to cc references newsgroups
                           mail-followup-to
                           content-type content-transfer-encoding
-                          body edit-again summary-buf)
+                          body edit-again summary-buf from)
   "Write and send mail/news message with Wanderlust."
   (interactive)
   (unless (featurep 'wl)
@@ -1311,13 +1314,13 @@ If optional argument is non-nil, current draft buffer is killed"
     (if (or (eq wl-draft-reply-buffer-style 'full)
            (eq this-command 'wl-draft)
            (eq this-command 'wl-summary-write)
-           (eq this-command 'wl-summary-write-current-newsgroup))
+           (eq this-command 'wl-summary-write-current-folder))
        (delete-other-windows))
     (auto-save-mode -1)
     (wl-draft-mode)
     (setq wl-sent-message-via nil)
-    (if (stringp wl-from)
-       (insert "From: " wl-from "\n"))
+    (if (stringp (or from wl-from))
+       (insert "From: " (or from wl-from) "\n"))
     (and (or (interactive-p)
             (eq this-command 'wl-summary-write)
             to)