Summary: Put spam mark on the message registered as spam and
[elisp/wanderlust.git] / elmo / elmo-split.el
index 310f031..630b707 100644 (file)
@@ -185,7 +185,7 @@ It can be some ACTION as in `elmo-split-rule'."
     (let (result)
       (dolist (field (if (listp field-or-fields)
                         field-or-fields
-                      (list field)))
+                      (list field-or-fields)))
        (let ((addrs (mapcar
                      'std11-address-string
                      (std11-parse-addresses-string
@@ -205,7 +205,7 @@ It can be some ACTION as in `elmo-split-rule'."
     (let (result)
       (dolist (field (if (listp field-or-fields)
                         field-or-fields
-                      (list field)))
+                      (list field-or-fields)))
        (let ((addrs (mapcar
                      'std11-address-string
                      (std11-parse-addresses-string
@@ -229,7 +229,7 @@ It can be some ACTION as in `elmo-split-rule'."
     (let (result)
       (dolist (field (if (listp field-or-fields)
                         field-or-fields
-                      (list field)))
+                      (list field-or-fields)))
        (let ((field-value (and
                            elmo-split-message-entity
                            (elmo-split-fetch-decoded-field
@@ -250,7 +250,7 @@ It can be some ACTION as in `elmo-split-rule'."
     (let (result)
       (dolist (field (if (listp field-or-fields)
                         field-or-fields
-                      (list field)))
+                      (list field-or-fields)))
        (let ((field-value (and elmo-split-message-entity
                                (elmo-split-fetch-decoded-field
                                 elmo-split-message-entity
@@ -297,7 +297,7 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
        (fcount 0)
        ret)
     (dolist (folder folders)
-      (setq ret (elmo-split-subr (elmo-make-folder folder) arg)
+      (setq ret (elmo-split-subr (elmo-get-folder folder) arg)
            count (+ count (car ret))
            fcount (+ fcount (cdr ret))))
     (run-hooks 'elmo-split-hook)
@@ -316,8 +316,7 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
     count))
 
 (defun elmo-split-subr (folder &optional reharsal)
-  (let ((elmo-inhibit-display-retrieval-progress t)
-       (count 0)
+  (let ((count 0)
        (fcount 0)
        (default-rule `((t ,elmo-split-default-action)))
        msgs action target-folder failure delete-substance
@@ -325,22 +324,19 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
     (message "Splitting...")
     (elmo-folder-open-internal folder)
     (setq msgs (elmo-folder-list-messages folder))
-    (elmo-progress-set 'elmo-split (length msgs) "Splitting...")
-    (unwind-protect
-       (progn
+    (elmo-with-progress-display (elmo-split (length msgs)) "Splitting messages"
+      (unwind-protect
          (with-temp-buffer
+           (set-buffer-multibyte nil)
            (dolist (msg msgs)
              (erase-buffer)
              (when (ignore-errors
                      (elmo-message-fetch folder msg
                                          (elmo-make-fetch-strategy 'entire)
-                                         nil (current-buffer) 'unread))
+                                         'unread))
                (run-hooks 'elmo-split-fetch-hook)
                (setq elmo-split-message-entity (mime-parse-buffer))
-               (setq flags (elmo-message-flags
-                            folder
-                            msg
-                            (elmo-msgdb-get-message-id-from-buffer)))
+               (setq flags (elmo-message-flags-for-append folder msg))
                (catch 'terminate
                  (dolist (rule (append elmo-split-rule default-rule))
                    (setq elmo-split-match-string-internal nil)
@@ -361,7 +357,7 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
                         ((stringp action)
                          (condition-case nil
                              (progn
-                               (setq target-folder (elmo-make-folder action))
+                               (setq target-folder (elmo-get-folder action))
                                (unless (elmo-folder-exists-p target-folder)
                                  (when
                                      (and
@@ -438,8 +434,7 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
                      (unless (eq (nth 2 rule) 'continue)
                        (throw 'terminate nil))))))
              (elmo-progress-notify 'elmo-split)))
-         (elmo-folder-close-internal folder))
-      (elmo-progress-clear 'elmo-split))
+       (elmo-folder-close-internal folder)))
     (cons count fcount)))
 
 (require 'product)