* wl-draft.el (wl-draft-send, wl-draft-do-fcc): Suppress compile warnings; Use
[elisp/wanderlust.git] / wl / wl-draft.el
index 8121eb0..828b50a 100644 (file)
@@ -135,32 +135,32 @@ e.g.
          user mechanism server))
 
 (defmacro wl-smtp-extension-bind (&rest body)
-  (` (let* ((smtp-sasl-mechanisms
-            (if wl-smtp-authenticate-type
-                (mapcar 'upcase
-                        (if (listp wl-smtp-authenticate-type)
-                            wl-smtp-authenticate-type
-                          (list wl-smtp-authenticate-type)))))
-           (smtp-use-sasl (and smtp-sasl-mechanisms t))
-           (smtp-use-starttls (eq wl-smtp-connection-type 'starttls))
-           (smtp-open-connection-function
-            (if (eq wl-smtp-connection-type 'ssl)
-                #'open-ssl-stream
-              smtp-open-connection-function))
-           smtp-sasl-user-name smtp-sasl-properties sasl-read-passphrase)
-       (setq smtp-sasl-user-name wl-smtp-posting-user
-            smtp-sasl-properties (when wl-smtp-authenticate-realm
-                                   (list 'realm
-                                         wl-smtp-authenticate-realm)))
-       (setq sasl-read-passphrase
-            (function
-             (lambda (prompt)
-               (elmo-get-passwd
-                (wl-smtp-password-key
-                 smtp-sasl-user-name
-                 (car smtp-sasl-mechanisms)
-                 smtp-server)))))
-       (,@ body))))
+  `(let* ((smtp-sasl-mechanisms
+          (if wl-smtp-authenticate-type
+              (mapcar 'upcase
+                      (if (listp wl-smtp-authenticate-type)
+                          wl-smtp-authenticate-type
+                        (list wl-smtp-authenticate-type)))))
+         (smtp-use-sasl (and smtp-sasl-mechanisms t))
+         (smtp-use-starttls (eq wl-smtp-connection-type 'starttls))
+         (smtp-open-connection-function
+          (if (eq wl-smtp-connection-type 'ssl)
+              #'open-ssl-stream
+            smtp-open-connection-function))
+         smtp-sasl-user-name smtp-sasl-properties sasl-read-passphrase)
+     (setq smtp-sasl-user-name wl-smtp-posting-user
+          smtp-sasl-properties (when wl-smtp-authenticate-realm
+                                 (list 'realm
+                                       wl-smtp-authenticate-realm)))
+     (setq sasl-read-passphrase
+          (function
+           (lambda (prompt)
+             (elmo-get-passwd
+              (wl-smtp-password-key
+               smtp-sasl-user-name
+               (car smtp-sasl-mechanisms)
+               smtp-server)))))
+     ,@body))
 
 (defun wl-draft-insert-date-field ()
   "Insert Date field."
@@ -487,8 +487,7 @@ or `wl-draft-reply-with-argument-list' if WITH-ARG argument is non-nil."
   (wl-draft-add-in-reply-to "References"))
 
 (defun wl-draft-add-in-reply-to (&optional alt-field)
-  (let* ((mes-id (save-excursion
-                  (set-buffer mail-reply-buffer)
+  (let* ((mes-id (with-current-buffer mail-reply-buffer
                   (std11-field-body "message-id")))
         (field (or alt-field "In-Reply-To"))
         (ref (std11-field-body field))
@@ -756,9 +755,8 @@ or `wl-draft-reply-with-argument-list' if WITH-ARG argument is non-nil."
 
 (defun wl-draft-delete (editing-buffer)
   "Kill the editing draft buffer and delete the file corresponds to it."
-  (save-excursion
-    (when editing-buffer
-      (set-buffer editing-buffer)
+  (when editing-buffer
+    (with-current-buffer editing-buffer
       (when wl-draft-buffer-message-number
        (elmo-folder-delete-messages (wl-draft-get-folder)
                                     (list
@@ -828,16 +826,16 @@ text was killed."
 ;; function for wl-sent-message-via
 
 (defmacro wl-draft-sent-message-p (type)
-  (` (eq (nth 1 (assq (, type) wl-sent-message-via)) 'sent)))
+  `(eq (nth 1 (assq ,type wl-sent-message-via)) 'sent))
 
 (defmacro wl-draft-set-sent-message (type result &optional server-port)
-  (` (let ((element (assq (, type) wl-sent-message-via)))
-       (if element
-          (unless (eq (nth 1 element) (, result))
-            (setcdr element (list (, result) (, server-port)))
-            (setq wl-sent-message-modified t))
-        (push (list (, type) (, result) (, server-port)) wl-sent-message-via)
-        (setq wl-sent-message-modified t)))))
+  `(let ((element (assq ,type wl-sent-message-via)))
+     (if element
+        (unless (eq (nth 1 element) ,result)
+          (setcdr element (list ,result ,server-port))
+          (setq wl-sent-message-modified t))
+       (push (list ,type ,result ,server-port) wl-sent-message-via)
+       (setq wl-sent-message-modified t))))
 
 (defun wl-draft-sent-message-results ()
   (let ((results wl-sent-message-via)
@@ -1070,8 +1068,7 @@ non-nil."
                (newline))
            (run-hooks 'wl-mail-send-pre-hook) ;; X-PGP-Sig, Cancel-Lock
            (if mail-interactive
-               (save-excursion
-                 (set-buffer errbuf)
+               (with-current-buffer errbuf
                  (erase-buffer)))
            (wl-draft-delete-field "bcc" delimline)
            (wl-draft-delete-field "resent-bcc" delimline)
@@ -1321,8 +1318,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
          (wl-draft-verbose-msg nil)
          err)
       (unwind-protect
-         (save-excursion
-           (set-buffer sending-buffer)
+         (with-current-buffer sending-buffer
            (if (and (not (wl-message-mail-p))
                     (not (wl-message-news-p)))
                (error "No recipient is specified"))
@@ -1402,7 +1398,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
                        "This is a blind carbon copy.")
                    "\n")
            (mime-edit-insert-tag "message" "rfc822")
-           (insert-buffer draft-buffer)
+           (insert-buffer-substring draft-buffer)
            (let (wl-interactive-send)
              (wl-draft-send 'kill-when-done))))))))
 
@@ -1558,15 +1554,12 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
 
 (defun wl-draft-do-fcc (header-end &optional fcc-list)
   (let ((send-mail-buffer (current-buffer))
-       (tembuf (generate-new-buffer " fcc output"))
        (case-fold-search t)
        beg end)
     (or (markerp header-end) (error "HEADER-END must be a marker"))
-    (save-excursion
-      (unless fcc-list
-       (setq fcc-list (wl-draft-get-fcc-list header-end)))
-      (set-buffer tembuf)
-      (erase-buffer)
+    (unless fcc-list
+      (setq fcc-list (wl-draft-get-fcc-list header-end)))
+    (with-temp-buffer
       ;; insert just the headers to avoid moving the gap more than
       ;; necessary (the message body could be arbitrarily huge.)
       (insert-buffer-substring send-mail-buffer 1 header-end)
@@ -1587,8 +1580,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
              (or (equal (car fcc-list) (car wl-read-folder-history))
                  (setq wl-read-folder-history
                        (append (list (car fcc-list)) wl-read-folder-history))))
-         (setq fcc-list (cdr fcc-list)))))
-    (kill-buffer tembuf)))
+         (setq fcc-list (cdr fcc-list)))))))
 
 (defun wl-draft-on-field-p ()
   (if (< (point)
@@ -1940,7 +1932,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
       (erase-buffer)
       (wl-draft-mode)
       (wl-draft-editor-mode)
-      (insert-buffer editing-buffer)
+      (insert-buffer-substring editing-buffer)
       (message "")
       (while local-variables
        (make-local-variable (car local-variables))
@@ -2009,21 +2001,21 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
     buffer))
 
 (defmacro wl-draft-body-goto-top ()
-  (` (progn
-       (goto-char (point-min))
-       (if (re-search-forward mail-header-separator nil t)
-          (forward-char 1)
-        (goto-char (point-max))))))
+  `(progn
+     (goto-char (point-min))
+     (if (re-search-forward mail-header-separator nil t)
+        (forward-char 1)
+       (goto-char (point-max)))))
 
 (defmacro wl-draft-body-goto-bottom ()
-  (` (goto-char (point-max))))
+  `(goto-char (point-max)))
 
 (defmacro wl-draft-config-body-goto-header ()
-  (` (progn
-       (goto-char (point-min))
-       (if (re-search-forward mail-header-separator nil t)
-          (beginning-of-line)
-        (goto-char (point-max))))))
+  `(progn
+     (goto-char (point-min))
+     (if (re-search-forward mail-header-separator nil t)
+        (beginning-of-line)
+       (goto-char (point-max)))))
 
 (defsubst wl-draft-config-sub-eval-insert (content &optional newline)
   (let (content-value)
@@ -2407,7 +2399,7 @@ Automatically applied in draft sending time."
        (message "No draft message exist.")
       (if (string-match (concat "^" wl-draft-folder "/") mybuf)
          (setq msg (cadr (memq
-                          (string-to-int (substring mybuf (match-end 0)))
+                          (string-to-number (substring mybuf (match-end 0)))
                           msgs))))
       (or msg (setq msg (car msgs)))
       (if (setq buf (get-buffer (format "%s/%d" wl-draft-folder msg)))