GNU bug report logs - #8920
24.0.50; Calendar raises error with #included diary file

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Wed, 22 Jun 2011 23:04:02 UTC

Severity: normal

Found in version 24.0.50

Done: Stephen Berman <stephen.berman <at> gmx.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8920 in the body.
You can then email your comments to 8920 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Wed, 22 Jun 2011 23:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 Jun 2011 23:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Calendar raises error with #included diary file
Date: Thu, 23 Jun 2011 01:03:21 +0200
[Message part 1 (text/plain, inline)]
1. Let the file ~/diary consist of the line between start and end:
-----start
#include "~/test"
end------

2. Let ~/test be readable; it's content is irrelevant (can be empty).

3. Let ~/.emacs consist of the lines between start and end:
-----start
(add-hook 'find-file-hook
	  (lambda () (set-window-buffer (selected-window)
					(set-buffer (current-buffer)))))

(custom-set-variables
 '(calendar-mark-diary-entries-flag t)
 '(calendar-today-visible-hook (quote (calendar-mark-today)))
 '(diary-list-entries-hook (quote (diary-include-other-diary-files)))
 '(diary-mark-entries-hook (quote (diary-mark-included-diary-files))))
end------

4. Invoke emacs (without -Q)

5. Type `M-x calendar RET'
=> Wrong type argument: number-or-marker-p, nil
The Calendar is displayed in the lower window, but today's date is not
marked, and the cursor is at the beginning of the buffer.

Here is the backtrace from entering the debugger on error:

[backtrace (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]
When I repeat the above recipe through step 4, then instrument the
lambda expression in .emacs for edebugging, then invoke the Calendar and
step through the lambda sexp, the Calendar first appears, then its
window is occupied by the diary buffer, then by the buffer of ~/test,
and finally by the diary again.  No error is raised, and when I switch
to the *Calendar* buffer, today's date is shown marked.


In GNU Emacs 24.0.50.1 (i686-suse-linux-gnu, GTK+ Version 2.20.1)
 of 2011-06-04 on escher
Windowing system distributor `The X.Org Foundation', version 11.0.10800000
configured using `configure  '--without-toolkit-scroll-bars' 'CFLAGS=-g -O2 -fno-optimize-sibling-calls''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Fri, 24 Jun 2011 18:50:03 GMT) Full text and rfc822 format available.

Message #8 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Fri, 24 Jun 2011 14:49:43 -0400
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?

Since find-file-noselect runs find-file-hook, at first sight it looks to
me like all you are doing is deliberately breaking find-file-noselect.

So my initial reaction is: "if it hurts when you do that, don't do that".




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Fri, 24 Jun 2011 21:33:02 GMT) Full text and rfc822 format available.

Message #11 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Fri, 24 Jun 2011 23:32:31 +0200
On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <rgm <at> gnu.org> 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?

I'm working on a new version of Todo mode (which I hope to submit for
possible inclusion in Emacs 24, depending on when the feature freeze
begins) which is defined so that visiting a file assigned (by
auto-mode-alist) to that mode executes code to display the file
appropriately by calling the new version of todo-show, which contains
the set-window-buffer sexp.  And such a file is suitable for diary
inclusion, because it may contain Todo items that are recognized as
diary entries.

> Since find-file-noselect runs find-file-hook, at first sight it looks to
> me like all you are doing is deliberately breaking find-file-noselect.

The above is just the minimal self-contained code that induces the
error; in the actual code the set-window-buffer sexp is contained in a
conditional call to the new version of todo-show.  It isn't necessary to
do this in find-file-hook; in fact, I had previously included the
conditional call directly in the new version of the mode function
todo-mode, then thought it would be cleaner to delegate it to a hook.
But maybe you're right that find-file-hook isn't appropriate.  In any
case, the Calendar problem is caused by calling that sexp, whether or
not it is in find-file-hook.

> So my initial reaction is: "if it hurts when you do that, don't do that".

I anticipated this reaction, and even had it myself, after encountering
the problem; the thing is, I didn't know I was doing that :-(.  That is,
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.

Steve Berman




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Sat, 25 Jun 2011 20:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Sat, 25 Jun 2011 22:18:08 +0200
On Fri, 24 Jun 2011 23:32:31 +0200 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <rgm <at> gnu.org> 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)))))




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Sat, 25 Jun 2011 22:26:02 GMT) Full text and rfc822 format available.

Message #17 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
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.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Sun, 26 Jun 2011 00:20:04 GMT) Full text and rfc822 format available.

Message #20 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Sun, 26 Jun 2011 02:19:14 +0200
On Sat, 25 Jun 2011 18:25:18 -0400 Glenn Morris <rgm <at> gnu.org> 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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8920; Package emacs. (Sun, 26 Jun 2011 01:26:01 GMT) Full text and rfc822 format available.

Message #23 received at 8920 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 8920 <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Sat, 25 Jun 2011 21:25:22 -0400
OK. Can this be closed?




Reply sent to Stephen Berman <stephen.berman <at> gmx.net>:
You have taken responsibility. (Sun, 26 Jun 2011 11:11:02 GMT) Full text and rfc822 format available.

Notification sent to Stephen Berman <stephen.berman <at> gmx.net>:
bug acknowledged by developer. (Sun, 26 Jun 2011 11:11:02 GMT) Full text and rfc822 format available.

Message #28 received at 8920-done <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8920-done <at> debbugs.gnu.org
Subject: Re: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Sun, 26 Jun 2011 13:09:51 +0200
On Sat, 25 Jun 2011 21:25:22 -0400 Glenn Morris <rgm <at> gnu.org> wrote:

> OK. Can this be closed?

Done.  (Should've closed it with the previous post, sorry.)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Jul 2011 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.