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

From: Stephen Berman <[email-masked]>
Date: Sat, 25 Jun 2011 22:18:08 +0200

On Fri, 24 Jun 2011 23:32:31 +0200 Stephen Berman <[email-masked]> wrote:

> On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <[email-masked]> wrote:
>
>> Stephen Berman wrote:
>>
>>> (add-hook 'find-file-hook
>>> 	  (lambda () (set-window-buffer (selected-window)
>>> 					(set-buffer (current-buffer)))))
>>
>> Help me out: what is this supposed to be for?
[...]
> my intention was to invoke todo-show when the user chooses to visit a
> todo file directly (instead of interactively calling todo-show); I
> didn't consider the case where the file is visited programmatically.  I
> don't know how to distinguish the two cases in this context;
> called-interactively-p won't DTRT, precisely because the command the
> user invokes to visit the file is not part of Todo mode.  So I'm hoping
> there's a way within calendar.el to avoid the error.

The following patch to calendar-generate-window fixes the problem for
me, and seems like it shouldn't cause problems elsewhere.

Steve Berman

*** /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)))))