Subject: bug#9831: narrowing the bug down

From: Mark Lillibridge <[email-masked]>
Date: Sat, 22 Oct 2011 13:45:05 -0700

Some further tracking reveals:

    The problem is in rmail-update-summary; rmail-update-summary calls
(indirectly) rmail-summary in the normal unfiltered summary case:

(defun rmail-update-summary (&rest ignore)
  (apply (car rmail-summary-redo) (cdr rmail-summary-redo)))

(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)))

Commenting out the last two lines of the above makes the bug go away (at
least for unfiltered summaries):

(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)))

A bit further tracking shows that the last call is the culprit:

(defun rmail-summary-beginning-of-message ()
  "Show current message from the beginning."
  (interactive)
  (rmail-summary-show-message 'BEG))

(defun rmail-summary-show-message (where)
  "Show current mail message.
Position it according to WHERE which can be BEG or END"
  (if (and (one-window-p) (not pop-up-frames))
      ;; If there is just one window, put the summary on the top.
      (let ((buffer rmail-buffer))
	(split-window (selected-window) rmail-summary-window-size)
	(select-window (frame-first-window))
	(rmail-pop-to-buffer rmail-buffer)
	;; If pop-to-buffer did not use that window, delete that
	;; window.  (This can happen if it uses another frame.)
	(or (eq buffer (window-buffer (next-window (frame-first-window))))
	    (delete-other-windows)))
    (rmail-pop-to-buffer rmail-buffer))
  (cond
   ((eq where 'BEG)
	(goto-char (point-min))
	(search-forward "\n\n"))
   ((eq where 'END)
	(goto-char (point-max))
	(recenter (1- (window-height))))
   )
  (rmail-pop-to-buffer rmail-summary-buffer))

    I'm not sure how to go about fixing this; extra dynamically-bound
variable that stops rmail-update-summary called functions from
displaying the summary in a window?

- Mark