Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file

From: Glenn Morris <[email-masked]>
Date: Sat, 25 Jun 2011 18:25:18 -0400

Stephen Berman wrote:

> *** /home/steve/bzr/emacs/trunk/lisp/calendar/calendar.el	2011-06-04 12:27:38.000000000 +0200
> --- /home/steve/bzr/emacs/quickfixes/lisp/calendar/calendar.el	2011-06-25 22:10:04.000000000 +0200
> ***************
> *** 1392,1398 ****
>            (calendar-mark-holidays)
>            (and in-calendar-window (sit-for 0)))
>       (unwind-protect
> !         (if calendar-mark-diary-entries-flag (diary-mark-entries))
>         (if today-visible
>             (run-hooks 'calendar-today-visible-hook)
>           (run-hooks 'calendar-today-invisible-hook)))))
> --- 1392,1401 ----
>            (calendar-mark-holidays)
>            (and in-calendar-window (sit-for 0)))
>       (unwind-protect
> !         (if calendar-mark-diary-entries-flag
> ! 	    (save-selected-window
> ! 	      (save-excursion
> ! 		(diary-mark-entries))))
>         (if today-visible
>             (run-hooks 'calendar-today-visible-hook)
>           (run-hooks 'calendar-today-invisible-hook)))))

I don't like this, because IIUC, this is only needed because of the:

(find-file-noselect (diary-check-diary-file) t)

in diary-mark-entries.

It should be implicit that find-file-noselect does not mess with the
window layout, and we should not need to wrap every call to it in save-*
constructs to guard against inappropriate find-file-hooks.

I've made some changes to diary-lib.el that mean there is no longer an
error in the initial example; however the calendar buffer ends up being
replaced with the diary buffer.

I didn't read in detail all that you want to do, but I think the only
way you can do it at present is by advising find-file rather than using
find-file-hook.