From 3fc6df63d5abe271c65d895a429f29aa8167eabc Mon Sep 17 00:00:00 2001 From: hmurata Date: Sun, 25 Jan 2004 10:16:03 +0000 Subject: [PATCH] (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. --- elmo/ChangeLog | 8 ++++++++ elmo/elsp-bogofilter.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) 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)) -- 1.7.10.4