* test-dist.el (test-elmo-modules-trailing-whitespace)
[elisp/wanderlust.git] / wl / wl-mime.el
index c8a798e..0c14cfd 100644 (file)
 (require 'mime-view)
 (require 'mime-edit)
 (require 'mime-play)
+(require 'mime-parse)
+(eval-when-compile (require 'mmbuffer))
 (require 'elmo)
+(require 'elmo-mime)
 (require 'wl-vars)
+(require 'wl-util)
 (eval-when-compile (require 'cl))
 
 ;;; Draft
@@ -58,8 +62,7 @@ has Non-nil value\)"
                     (function wl-draft-yank-to-draft-buffer))))
        (message-buffer (wl-current-message-buffer)))
     (if message-buffer
-       (save-excursion
-         (set-buffer message-buffer)
+       (with-current-buffer message-buffer
          (save-restriction
            (widen)
            (cond
@@ -90,8 +93,7 @@ It calls following-method selected from variable
       (setq min (point-min)
            beg (re-search-forward "^$" nil t)
            end (point-max)))
-    (save-excursion
-      (set-buffer (setq new-buf (get-buffer-create new-name)))
+    (with-current-buffer (setq new-buf (get-buffer-create new-name))
       (erase-buffer)
       (insert-buffer-substring the-buf beg end)
       (goto-char (point-min))
@@ -122,8 +124,7 @@ It calls following-method selected from variable
           new-buf
           (the-buf (current-buffer))
           fields)
-      (save-excursion
-       (set-buffer (setq new-buf (get-buffer-create new-name)))
+      (with-current-buffer (setq new-buf (get-buffer-create new-name))
        (erase-buffer)
        (insert ?\n)
        (insert-buffer-substring the-buf r-beg r-end)
@@ -150,8 +151,7 @@ It calls following-method selected from variable
            (setq field-name (car rest))
            (or (std11-field-body field-name)
                (progn
-                 (save-excursion
-                   (set-buffer the-buf)
+                 (with-current-buffer the-buf
                    (let ((entity (when mime-mother-buffer
                                    (set-buffer mime-mother-buffer)
                                    (get-text-property (point)
@@ -415,7 +415,7 @@ It calls following-method selected from variable
 
 (defsubst wl-mime-node-id-to-string (node-id)
   (if (consp node-id)
-      (mapconcat (function (lambda (num) (format "%s" (1+ num))))
+      (mapconcat (lambda (num) (format "%s" (1+ num)))
                 (reverse node-id)
                 ".")
     "0"))
@@ -450,7 +450,7 @@ It calls following-method selected from variable
                  (format "Do you really want to delete part %s? "
                          (wl-mime-node-id-to-string node-id))))
        (when (with-temp-buffer
-               (insert-buffer orig-buf)
+               (insert-buffer-substring orig-buf)
                (delete-region header-start body-end)
                (goto-char header-start)
                (insert "Content-Type: text/plain; charset=US-ASCII\n")
@@ -484,8 +484,11 @@ It calls following-method selected from variable
 (eval-when-compile
   (defmacro wl-define-dummy-functions (&rest symbols)
     `(dolist (symbol (quote ,symbols))
-       (defalias symbol 'ignore)))
+       (defalias symbol 'ignore))))
 
+(eval-when-compile
+  ;; split eval-when-compile form for avoid error on `make compile-strict'
+  (require 'mime-pgp)
   (condition-case nil
       (require 'epa)
     (error
@@ -605,7 +608,7 @@ It calls following-method selected from variable
          (inhibit-read-only t)
          coding-system)
       (unless region
-       (error "Cannot find pgp encrypted region"))
+       (error "Cannot find PGP encrypted region"))
       (save-restriction
        (let ((props (text-properties-at (car region))))
          (narrow-to-region (car region) (cdr region))
@@ -625,6 +628,8 @@ With ARG, ask coding system and encode the region with it before verifying."
     (let ((region (wl-find-region "^-+BEGIN PGP SIGNED MESSAGE-+$"
                                  "^-+END PGP SIGNATURE-+$"))
          coding-system)
+      (unless region
+       (error "Cannot find PGP signed region"))
       (setq coding-system
            (or (get-text-property (car region) 'wl-mime-decoded-coding-system)
                (let* ((situation (mime-preview-find-boundary-info))
@@ -866,8 +871,6 @@ With ARG, ask destination folder."
        (elmo-message-visible-field-list wl-message-visible-field-list)
        (elmo-message-sorted-field-list wl-message-sort-field-list))
     (elmo-mime-insert-header entity situation)
-    (goto-char (point-min))
-    (delete-matching-lines "^$")
     (wl-highlight-headers)))
 
 (defun wl-mime-decrypt-application/pgp-encrypted (entity situation)