# HG changeset patch # User Glenn Morris # Date 1235014198 0 # Node ID 4df6195e1d5ee3daf533dc2b6bc230c321a3d9a8 # Parent 66d7dedd5eaf9e5746c9d9550a1f6986875ec776 (rmail-get-new-mail-filter-spam): Move here from rmail.el. diff -r 66d7dedd5eaf -r 4df6195e1d5e lisp/mail/rmail-spam-filter.el --- a/lisp/mail/rmail-spam-filter.el Thu Feb 19 03:25:46 2009 +0000 +++ b/lisp/mail/rmail-spam-filter.el Thu Feb 19 03:29:58 2009 +0000 @@ -351,6 +351,30 @@ (setq return-value t))) return-value)) +(defun rmail-get-new-mail-filter-spam (nnew) + "Check the most NNEW recent messages for spam." + (let* ((nold (- rmail-total-messages nnew)) + (nspam 0) + (nscan (1+ nold))) + (while (<= nscan rmail-total-messages) + (or (rmail-spam-filter nscan) + (setq nspam (1+ nspam))) + (setq nscan (1+ nscan))) + (when (> nspam 0) + ;; Otherwise the expunge prompt leaves the raw mbox buffer showing. + (rmail-show-message (rmail-first-unseen-message) 1) + (if (rmail-expunge-confirmed) (rmail-only-expunge t)) + ;; Swap back, else get-new-mail-1 gets confused. + (rmail-swap-buffers-maybe) + (widen)) + ;; Return a message based on the number of spam messages found. + (cond + ((zerop nspam) "") + ((= 1 nnew) ", and it appears to be spam") + ((= nspam nnew) ", and all appear to be spam") + (t (format ", and %d appear%s to be spam" nspam + (if (= 1 nspam) "s" "")))))) + ;; define functions for interactively adding sender/subject of a ;; specific message to the spam definitions while reading it, using ;; the menubar: