Subject: cause of bug found! [PATCH]

From: Mark Lillibridge <[email-masked]>
Date: Sat, 22 Oct 2011 14:26:23 -0700

Because this bug doesn't occur in Emacs 22, I compared to that code's
version of rmail-summary:

[Rmail 22]
(defun rmail-summary ()
  "Display a summary of all messages, one line per message."
  (interactive)
  (rmail-new-summary "All" '(rmail-summary) nil))

[Rmail 23.3]
(defun rmail-summary ()
  "Display a summary of all messages, one line per message."
  (interactive)
  (rmail-new-summary "All" '(rmail-summary) nil)
  (unless (get-buffer-window rmail-buffer)
    (rmail-summary-beginning-of-message)))

    As you can see, some well-meaning person added the functionality of
move-to-start-of-message to the display summary command ('h') and broke
rmail-output and associated functions.  I checked and none of the other
summary generating functions (e.g., rmail-summary-by-labels) have this
functionality (added).

    On the assumption that somebody wanted this functionality, here is
one way to patch things:

ts-rhel5 [159]% ( setenv LC_ALL C ; setenv TZ UTC0 ; diff -Naur original-rmailsum.el rmailsum.el ) 
--- original-rmailsum.el        2011-10-22 21:03:14.834090000 +0000
+++ rmailsum.el 2011-10-22 21:22:00.443672000 +0000
@@ -71,16 +71,22 @@
 
 ;; Regenerate the contents of the summary
 ;; using the same selection criterion as last time.
+;; If current buffer is the summary buffer (rather than the Rmail
+;; buffer), then does not make summary displayed if not already
+;; displayed.
 ;; M-x revert-buffer in a summary buffer calls this function.
 (defun rmail-update-summary (&rest ignore)
   (apply (car rmail-summary-redo) (cdr rmail-summary-redo)))
 
 ;;;###autoload
-(defun rmail-summary ()
-  "Display a summary of all messages, one line per message."
+(defun rmail-summary (&rest no-display)
+  "Display a summary of all messages, one line per message.
+
+If no-display is set, updates/creates the summary buffer, but does not
+necessarily display it."
   (interactive)
-  (rmail-new-summary "All" '(rmail-summary) nil)
-  (unless (get-buffer-window rmail-buffer)
+  (rmail-new-summary "All" '(rmail-summary t) nil)
+  (unless (or no-display (get-buffer-window rmail-buffer))
     (rmail-summary-beginning-of-message)))
 
 ;;;###autoload

I believe it is now safe to remove the FIXME from rmailout.el:

    ;; FIXME should re-use existing windows.
    (if (rmail-summary-exists)
	(rmail-select-summary (rmail-update-summary)))

- Mark