"Spam configuration for wanderlust."
:group 'wl)
-(defcustom wl-spam-folder-name "+spam"
+(defcustom wl-spam-folder "+spam"
"*Spam folder."
:type 'string
:group 'wl-spam)
: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)
Append this value to `wl-summary-mark-action-list' by `wl-spam-setup'.
See `wl-summary-mark-action-list' for the detail of element."
- :type '(repeat (string :tag "Temporary mark")
- (symbol :tag "Set mark function")
- (symbol :tag "Unset mark function")
- (symbol :tag "Exec function")
- (symbol :tag "Face symbol")
- (string :tag "Document string"))
+ :type '(repeat (list
+ (string :tag "Temporary mark")
+ (symbol :tag "Action name")
+ (symbol :tag "Argument function")
+ (symbol :tag "Set mark function")
+ (symbol :tag "Exec function")
+ (symbol :tag "Face symbol")
+ (string :tag "Document string")))
: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)
(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
(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)
(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)
(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)))
(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-sync-updated-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
(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))