[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Stephen Berman
Subject: bug#8920: 24.0.50; Calendar raises error with #included diary file
Date: Fri, 24 Jun 2011 23:32:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <address@hidden> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]