* bug#8920: 24.0.50; Calendar raises error with #included diary file
@ 2011-06-22 23:03 Stephen Berman
2011-06-24 18:49 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2011-06-22 23:03 UTC (permalink / raw)
To: 8920
[-- Attachment #1: Type: text/plain, Size: 935 bytes --]
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:
[-- Attachment #2: backtrace --]
[-- Type: application/octet-stream, Size: 573 bytes --]
[-- Attachment #3: Type: text/plain, Size: 1029 bytes --]
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-22 23:03 bug#8920: 24.0.50; Calendar raises error with #included diary file Stephen Berman
@ 2011-06-24 18:49 ` Glenn Morris
2011-06-24 21:32 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2011-06-24 18:49 UTC (permalink / raw)
To: Stephen Berman; +Cc: 8920
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-24 18:49 ` Glenn Morris
@ 2011-06-24 21:32 ` Stephen Berman
2011-06-25 20:18 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2011-06-24 21:32 UTC (permalink / raw)
To: Glenn Morris; +Cc: 8920
On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <rgm@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-24 21:32 ` Stephen Berman
@ 2011-06-25 20:18 ` Stephen Berman
2011-06-25 22:25 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2011-06-25 20:18 UTC (permalink / raw)
To: Glenn Morris; +Cc: 8920
On Fri, 24 Jun 2011 23:32:31 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:
> On Fri, 24 Jun 2011 14:49:43 -0400 Glenn Morris <rgm@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)))))
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-25 20:18 ` Stephen Berman
@ 2011-06-25 22:25 ` Glenn Morris
2011-06-26 0:19 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2011-06-25 22:25 UTC (permalink / raw)
To: Stephen Berman; +Cc: 8920
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-25 22:25 ` Glenn Morris
@ 2011-06-26 0:19 ` Stephen Berman
2011-06-26 1:25 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2011-06-26 0:19 UTC (permalink / raw)
To: Glenn Morris; +Cc: 8920
On Sat, 25 Jun 2011 18:25:18 -0400 Glenn Morris <rgm@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-26 0:19 ` Stephen Berman
@ 2011-06-26 1:25 ` Glenn Morris
2011-06-26 11:09 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2011-06-26 1:25 UTC (permalink / raw)
To: Stephen Berman; +Cc: 8920
OK. Can this be closed?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8920: 24.0.50; Calendar raises error with #included diary file
2011-06-26 1:25 ` Glenn Morris
@ 2011-06-26 11:09 ` Stephen Berman
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Berman @ 2011-06-26 11:09 UTC (permalink / raw)
To: Glenn Morris; +Cc: 8920-done
On Sat, 25 Jun 2011 21:25:22 -0400 Glenn Morris <rgm@gnu.org> wrote:
> OK. Can this be closed?
Done. (Should've closed it with the previous post, sorry.)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-06-26 11:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-22 23:03 bug#8920: 24.0.50; Calendar raises error with #included diary file Stephen Berman
2011-06-24 18:49 ` Glenn Morris
2011-06-24 21:32 ` Stephen Berman
2011-06-25 20:18 ` Stephen Berman
2011-06-25 22:25 ` Glenn Morris
2011-06-26 0:19 ` Stephen Berman
2011-06-26 1:25 ` Glenn Morris
2011-06-26 11:09 ` Stephen Berman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).