Subject: bug#78957: 31.0.50; Wrong mode-line in fancy diary

From: Eli Zaretskii <[email-masked]>
Date: Thu, 10 Jul 2025 18:23:47 +0300

> From: Manuel Giraud <[email-masked]>
> Cc: martin rudalics <[email-masked]>,  [email-masked],
>   [email-masked]
> Date: Thu, 10 Jul 2025 17:10:56 +0200
> 
> > Is this a regression in a recent Emacs version?  If yes, which
> > version?
> 
> Hard to tell but it seems it already has been an issue before:
> 
> --8<---------------cut here---------------start------------->8---
> commit 4cbd0713000c5f0a184e16df3556e8408ea3b894
> Author: Mark Oteiza <[email-masked]>
> Date:   Sat Oct 10 22:23:59 2015 -0400
> 
>     * lisp/calendar/calendar.el: Display buffer before executing body.
>     
>     In each use of this macro, the modeline is derived from a window width
>     calculation, which will be wrong if (display-buffer) splits the window
>     horizontally.
> --8<---------------cut here---------------end--------------->8---
> 
> But at the same time, `calendar-set-mode-line' has not been modified
> since 2012.
> 
> So maybe, once upon a time, `display-buffer' meant "make this buffer the
> selected window" and this is not the case anymore.

No, display-buffer never selected the window.  Its doc string always
said that.

> > If this isn't a regression, then please make the patch 110% safe if
> > you want it to go to the release branch.  E.g., what if
> > get-buffer-window returns nil?
> >
> > Martin, any comments to the patch, with emphasis on its safety?
> 
> I'll try and report about Martin's proposal.

Thanks.