From: hmurata Date: Sun, 25 Jan 2004 10:16:03 +0000 (+0000) Subject: (elmo-spam-bogofilter-max-messages-per-process): New user option. X-Git-Tag: wl-2_11_24~19 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=3fc6df63d5abe271c65d895a429f29aa8167eabc;p=elisp%2Fwanderlust.git (elmo-spam-bogofilter-max-messages-per-process): New user option. (elmo-spam-bogofilter-register-messages): New internal function. (elmo-spam-register-spam-messages): Define. (elmo-spam-register-good-messages): Ditto. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 7e12506..5d507c8 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,11 @@ +2004-01-25 Hiroya Murata + + * elsp-bogofilter.el + (elmo-spam-bogofilter-max-messages-per-process): New user option. + (elmo-spam-bogofilter-register-messages): New internal function. + (elmo-spam-register-spam-messages): Define. + (elmo-spam-register-good-messages): Ditto. + 2004-01-24 Hiroya Murata * elsp-bogofilter.el (elmo-spam-bogofilter-arguments-alist): diff --git a/elmo/elsp-bogofilter.el b/elmo/elsp-bogofilter.el index 6cda961..41adb35 100644 --- a/elmo/elsp-bogofilter.el +++ b/elmo/elsp-bogofilter.el @@ -52,6 +52,11 @@ (const :tag "Use the default")) :group 'elmo-spam-bogofilter) +(defcustom elmo-spam-bogofilter-max-messages-per-process 30 + "Number of messages processed at one once" + :type 'integer + :group 'elmo-spam-bogofilter) + (defcustom elmo-spam-bogofilter-arguments-alist '((classify (if elmo-spam-bogofilter-debug "-vv") @@ -118,6 +123,43 @@ Must be return a string or list of string." buffer &optional restore) (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))))) + +(luna-define-method elmo-spam-register-spam-messages :around + ((processor elsp-bogofilter) folder &optional numbers restore) + (let ((numbers (or numbers (elmo-folder-list-messages folder t t)))) + (if (> (length numbers) 1) + (elmo-spam-bogofilter-register-messages folder numbers t restore) + (luna-call-next-method)))) + +(luna-define-method elmo-spam-register-good-messages :around + ((processor elsp-bogofilter) folder &optional numbers restore) + (let ((numbers (or numbers (elmo-folder-list-messages folder t t)))) + (if (> (length numbers) 1) + (elmo-spam-bogofilter-register-messages folder numbers nil restore) + (luna-call-next-method)))) + (require 'product) (product-provide (provide 'elsp-bogofilter) (require 'elmo-version))