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

From: Stephen Berman <[email-masked]>
Date: Sun, 26 Jun 2011 02:19:14 +0200

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

> Stephen Berman wrote:
>>       (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.

Yes, though I've ascertained that this only happens when the included
file is not already being visited in a buffer when calendar is invoked
-- that's what triggers the inappropriate function in find-file-hook.

> 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.

Hm, I'd rather not take that advice ;-).  But I've now put the function
on post-command-hook and so far it seems to DTRT and also avoids the
problem with find-file-hook.

Thanks for the helpful feedback.

Steve Berman