Mercurial > emacs
changeset 53598:c66875fbc45d
(rmail-get-new-mail): New local rsf-number-of-spam.
Call rmail-spam-filter. Delete and expunge spam.
Print number of spam messages deleted.
Save and restore the deletion status of old messages when reading
new mail with spam filter, so that expunging spam does not expunge
msgs deleted by the user.
(rmail-only-expunge): added an optional argument dont-show to
prevent showing message after expunge.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 16 Jan 2004 18:23:37 +0000 |
parents | c2d405bc6059 |
children | aa04e56e2a40 |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 59 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Fri Jan 16 18:20:00 2004 +0000 +++ b/lisp/mail/rmail.el Fri Jan 16 18:23:37 2004 +0000 @@ -1364,6 +1364,7 @@ (while all-files (let ((opoint (point)) (new-messages 0) + (rsf-number-of-spam 0) (delete-files ()) ;; If buffer has not changed yet, and has not been saved yet, ;; don't replace the old backup file now. @@ -1446,11 +1447,59 @@ (progn (goto-char opoint) (if (or file-name rmail-inbox-list) (message "(No new mail has arrived)"))) - (if (rmail-summary-exists) + ;; check new messages to see if any of them is spam: + (if rmail-use-spam-filter + (let* + ((old-messages (- rmail-total-messages new-messages)) + (rsf-scanned-message-number (1+ old-messages)) + ;; save deletion flags of old messages: vector starts + ;; at zero (is one longer that no of messages), + ;; therefore take 1+ old-messages + (save-deleted + (substring rmail-deleted-vector 0 (1+ + old-messages)))) + ;; set all messages to undeleted + (setq rmail-deleted-vector + (make-string (1+ rmail-total-messages) ?\ )) + (while (<= rsf-scanned-message-number + rmail-total-messages) + (progn + (if (not (rmail-spam-filter rsf-scanned-message-number)) + (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam))) + ) + (setq rsf-scanned-message-number (1+ rsf-scanned-message-number)) + )) + (if (> rsf-number-of-spam 0) + (progn + (when (rmail-expunge-confirmed) + (rmail-only-expunge t)) + )) + (setq rmail-deleted-vector + (concat + save-deleted + (make-string (- rmail-total-messages old-messages) + ?\ ))) + )) + (if (rmail-summary-exists) (rmail-select-summary (rmail-update-summary))) - (message "%d new message%s read" - new-messages (if (= 1 new-messages) "" "s")) + (message "%d new message%s read%s" + new-messages (if (= 1 new-messages) "" "s") + ;; print out a message on number of spam messages found: + (if (and rmail-use-spam-filter (> rsf-number-of-spam 0)) + (if (= 1 new-messages) + (format ", and found to be a spam message" + rsf-number-of-spam) + (if (> rsf-number-of-spam 1) + (format ", %d of which found to be spam messages" + rsf-number-of-spam) + (format ", one of which found to be a spam message" + rsf-number-of-spam))) + "")) + (if (and rmail-use-spam-filter (> rsf-number-of-spam 0)) + (progn (if rmail-spam-filter-beep (beep t)) + (sleep-for rmail-spam-sleep-after-message))) + ;; Move to the first new message ;; unless we have other unseen messages before it. (rmail-show-message (rmail-first-unseen-message)) @@ -2999,7 +3048,7 @@ (funcall rmail-confirm-expunge "Erase deleted messages from Rmail file? "))) -(defun rmail-only-expunge () +(defun rmail-only-expunge (&optional dont-show) "Actually erase all deleted messages in the file." (interactive) (set-buffer rmail-buffer) @@ -3078,11 +3127,12 @@ (message "Expunging deleted messages...done") (if (not win) (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax))) - (rmail-show-message - (if (zerop rmail-current-message) 1 nil)) - (if rmail-enable-mime - (goto-char (+ (point-min) opoint)) - (goto-char (+ (point) opoint)))))) + (if (not dont-show) + (rmail-show-message + (if (zerop rmail-current-message) 1 nil) + (if rmail-enable-mime + (goto-char (+ (point-min) opoint)) + (goto-char (+ (point) opoint)))))))) (defun rmail-expunge () "Erase deleted messages from Rmail file and summary buffer."