changeset 102605:d95dfcc4b888

(rmail-expunge): Show the message only once, and only if needed. If the current message was current before, just re-swap.
author Richard M. Stallman <rms@gnu.org>
date Mon, 16 Mar 2009 14:04:11 +0000
parents f1d999427056
children 39b162fc29aa
files lisp/mail/rmail.el
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Mon Mar 16 13:42:31 2009 +0000
+++ b/lisp/mail/rmail.el	Mon Mar 16 14:04:11 2009 +0000
@@ -3263,16 +3263,19 @@
   "Erase deleted messages from Rmail file and summary buffer."
   (interactive)
   (when (rmail-expunge-confirmed)
-    (let ((old-total rmail-total-messages)
-	  (opoint (with-current-buffer rmail-buffer
-		    (when (rmail-buffers-swapped-p)
-		      (point)))))
-      (rmail-only-expunge dont-show)
-      (if (rmail-summary-exists)
-	  (rmail-select-summary (rmail-update-summary))
-	(rmail-show-message-1 rmail-current-message)
-	(if (and (eq old-total rmail-total-messages) opoint)
-	    (goto-char opoint))))))
+    (let ((was-deleted (rmail-message-deleted-p rmail-current-message))
+	  (was-swapped (rmail-buffers-swapped-p)))
+      (rmail-only-expunge t)
+      (unless dont-show
+	(if (rmail-summary-exists)
+	    (rmail-select-summary (rmail-update-summary))
+	  ;; If we expunged the current message, a new one is current now,
+	  ;; so show it.  If we weren't showing a message, show it. 
+	  (if (or was-deleted (not was-swapped))
+	      (rmail-show-message-1 rmail-current-message)
+	    ;; Show the same message that was being shown before.
+	    (rmail-swap-buffers)
+	    (setq rmail-buffer-swapped t)))))))
 
 ;;;; *** Rmail Mailing Commands ***