summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremacs-f <emacs-f@media.mit.edu>2020-12-08 18:22:30 -0500
committerEli Zaretskii <eliz@gnu.org>2020-12-26 11:46:11 +0200
commitf9264a3878ba6366aacdf80e3ebba3ba799415a6 (patch)
tree2944e4112b97930a1d3bfc5f9da157682e765274
parentb3c9af9061e09efd94a1f5bd58aed69800da237d (diff)
downloademacs-f9264a3878ba6366aacdf80e3ebba3ba799415a6.tar.gz
Avoid missing email messages due to rmail-spam-filter
* lisp/mail/rmail-spam-filter.el (rsf--rmail-last-seen-message): New function. (rmail-spam-filter, rmail-get-new-mail-filter-spam): Call 'rsf--rmail-last-seen-message' instead of 'rmail-first-unseen-message'. (Bug#45128) Copyright-paperwork-exempt: yes
-rw-r--r--lisp/mail/rmail-spam-filter.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/mail/rmail-spam-filter.el b/lisp/mail/rmail-spam-filter.el
index db518482591..4d8c9267f31 100644
--- a/lisp/mail/rmail-spam-filter.el
+++ b/lisp/mail/rmail-spam-filter.el
@@ -214,6 +214,16 @@ the cdr is set to t. Else, the car is set to nil."
;; rule means this cannot be spam.
(setcar result nil)))))
+;; Don't spuriously advance to the next unseen message while
+;; prompting, because that causes it to then be missed while actually
+;; reading mail afterwards! Call this instead of
+;; rmail-first-unseen-message.
+(defun rsf--rmail-last-seen-message ()
+ (max 1
+ ;; 'rmail-first-unseen-message' can return nil in a completely
+ ;; empty buffer.
+ (1- (or (rmail-first-unseen-message) 1))))
+
(defun rmail-spam-filter (msg)
"Return nil if message number MSG is spam based on `rsf-definitions-alist'.
If spam, optionally output message to a file `rsf-file' and delete
@@ -327,8 +337,7 @@ it from rmail file. Called for each new message retrieved by
(if (and (car maybe-spam) (cdr maybe-spam))
;; Temporarily set rmail-current-message in order to output
;; and delete the spam msg if needed:
- (let ((rmail-current-message msg) ; FIXME does this do anything?
- (action (cdr (assq 'action
+ (let ((action (cdr (assq 'action
(nth num-element rsf-definitions-alist))))
(newfile (not (file-exists-p rsf-file))))
;; Check action item in rsf-definitions-alist and do it.
@@ -337,7 +346,7 @@ it from rmail file. Called for each new message retrieved by
;; Else the prompt to write a new file leaves the raw
;; mbox buffer visible.
(and newfile
- (rmail-show-message (rmail-first-unseen-message) t))
+ (rmail-show-message (rsf--rmail-last-seen-message) t))
(rmail-output rsf-file)
;; Swap back, else rmail-get-new-mail-1 gets confused.
(when newfile
@@ -377,7 +386,7 @@ This is called at the end of `rmail-get-new-mail-1' if there is new mail."
(sleep-for rsf-sleep-after-message))
(when (> nspam 0)
;; Otherwise sleep or expunge prompt leaves raw mbox buffer showing.
- (rmail-show-message (or (rmail-first-unseen-message) 1) t)
+ (rmail-show-message (or (rsf--rmail-last-seen-message) 1) t)
(unwind-protect
(progn
(if rsf-beep (ding t))