aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-01-16 18:23:37 +0000
committerRichard M. Stallman2004-01-16 18:23:37 +0000
commita53692379f6caed5e6d1686a1933914751dd64fe (patch)
tree154599470b2b56869256b908f10d356505e51a51
parent7a21fef9ecbd83d96b9f1410488915ff804bc943 (diff)
downloademacs-a53692379f6caed5e6d1686a1933914751dd64fe.tar.gz
emacs-a53692379f6caed5e6d1686a1933914751dd64fe.zip
(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.
-rw-r--r--lisp/mail/rmail.el68
1 files changed, 59 insertions, 9 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index cc2d595d8a6..f8abc2a910d 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1364,6 +1364,7 @@ It returns t if it got any new messages."
1364 (while all-files 1364 (while all-files
1365 (let ((opoint (point)) 1365 (let ((opoint (point))
1366 (new-messages 0) 1366 (new-messages 0)
1367 (rsf-number-of-spam 0)
1367 (delete-files ()) 1368 (delete-files ())
1368 ;; If buffer has not changed yet, and has not been saved yet, 1369 ;; If buffer has not changed yet, and has not been saved yet,
1369 ;; don't replace the old backup file now. 1370 ;; don't replace the old backup file now.
@@ -1446,11 +1447,59 @@ It returns t if it got any new messages."
1446 (progn (goto-char opoint) 1447 (progn (goto-char opoint)
1447 (if (or file-name rmail-inbox-list) 1448 (if (or file-name rmail-inbox-list)
1448 (message "(No new mail has arrived)"))) 1449 (message "(No new mail has arrived)")))
1449 (if (rmail-summary-exists) 1450 ;; check new messages to see if any of them is spam:
1451 (if rmail-use-spam-filter
1452 (let*
1453 ((old-messages (- rmail-total-messages new-messages))
1454 (rsf-scanned-message-number (1+ old-messages))
1455 ;; save deletion flags of old messages: vector starts
1456 ;; at zero (is one longer that no of messages),
1457 ;; therefore take 1+ old-messages
1458 (save-deleted
1459 (substring rmail-deleted-vector 0 (1+
1460 old-messages))))
1461 ;; set all messages to undeleted
1462 (setq rmail-deleted-vector
1463 (make-string (1+ rmail-total-messages) ?\ ))
1464 (while (<= rsf-scanned-message-number
1465 rmail-total-messages)
1466 (progn
1467 (if (not (rmail-spam-filter rsf-scanned-message-number))
1468 (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam)))
1469 )
1470 (setq rsf-scanned-message-number (1+ rsf-scanned-message-number))
1471 ))
1472 (if (> rsf-number-of-spam 0)
1473 (progn
1474 (when (rmail-expunge-confirmed)
1475 (rmail-only-expunge t))
1476 ))
1477 (setq rmail-deleted-vector
1478 (concat
1479 save-deleted
1480 (make-string (- rmail-total-messages old-messages)
1481 ?\ )))
1482 ))
1483 (if (rmail-summary-exists)
1450 (rmail-select-summary 1484 (rmail-select-summary
1451 (rmail-update-summary))) 1485 (rmail-update-summary)))
1452 (message "%d new message%s read" 1486 (message "%d new message%s read%s"
1453 new-messages (if (= 1 new-messages) "" "s")) 1487 new-messages (if (= 1 new-messages) "" "s")
1488 ;; print out a message on number of spam messages found:
1489 (if (and rmail-use-spam-filter (> rsf-number-of-spam 0))
1490 (if (= 1 new-messages)
1491 (format ", and found to be a spam message"
1492 rsf-number-of-spam)
1493 (if (> rsf-number-of-spam 1)
1494 (format ", %d of which found to be spam messages"
1495 rsf-number-of-spam)
1496 (format ", one of which found to be a spam message"
1497 rsf-number-of-spam)))
1498 ""))
1499 (if (and rmail-use-spam-filter (> rsf-number-of-spam 0))
1500 (progn (if rmail-spam-filter-beep (beep t))
1501 (sleep-for rmail-spam-sleep-after-message)))
1502
1454 ;; Move to the first new message 1503 ;; Move to the first new message
1455 ;; unless we have other unseen messages before it. 1504 ;; unless we have other unseen messages before it.
1456 (rmail-show-message (rmail-first-unseen-message)) 1505 (rmail-show-message (rmail-first-unseen-message))
@@ -2999,7 +3048,7 @@ See also user-option `rmail-confirm-expunge'."
2999 (funcall rmail-confirm-expunge 3048 (funcall rmail-confirm-expunge
3000 "Erase deleted messages from Rmail file? "))) 3049 "Erase deleted messages from Rmail file? ")))
3001 3050
3002(defun rmail-only-expunge () 3051(defun rmail-only-expunge (&optional dont-show)
3003 "Actually erase all deleted messages in the file." 3052 "Actually erase all deleted messages in the file."
3004 (interactive) 3053 (interactive)
3005 (set-buffer rmail-buffer) 3054 (set-buffer rmail-buffer)
@@ -3078,11 +3127,12 @@ See also user-option `rmail-confirm-expunge'."
3078 (message "Expunging deleted messages...done") 3127 (message "Expunging deleted messages...done")
3079 (if (not win) 3128 (if (not win)
3080 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax))) 3129 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
3081 (rmail-show-message 3130 (if (not dont-show)
3082 (if (zerop rmail-current-message) 1 nil)) 3131 (rmail-show-message
3083 (if rmail-enable-mime 3132 (if (zerop rmail-current-message) 1 nil)
3084 (goto-char (+ (point-min) opoint)) 3133 (if rmail-enable-mime
3085 (goto-char (+ (point) opoint)))))) 3134 (goto-char (+ (point-min) opoint))
3135 (goto-char (+ (point) opoint))))))))
3086 3136
3087(defun rmail-expunge () 3137(defun rmail-expunge ()
3088 "Erase deleted messages from Rmail file and summary buffer." 3138 "Erase deleted messages from Rmail file and summary buffer."