Subject: Re: bug#13066: 24.2.90; setting rmail-summary-window-size causes error

From: Glenn Morris <[email-masked]>
Date: Thu, 06 Dec 2012 15:55:07 -0500

Kenichi Handa wrote:

> % emacs -Q
> M-x rmail RET
> M-x customize-variable RET rmail-summary-window-size
> ;; Then set it to 10, click [apply], type q, then type h,
> ;; and then type g (rmail-summary-get-new-mail).
>
> This causes the same error.  The backtrace is this:
>
> Debugger entered--Lisp error: (wrong-type-argument numberp nil)
>   zerop(nil)
>   (or (zerop msg) (rmail-summary-goto-msg msg))
>   (let (msg) (save-current-buffer (set-buffer rmail-buffer) (rmail-get-new-mail file-name) (setq msg rmail-current-message)) (or (zerop msg) (rmail-summary-goto-msg msg)))
>   rmail-summary-get-new-mail(nil)
>   call-interactively(rmail-summary-get-new-mail nil nil)

This is also because rmail-maybe-display-summary behaves differently to
how it used to.

When we enter rmail-maybe-display-summary:
  current-buffer = RMAIL
  selected-window = RMAIL summary

When we get to the end of this function:

(unwind-protect
    (progn
      ;; current-buffer = RMAIL
      (select-window window)  ; -> RMAIL summary
      ;; In 24.2, RMAIL buffer still current.
      ;; In 24.2.90, RMAIL summary buffer is now current.
      (enlarge-window (- rmail-summary-window-size (window-height))))
  (select-window selected)))))

I think we could summarize the difference between 24.2 and 24.2.90
by using emacs -Q, then evaluating the following in scratch:

(progn
 (message "1 : %s : %s" (current-buffer) (selected-window))
 (set-buffer "*Messages*")
 (message "2 : %s : %s" (current-buffer) (setq window
 (selected-window)))
 (select-window window)
 (message "3 : %s : %s" (current-buffer) (setq window (selected-window))))

With 24.2, the result is:

1 : *scratch* : #<window 3 on *scratch*>
2 : *Messages* : #<window 3 on *scratch*>
3 : *Messages* : #<window 3 on *scratch*>

With 24.2.90, it is:

1 : *scratch* : #<window 3 on *scratch*>
2 : *Messages* : #<window 3 on *scratch*>
3 : *scratch* : #<window 3 on *scratch*>