(elmo-shimbun-update-overview): Add argnument
[elisp/wanderlust.git] / elmo / elsp-bogofilter.el
index 41adb35..8548650 100644 (file)
@@ -53,7 +53,7 @@
   :group 'elmo-spam-bogofilter)
 
 (defcustom elmo-spam-bogofilter-max-messages-per-process 30
-  "Number of messages processed at one once"
+  "Number of messages processed at once."
   :type 'integer
   :group 'elmo-spam-bogofilter)
 
@@ -124,27 +124,15 @@ Must be return a string or list of string."
   (elsp-bogofilter-register-buffer buffer nil restore))
 
 (defsubst elmo-spam-bogofilter-register-messages (folder numbers spam restore)
-  (with-temp-buffer
-    (buffer-disable-undo (current-buffer))
-    (while numbers
-      (let ((count 0))
-       (while (and numbers
-                   (< count elmo-spam-bogofilter-max-messages-per-process))
-         (insert "From MAILER-DAEMON\n"
-                 (with-temp-buffer
-                   (elmo-spam-message-fetch folder (car numbers))
-                   (goto-char (point-min))
-                   (while (re-search-forward "^>*From " nil t)
-                     (goto-char (match-beginning 0))
-                     (insert ?>)
-                     (forward-line))
-                   (buffer-substring (point-min) (point-max)))
-                 "\n\n")
-         (setq count (1+ count)
-               numbers (cdr numbers)))
-       (elsp-bogofilter-register-buffer (current-buffer) spam restore)
-       (elmo-progress-notify 'elmo-spam-register count)
-       (erase-buffer)))))
+  (if (not (< 0 elmo-spam-bogofilter-max-messages-per-process))
+      (error "\
+non-positive value for `elmo-spam-bogofilter-max-messages-per-process'"))
+  (elmo-spam-process-messages-as-mbox
+   folder numbers elmo-spam-bogofilter-max-messages-per-process
+   (lambda (count spam restore)
+     (elsp-bogofilter-register-buffer (current-buffer) spam restore)
+     (elmo-progress-notify 'elmo-spam-register count))
+   spam restore))
 
 (luna-define-method elmo-spam-register-spam-messages :around
   ((processor elsp-bogofilter) folder &optional numbers restore)