aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremacs-f2020-12-08 18:22:30 -0500
committerEli Zaretskii2020-12-26 11:46:11 +0200
commitf9264a3878ba6366aacdf80e3ebba3ba799415a6 (patch)
tree2944e4112b97930a1d3bfc5f9da157682e765274
parentb3c9af9061e09efd94a1f5bd58aed69800da237d (diff)
downloademacs-f9264a3878ba6366aacdf80e3ebba3ba799415a6.tar.gz
emacs-f9264a3878ba6366aacdf80e3ebba3ba799415a6.zip
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."
214 ;; rule means this cannot be spam. 214 ;; rule means this cannot be spam.
215 (setcar result nil))))) 215 (setcar result nil)))))
216 216
217;; Don't spuriously advance to the next unseen message while
218;; prompting, because that causes it to then be missed while actually
219;; reading mail afterwards! Call this instead of
220;; rmail-first-unseen-message.
221(defun rsf--rmail-last-seen-message ()
222 (max 1
223 ;; 'rmail-first-unseen-message' can return nil in a completely
224 ;; empty buffer.
225 (1- (or (rmail-first-unseen-message) 1))))
226
217(defun rmail-spam-filter (msg) 227(defun rmail-spam-filter (msg)
218 "Return nil if message number MSG is spam based on `rsf-definitions-alist'. 228 "Return nil if message number MSG is spam based on `rsf-definitions-alist'.
219If spam, optionally output message to a file `rsf-file' and delete 229If 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
327 (if (and (car maybe-spam) (cdr maybe-spam)) 337 (if (and (car maybe-spam) (cdr maybe-spam))
328 ;; Temporarily set rmail-current-message in order to output 338 ;; Temporarily set rmail-current-message in order to output
329 ;; and delete the spam msg if needed: 339 ;; and delete the spam msg if needed:
330 (let ((rmail-current-message msg) ; FIXME does this do anything? 340 (let ((action (cdr (assq 'action
331 (action (cdr (assq 'action
332 (nth num-element rsf-definitions-alist)))) 341 (nth num-element rsf-definitions-alist))))
333 (newfile (not (file-exists-p rsf-file)))) 342 (newfile (not (file-exists-p rsf-file))))
334 ;; Check action item in rsf-definitions-alist and do it. 343 ;; 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
337 ;; Else the prompt to write a new file leaves the raw 346 ;; Else the prompt to write a new file leaves the raw
338 ;; mbox buffer visible. 347 ;; mbox buffer visible.
339 (and newfile 348 (and newfile
340 (rmail-show-message (rmail-first-unseen-message) t)) 349 (rmail-show-message (rsf--rmail-last-seen-message) t))
341 (rmail-output rsf-file) 350 (rmail-output rsf-file)
342 ;; Swap back, else rmail-get-new-mail-1 gets confused. 351 ;; Swap back, else rmail-get-new-mail-1 gets confused.
343 (when newfile 352 (when newfile
@@ -377,7 +386,7 @@ This is called at the end of `rmail-get-new-mail-1' if there is new mail."
377 (sleep-for rsf-sleep-after-message)) 386 (sleep-for rsf-sleep-after-message))
378 (when (> nspam 0) 387 (when (> nspam 0)
379 ;; Otherwise sleep or expunge prompt leaves raw mbox buffer showing. 388 ;; Otherwise sleep or expunge prompt leaves raw mbox buffer showing.
380 (rmail-show-message (or (rmail-first-unseen-message) 1) t) 389 (rmail-show-message (or (rsf--rmail-last-seen-message) 1) t)
381 (unwind-protect 390 (unwind-protect
382 (progn 391 (progn
383 (if rsf-beep (ding t)) 392 (if rsf-beep (ding t))