X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=wl%2Fwl-spam.el;h=ad1febc8b7ab5dc680ab399ec7d8d3655b0bae7f;hb=62345218eb5ad2b29ace6731bbddf1d3fe787c3c;hp=f397b79fdb9cdc6431c29c9e0e75e7fee7081a30;hpb=9768a600b150508da55d770f4290d7230d2723be;p=elisp%2Fwanderlust.git diff --git a/wl/wl-spam.el b/wl/wl-spam.el index f397b79..ad1febc 100644 --- a/wl/wl-spam.el +++ b/wl/wl-spam.el @@ -41,7 +41,7 @@ "Spam configuration for wanderlust." :group 'wl) -(defcustom wl-spam-folder-name "+spam" +(defcustom wl-spam-folder "+spam" "*Spam folder." :type 'string :group 'wl-spam) @@ -59,7 +59,7 @@ :type '(repeat (regexp :tag "Folder Regexp")) :group 'wl-spam) -(defcustom wl-spam-auto-check-folder-regexp-list '("[+.]inbox") +(defcustom wl-spam-auto-check-folder-regexp-list nil "*List of Folder regexp which check spam automatically." :type '(repeat (regexp :tag "Folder Regexp")) :group 'wl-spam) @@ -103,7 +103,7 @@ See `wl-summary-mark-action-list' for the detail of element." :group 'wl-spam) (defun wl-spam-domain (folder-name) - (cond ((string= folder-name wl-spam-folder-name) + (cond ((string= folder-name wl-spam-folder) 'spam) ((wl-string-match-member folder-name wl-spam-undecided-folder-regexp-list) @@ -152,8 +152,9 @@ See `wl-summary-mark-action-list' for the detail of element." (defun wl-spam-save-status (&optional force) (interactive "P") - (let ((processor (elmo-spam-processor))) - (when (or force (elmo-spam-modified-p processor)) + (let ((processor (elmo-spam-processor (not force)))) + (when (or force + (and processor (elmo-spam-modified-p processor))) (elmo-spam-save-status processor)))) ;; insinuate into summary mode @@ -262,6 +263,7 @@ See `wl-summary-mark-action-list' for the detail of element." (let ((domain (wl-spam-domain (elmo-folder-name-internal wl-summary-buffer-elmo-folder))) (total (length mark-list))) + (wl-folder-confirm-existence (elmo-make-folder wl-spam-folder)) (when (memq domain '(undecided good)) (message "Registering spam...") (elmo-with-progress-display (> total elmo-display-progress-threshold) @@ -272,7 +274,7 @@ See `wl-summary-mark-action-list' for the detail of element." (eq domain 'good))) (message "Registering spam...done")) (wl-summary-move-mark-list-messages mark-list - wl-spam-folder-name + wl-spam-folder "Refiling spam..."))) (defun wl-summary-exec-action-refile-with-register (mark-list) @@ -291,17 +293,22 @@ See `wl-summary-mark-action-list' for the detail of element." (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 + (when spam-list + (setq total (length spam-list)) + (message "Registering spam...") + (elmo-with-progress-display (> total elmo-display-progress-threshold) + (elmo-spam-register total "Registering spam...") (elmo-spam-register-spam-messages processor folder spam-list (eq domain 'good))) - (when good-list + (message "Registering spam...done")) + (when good-list + (setq total (length good-list)) + (message "Registering good...") + (elmo-with-progress-display (> total elmo-display-progress-threshold) + (elmo-spam-register total "Registering good...") (elmo-spam-register-good-messages processor folder good-list - (eq domain 'spam)))) - (message "Registering spam...done"))) + (eq domain 'spam))) + (message "Registering good...done")))) ;; execute refile messages (wl-summary-exec-action-refile mark-list))) @@ -310,20 +317,28 @@ See `wl-summary-mark-action-list' for the detail of element." (number wl-message-buffer-cur-number) spam) (message "Cheking spam...") - (when (elmo-spam-buffer-spam-p (elmo-spam-processor) original) + (when (setq spam (elmo-spam-buffer-spam-p (elmo-spam-processor) original)) (with-current-buffer wl-message-buffer-cur-summary-buffer (wl-summary-spam number))) (message "Cheking spam...done") - (when (interactive-p) - (message "No: %d is %sa spam message." number (if spam "" "not "))))) + (message "No: %d is %sa spam message." number (if spam "" "not ")))) (defun wl-refile-guess-by-spam (entity) (when (elmo-spam-message-spam-p (elmo-spam-processor) wl-summary-buffer-elmo-folder (elmo-message-entity-number entity)) - wl-spam-folder-name)) + wl-spam-folder)) (defun wl-spam-setup () + (add-hook 'wl-summary-prepared-hook #'wl-summary-auto-check-spam) + (let ((actions wl-summary-mark-action-list) + action) + (while actions + (setq action (car actions) + actions (cdr actions)) + (when (eq (wl-summary-action-symbol action) 'refile) + (setcar (nthcdr 4 action) 'wl-summary-exec-action-refile-with-register) + (setq actions nil)))) (when wl-spam-mark-action-list (setq wl-summary-mark-action-list (append wl-summary-mark-action-list @@ -336,8 +351,12 @@ See `wl-summary-mark-action-list' for the detail of element." (cons (wl-summary-action-mark action) wl-summary-skip-mark-list)))) (define-key wl-summary-mode-map "k" wl-summary-spam-map) - (define-key wl-summary-mode-map "ms" 'wl-summary-target-mark-register-as-spam) - (define-key wl-summary-mode-map "mn" 'wl-summary-target-mark-register-as-good)) + (define-key + wl-summary-mode-map "mk" 'wl-summary-target-mark-spam) + (define-key + wl-summary-mode-map "ms" 'wl-summary-target-mark-register-as-spam) + (define-key + wl-summary-mode-map "mn" 'wl-summary-target-mark-register-as-good)) (require 'product) (product-provide (provide 'wl-spam) (require 'wl-version))