Subject: bug#18381: 24.3.93; Diary can wrongly be displayed in Calendar's window

From: Glenn Morris <[email-masked]>
Date: Thu, 04 Sep 2014 14:04:07 -0400

martin rudalics wrote:

> ... is the same window where you first show the calendar here.  As a
> consequence, `display-buffer-in-previous-window' will find a window
> where you have shown `diary' already and reuse that window.  I'm not
> sure what's the best thing to do here - maybe we should remove
> `display-buffer-in-previous-window' from
> `display-buffer-fallback-action' in `calendar-in-read-only-buffer'.

The most conservative fix would seem to be to only change
calendar-basic-setup, where it calls diary-view-entries.

I guess what we really want to say is "don't display the diary in the
window that you just displayed the calendar in" (is that possible?), but
failing that, simply removing display-buffer-in-previous-window seems to
work. What's the cleanest way to do that? Binding
display-buffer-overriding-action or display-buffer-fallback-action
to an explicit list? display-buffer-fallback-action does not have the
friendliest format to make "remove element X" straightforward,
and is marked as a constant.

*** lisp/calendar/calendar.el	2014-03-17 16:04:32 +0000
--- lisp/calendar/calendar.el	2014-09-04 17:57:25 +0000
***************
*** 1432,1438 ****
        (calendar-generate-window month year)
        (if (and calendar-view-diary-initially-flag
                 (calendar-date-is-visible-p date))
!           (diary-view-entries))))
    (if calendar-view-holidays-initially-flag
        (let* ((diary-buffer (get-file-buffer diary-file))
               (diary-window (if diary-buffer (get-buffer-window diary-buffer)))
--- 1432,1444 ----
        (calendar-generate-window month year)
        (if (and calendar-view-diary-initially-flag
                 (calendar-date-is-visible-p date))
!           (let ((display-buffer-fallback-action
!                  '((display-buffer--maybe-same-window
!                     display-buffer-reuse-window
!                     display-buffer--maybe-pop-up-frame-or-window
!                     display-buffer-use-some-window
!                     display-buffer-pop-up-frame))))
!             (diary-view-entries)))))
    (if calendar-view-holidays-initially-flag
        (let* ((diary-buffer (get-file-buffer diary-file))
               (diary-window (if diary-buffer (get-buffer-window diary-buffer)))