From: hmurata Date: Sun, 2 Nov 2003 16:14:37 +0000 (+0000) Subject: * wl-spam.el (wl-spam-domain): Renamed from X-Git-Tag: wl-2_11_21~33 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=a92395308e5d13f611456b8df3c611a882b04a52;p=elisp%2Fwanderlust.git * wl-spam.el (wl-spam-domain): Renamed from `wl-spam-folder-guess-domain'. (wl-summary-exec-action-spam): Register as spam if domain of the source folder is good. (wl-summary-exec-action-refile-with-register): Register message if domain of the source folder is not undecided. * elsp-spamfilter.el (elsp-spamfilter-decode-buffer): Renamed from `elmo-spam-spamfilter-decode-buffer'. (elsp-spamfilter-register-buffer-internal): New internal function. (elmo-spam-buffer-spam-p): Use it; Follow the API change. (elmo-spam-register-spam-buffer): Ditto. (elmo-spam-register-good-buffer): Ditto. * elsp-bogofilter.el (elmo-spam-buffer-spam-p): Follow the API change. (elmo-spam-bogofilter-register-buffer): Added argument `restore'. (elmo-spam-register-spam-buffer): Follow the API change. (elmo-spam-register-good-buffer): Ditto. * elmo-split.el (toplevel): Require elmo-spam when copmile. (elmo-split-spam-p): Added argument plist; Call `elmo-spam-buffer-spam-p' with new argument register. * elmo-spam.el (elmo-spam-buffer-spam-p): Added optional argument `register'. (elmo-spam-message-spam-p): Ditto. (elmo-spam-register-spam-buffer): Added optional argument `restore'. (elmo-spam-register-good-buffer): Ditto. (elmo-spam-register-spam-messages): Ditto. (elmo-spam-register-good-messages): Ditto. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 3661c95..8831571 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,31 @@ +2003-11-02 Hiroya Murata + + * elsp-spamfilter.el (elsp-spamfilter-decode-buffer): Renamed from + `elmo-spam-spamfilter-decode-buffer'. + (elsp-spamfilter-register-buffer-internal): New internal function. + (elmo-spam-buffer-spam-p): Use it; Follow the API change. + (elmo-spam-register-spam-buffer): Ditto. + (elmo-spam-register-good-buffer): Ditto. + + * elsp-bogofilter.el (elmo-spam-buffer-spam-p): Follow the API + change. + (elmo-spam-bogofilter-register-buffer): Added argument `restore'. + (elmo-spam-register-spam-buffer): Follow the API change. + (elmo-spam-register-good-buffer): Ditto. + + * elmo-split.el (toplevel): Require elmo-spam when copmile. + (elmo-split-spam-p): Added argument plist; Call + `elmo-spam-buffer-spam-p' with new argument register. + + * elmo-spam.el (elmo-spam-buffer-spam-p): Added optional argument + `register'. + (elmo-spam-message-spam-p): Ditto. + (elmo-spam-register-spam-buffer): Added optional argument + `restore'. + (elmo-spam-register-good-buffer): Ditto. + (elmo-spam-register-spam-messages): Ditto. + (elmo-spam-register-good-messages): Ditto. + 2003-10-27 Hiroya Murata * elsp-spamfilter.el (elmo-spam-register-spam-buffer): Fixed to diff --git a/elmo/elmo-spam.el b/elmo/elmo-spam.el index a3cd841..febf103 100644 --- a/elmo/elmo-spam.el +++ b/elmo/elmo-spam.el @@ -51,28 +51,40 @@ (luna-define-class elsp-generic ())) ;; required method -(luna-define-generic elmo-spam-buffer-spam-p (processor buffer) +(luna-define-generic elmo-spam-buffer-spam-p (processor buffer + &optional register) "Return non-nil if contents of BUFFER is spam. -PROCESSOR is spam processor structure.") +PROCESSOR is spam processor structure. +If optional augument REGISTER is non-nil, +register according to the classification.") -(luna-define-generic elmo-spam-register-spam-buffer (processor buffer) +(luna-define-generic elmo-spam-register-spam-buffer (processor + buffer + &optional restore) "Register contents of BUFFER as spam. -PROCESSOR is spam processor structure.") +PROCESSOR is spam processor structure. +If optional argument RESTORE is non-nil, unregister from non-spam list.") -(luna-define-generic elmo-spam-register-good-buffer (processor buffer) - "Register contents of BUFFER as non spam. -PROCESSOR is spam processor structure.") +(luna-define-generic elmo-spam-register-good-buffer (processor + buffer + &optional restore) + "Register contents of BUFFER as non-spam. +PROCESSOR is spam processor structure. +If optional argument RESTORE is non-nil, unregister from spam list.") +;; optional method (luna-define-generic elmo-spam-modified-p (processor) "Return non-nil if status of PROCESSOR is modified.") (luna-define-generic elmo-spam-save-status (processor) "Save status of the PROCESSOR.") -;; optional method -(luna-define-generic elmo-spam-message-spam-p (processor folder number) +(luna-define-generic elmo-spam-message-spam-p (processor folder number + &optional register) "Return non-nil if the message in the FOLDER with NUMBER is spam. -PROCESSOR is spam processor structure.") +PROCESSOR is spam processor structure. +If optional augument REGISTER is non-nil, +register according to the classification.") (luna-define-generic elmo-spam-list-spam-messages (processor folder &optional numbers) @@ -84,21 +96,25 @@ messages are searched from the list.") (luna-define-generic elmo-spam-register-spam-messages (processor folder - &optional numbers) + &optional + numbers restore) "Register contents of messages as spam. PROCESSOR is spam processor structure. FOLDER is the ELMO folder structure. If optional argument NUMBERS is specified and is a list of message numbers, -messages are searched from the list.") +messages are searched from the list. +If optional argument RESTORE is non-nil, unregister from non-spam list.") (luna-define-generic elmo-spam-register-good-messages (processor folder - &optional numbers) + &optional + numbers restore) "Register contents of messages as non spam. PROCESSOR is spam processor structure. FOLDER is the ELMO folder structure. If optional argument NUMBERS is specified and is a list of message numbers, -messages are searched from the list.") +messages are searched from the list. +If optional argument RESTORE is non-nil, unregister from spam list.") ;; for internal use (defun elmo-spam-message-fetch (folder number) @@ -111,10 +127,10 @@ messages are searched from the list.") ;; generic implement (luna-define-method elmo-spam-message-spam-p ((processor elsp-generic) - folder number) + folder number &optional register) (with-temp-buffer (elmo-spam-message-fetch folder number) - (elmo-spam-buffer-spam-p processor (current-buffer)))) + (elmo-spam-buffer-spam-p processor (current-buffer) register))) (luna-define-method elmo-spam-list-spam-messages ((processor elsp-generic) folder &optional numbers) @@ -127,25 +143,29 @@ messages are searched from the list.") (nreverse spam-list))) (luna-define-method elmo-spam-register-spam-messages ((processor elsp-generic) - folder &optional numbers) + folder + &optional + numbers restore) (let ((numbers (or numbers (elmo-folder-list-messages folder t t)))) (with-temp-buffer (buffer-disable-undo (current-buffer)) (dolist (number numbers) (erase-buffer) (elmo-spam-message-fetch folder number) - (elmo-spam-register-spam-buffer processor (current-buffer)) + (elmo-spam-register-spam-buffer processor (current-buffer) restore) (elmo-progress-notify 'elmo-spam-register))))) (luna-define-method elmo-spam-register-good-messages ((processor elsp-generic) - folder &optional numbers) + folder + &optional + numbers restore) (let ((numbers (or numbers (elmo-folder-list-messages folder t t)))) (with-temp-buffer (buffer-disable-undo (current-buffer)) (dolist (number numbers) (erase-buffer) (elmo-spam-message-fetch folder number) - (elmo-spam-register-good-buffer processor (current-buffer)) + (elmo-spam-register-good-buffer processor (current-buffer) restore) (elmo-progress-notify 'elmo-spam-register))))) (provide 'elsp-generic) diff --git a/elmo/elmo-split.el b/elmo/elmo-split.el index e7c53fb..500d61d 100644 --- a/elmo/elmo-split.el +++ b/elmo/elmo-split.el @@ -42,8 +42,7 @@ (eval-when-compile ;; Avoid compile warnings - (defun-maybe elmo-spam-processor ()) - (defun-maybe elmo-spam-buffer-spam-p (processor buffer))) + (require 'elmo-spam)) (defcustom elmo-split-rule nil "Split rule for the command `elmo-split'. @@ -220,9 +219,11 @@ It can be some ACTION as in `elmo-split-rule'." (symbol-name field))))) (equal field-value value)))) -(defun elmo-split-spam-p (buffer) +(defun elmo-split-spam-p (buffer &rest plist) (require 'elmo-spam) - (elmo-spam-buffer-spam-p (elmo-spam-processor) buffer)) + (elmo-spam-buffer-spam-p (elmo-spam-processor) + buffer + (plist-get plist :register))) (defun elmo-split-match (buffer field value) (with-current-buffer buffer diff --git a/elmo/elsp-bogofilter.el b/elmo/elsp-bogofilter.el index e3b161f..05a71e5 100644 --- a/elmo/elsp-bogofilter.el +++ b/elmo/elsp-bogofilter.el @@ -74,8 +74,9 @@ (luna-define-class elsp-bogofilter (elsp-generic))) (luna-define-method elmo-spam-buffer-spam-p ((processor elsp-bogofilter) - buffer) + buffer &optional register) (let ((args `("-v" "-2" + ,@(if register (list "-u")) ,@(if elmo-spam-bogofilter-database-directory (list "-d" elmo-spam-bogofilter-database-directory))))) (with-current-buffer buffer @@ -84,11 +85,12 @@ elmo-spam-bogofilter-program nil nil nil args))))) -(defsubst elmo-spam-bogofilter-register-buffer (buffer spam) +(defsubst elmo-spam-bogofilter-register-buffer (buffer spam restore) (let ((args `("-v" ,(if spam elmo-spam-bogofilter-spam-switch elmo-spam-bogofilter-good-switch) + ,@(if restore (list (if spam "-N" "-S"))) ,@(if elmo-spam-bogofilter-database-directory (list "-d" elmo-spam-bogofilter-database-directory))))) (with-current-buffer buffer @@ -98,12 +100,12 @@ nil nil nil args)))) (luna-define-method elmo-spam-register-spam-buffer ((processor elsp-bogofilter) - buffer) - (elmo-spam-bogofilter-register-buffer buffer t)) + buffer &optional restore) + (elmo-spam-bogofilter-register-buffer buffer t restore)) (luna-define-method elmo-spam-register-good-buffer ((processor elsp-bogofilter) - buffer) - (elmo-spam-bogofilter-register-buffer buffer nil)) + buffer &optional restore) + (elmo-spam-bogofilter-register-buffer buffer nil restore)) (require 'product) (product-provide (provide 'elsp-bogofilter) (require 'elmo-version)) diff --git a/elmo/elsp-spamfilter.el b/elmo/elsp-spamfilter.el index 0615506..f5a7cd6 100644 --- a/elmo/elsp-spamfilter.el +++ b/elmo/elsp-spamfilter.el @@ -76,37 +76,42 @@ (elsp-spamfilter-bad-corpus-internal processor)) (elsp-spamfilter-set-modified-internal processor nil)) -(defun elmo-spam-spamfilter-decode-buffer (buffer) +(defun elsp-spamfilter-decode-buffer (buffer) (mime-display-message (mime-open-entity 'elmo-buffer buffer) (current-buffer))) +(defsubst elsp-spamfilter-register-buffer-internal (processor buffer spam) + (spamf-register-words-buffer + (if spam + (elsp-spamfilter-bad-corpus-internal processor) + (elsp-spamfilter-good-corpus-internal processor)) + buffer) + (elsp-spamfilter-set-modified-internal processor t)) + (luna-define-method elmo-spam-buffer-spam-p ((processor elsp-spamfilter) - buffer) + buffer &optional register) (with-temp-buffer - (elmo-spam-spamfilter-decode-buffer buffer) - (spamf-spam-buffer-p - (current-buffer) - (elsp-spamfilter-good-corpus-internal processor) - (elsp-spamfilter-bad-corpus-internal processor)))) + (elsp-spamfilter-decode-buffer buffer) + (let ((spam (spamf-spam-buffer-p + (current-buffer) + (elsp-spamfilter-good-corpus-internal processor) + (elsp-spamfilter-bad-corpus-internal processor)))) + (when register + (elsp-spamfilter-register-buffer-internal processor buffer spam)) + spam))) (luna-define-method elmo-spam-register-spam-buffer ((processor elsp-spamfilter) - buffer) + buffer &optional restore) (with-temp-buffer - (elmo-spam-spamfilter-decode-buffer buffer) - (spamf-register-spam-buffer - (current-buffer) - (elsp-spamfilter-bad-corpus-internal processor)) - (elsp-spamfilter-set-modified-internal processor t))) + (elsp-spamfilter-decode-buffer buffer) + (elsp-spamfilter-register-buffer-internal processor buffer t))) (luna-define-method elmo-spam-register-good-buffer ((processor elsp-spamfilter) - buffer) + buffer &optional restore) (with-temp-buffer - (elmo-spam-spamfilter-decode-buffer buffer) - (spamf-register-good-buffer - (current-buffer) - (elsp-spamfilter-good-corpus-internal processor)) - (elsp-spamfilter-set-modified-internal processor t))) + (elsp-spamfilter-decode-buffer buffer) + (elsp-spamfilter-register-buffer-internal processor buffer nil))) (require 'product) (product-provide (provide 'elsp-spamfilter) (require 'elmo-version)) diff --git a/wl/ChangeLog b/wl/ChangeLog index 7d2ce03..7c7e1ff 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,12 @@ +2003-11-02 Hiroya Murata + + * wl-spam.el (wl-spam-domain): Renamed from + `wl-spam-folder-guess-domain'. + (wl-summary-exec-action-spam): Register as spam if domain of the + source folder is good. + (wl-summary-exec-action-refile-with-register): Register message if + domain of the source folder is not undecided. + 2003-10-31 Hiroya Murata * wl-summary.el (wl-summary-insert-thread): Fixed the logic to diff --git a/wl/wl-spam.el b/wl/wl-spam.el index 0b47a2d..31cc3b0 100644 --- a/wl/wl-spam.el +++ b/wl/wl-spam.el @@ -101,7 +101,7 @@ See `wl-summary-mark-action-list' for the detail of element." (string :tag "Document string")) :group 'wl-spam) -(defun wl-spam-folder-guess-domain (folder-name) +(defun wl-spam-domain (folder-name) (cond ((string= folder-name wl-spam-folder-name) 'spam) ((wl-string-match-member folder-name @@ -257,43 +257,49 @@ See `wl-summary-mark-action-list' for the detail of element." (wl-summary-mark-spam))) (defun wl-summary-exec-action-spam (mark-list) - (let ((folder wl-summary-buffer-elmo-folder) + (let ((domain (wl-spam-domain (elmo-folder-name-internal + wl-summary-buffer-elmo-folder))) (total (length mark-list))) - (when (eq (wl-spam-folder-guess-domain (elmo-folder-name-internal folder)) - 'undecided) + (when (memq domain '(undecided good)) (message "Registering spam...") (elmo-with-progress-display (> total elmo-display-progress-threshold) (elmo-spam-register total "Registering spam...") (elmo-spam-register-spam-messages (elmo-spam-processor) - folder - (mapcar #'car mark-list))) + wl-summary-buffer-elmo-folder + (mapcar #'car mark-list) + (eq domain 'good))) (message "Registering spam...done")) (wl-summary-move-mark-list-messages mark-list wl-spam-folder-name "Refiling spam..."))) (defun wl-summary-exec-action-refile-with-register (mark-list) - (let ((processor (elmo-spam-processor)) - (folder wl-summary-buffer-elmo-folder) - spam-list good-list total) - (when (eq (wl-spam-folder-guess-domain - (elmo-folder-name-internal folder)) - 'undecided) - (message "Registering spam...") + (let* ((processor (elmo-spam-processor)) + (folder wl-summary-buffer-elmo-folder) + (domain (wl-spam-domain (elmo-folder-name-internal folder))) + spam-list good-list total) + (unless (eq domain 'ignore) (dolist (info mark-list) - (case (wl-spam-folder-guess-domain (nth 2 info)) + (case (wl-spam-domain (nth 2 info)) (spam (setq spam-list (cons (car info) spam-list))) (good (setq good-list (cons (car info) good-list))))) - (setq total (+ (length spam-list) (length good-list))) - (elmo-with-progress-display (> total elmo-display-progress-threshold) - (elmo-spam-register total "Registering spam...") - (when spam-list - (elmo-spam-register-spam-messages processor folder spam-list)) - (when good-list - (elmo-spam-register-good-messages processor folder good-list))) - (message "Registering spam...done")) + (case domain + (spam (setq spam-list nil)) + (good (setq good-list nil))) + (when (or spam-list good-list) + (message "Registering spam...") + (setq total (+ (length spam-list) (length good-list))) + (elmo-with-progress-display (> total elmo-display-progress-threshold) + (elmo-spam-register total "Registering spam...") + (when spam-list + (elmo-spam-register-spam-messages processor folder spam-list + (eq domain 'good))) + (when good-list + (elmo-spam-register-good-messages processor folder good-list + (eq domain 'spam)))) + (message "Registering spam...done"))) ;; execute refile messages (wl-summary-exec-action-refile mark-list)))