GNU bug report logs - #7019
appointments and unsorted diary-entries-list

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Sun, 12 Sep 2010 10:00:03 UTC

Severity: normal

Found in version 23.2

Done: Glenn Morris <rgm <at> gnu.org>

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 7019 in the body.
You can then email your comments to 7019 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#7019; Package emacs. (Sun, 12 Sep 2010 10:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 12 Sep 2010 10:00:03 GMT) Full text and rfc822 format available.

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

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; [PATCH] fix bugs in diary/appt
Date: Sun, 12 Sep 2010 11:01:19 +0100
[Message part 1 (text/plain, inline)]
Emacs failed to notice me some appointments (fortunately they are not
important). Here is the finding:

The doc string of diary-list-entries says the return list is sorted,
which is not the case. (add-hook 'diary-list-entries-hook
'diary-sort-entries) is not guaranteed to work unless that is the very
last function to run. Other functions in that hook can modify the
entries too, for example, diary-include-other-diary-files. The first
patch fixes these issues. Another fix will be to fix the doc string to
state that the returned list is not sorted.

appt-make-list replies on sorted diary entries to work. The second patch
explicitly sorts the list before processing.

[0001-Respect-the-doc-string-and-return-sorted-diary-entri.patch (text/x-diff, inline)]
From 1b678c6c0601f500321cfb037467f6d393f0e7eb Mon Sep 17 00:00:00 2001
From: Leo <sdl.web <at> gmail.com>
Date: Sun, 12 Sep 2010 10:36:11 +0100
Subject: [PATCH 1/2] Respect the doc string and return sorted diary entries

---
 lisp/calendar/diary-lib.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index 39354bd..3c748ac 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -187,7 +187,6 @@ you will probably also want to add `diary-mark-included-diary-files' to
 
      (setq diary-display-function 'diary-fancy-display)
      (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
-     (add-hook 'diary-list-entries-hook 'diary-sort-entries)
 
 in your `.emacs' file to cause the fancy diary buffer to be displayed with
 diary entries from various included files, each day's entries sorted into
@@ -789,6 +788,7 @@ LIST-ONLY is non-nil, in which case it just returns the list."
               (goto-char (point-min))
               (run-hooks 'diary-nongregorian-listing-hook
                          'diary-list-entries-hook)
+	      (diary-sort-entries)
               (unless list-only
                 (if (and diary-display-function
                          (listp diary-display-function))
-- 
1.7.2

[0002-Make-appt-make-list-more-robust.patch (text/x-diff, inline)]
From 7d29e59fb61a8ef76e1c5c583a52cc25b32fba41 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web <at> gmail.com>
Date: Sun, 12 Sep 2010 10:41:19 +0100
Subject: [PATCH 2/2] Make appt-make-list more robust

It depends on a list of sorted diary entries to work; so explicitly
sort the entries.
---
 lisp/calendar/appt.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index b590290..53469b0 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -572,7 +572,8 @@ appointment package (if it is not already active)."
               ;; looking for entries beginning with a time.  If the
               ;; entry begins with a time, add it to the
               ;; appt-time-msg-list.  Then sort the list.
-              (let ((entry-list diary-entries-list)
+              (let ((entry-list (sort (copy-sequence diary-entries-list)
+				      'diary-entry-compare))
                     time-string)
                 ;; Skip diary entries for dates before today.
                 (while (and entry-list
-- 
1.7.2

[Message part 4 (text/plain, inline)]
Leo

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Tue, 14 Sep 2010 00:24:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Mon, 13 Sep 2010 20:26:03 -0400
Leo wrote:

> The doc string of diary-list-entries says the return list is sorted,

Where does it say that? Oh, I guess you might mean:

  Returns a list of all relevant diary entries found, if any, in order
  by date.

Which is true unless include files are involved. Note it does not mean
that entries are also sorted by time of day. I don't think sorting by
default is the right solution. I might just mention in the docs that
if include files are used, the order will day order for the entries
from any given file, then by the order in which the include files were
processed. Some people might want it that way (eg not sorted by time
of day), and those who don't are probably aready using
diary-sort-entries. The fact that the entries are in day order is
really just a consequence of how the code is implemented, rather than
a deliberate choice.

> (add-hook 'diary-list-entries-hook 'diary-sort-entries) is not
> guaranteed to work unless that is the very last function to run.

OK, I think that should just be pointed out in the docs.
(The manual sort of does this without being explicit.)

> appt-make-list replies on sorted diary entries to work.

Looks like it relies on them being sorted in _day_ order, but not in
_time_ order within any given day. Again, this is true unless include
files are involved. I guess this is why nobody noticed till now. I'll
fix that somehow.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Tue, 14 Sep 2010 06:41:01 GMT) Full text and rfc822 format available.

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

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Tue, 14 Sep 2010 07:42:50 +0100
On 2010-09-14 01:26 +0100, Glenn Morris wrote:
> Leo wrote:
>
>> The doc string of diary-list-entries says the return list is sorted,
>
> Where does it say that? Oh, I guess you might mean:
>
>   Returns a list of all relevant diary entries found, if any, in order
>   by date.
>
> Which is true unless include files are involved. Note it does not mean
> that entries are also sorted by time of day. I don't think sorting by
> default is the right solution. I might just mention in the docs that
> if include files are used, the order will day order for the entries
> from any given file, then by the order in which the include files were
> processed. Some people might want it that way (eg not sorted by time
> of day), and those who don't are probably aready using
> diary-sort-entries. The fact that the entries are in day order is
> really just a consequence of how the code is implemented, rather than
> a deliberate choice.
>
>> (add-hook 'diary-list-entries-hook 'diary-sort-entries) is not
>> guaranteed to work unless that is the very last function to run.
>
> OK, I think that should just be pointed out in the docs.
> (The manual sort of does this without being explicit.)
>
>> appt-make-list replies on sorted diary entries to work.
>
> Looks like it relies on them being sorted in _day_ order, but not in
> _time_ order within any given day. Again, this is true unless include
> files are involved. I guess this is why nobody noticed till now. I'll
> fix that somehow.

Sorry I should be more explicit. I meant date order in all of them. I
think emacs should try its best not to miss any appointments recorded in
it. For example, diary-list-entries-hook is user level variable, so
anything could happen to it, say someone accidentally adds a function
that shuffles diary-entry-list and that could screw up appt.

Thanks.
Leo





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Wed, 15 Sep 2010 00:29:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Tue, 14 Sep 2010 20:30:32 -0400
Leo wrote:

> Emacs failed to notice me some appointments (fortunately they are not
> important).

Could you explain precisely how this happened, from `emacs -Q'?

Using diary-number-of-entries > 1 and include files?





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Wed, 15 Sep 2010 02:56:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Tue, 14 Sep 2010 22:58:15 -0400
I've fixed the only case I can think of, in the emacs-23 branch.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Wed, 15 Sep 2010 07:08:02 GMT) Full text and rfc822 format available.

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

From: Leo <sdl.web <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Wed, 15 Sep 2010 08:09:47 +0100
[Message part 1 (text/plain, inline)]
On 2010-09-15 01:30 +0100, Glenn Morris wrote:
> Leo wrote:
>
>> Emacs failed to notice me some appointments (fortunately they are not
>> important).
>
> Could you explain precisely how this happened, from `emacs -Q'?
>
> Using diary-number-of-entries > 1 and include files?

In the main diary file, I have an appointment on Sunday. In the
included, another one Today. Without sorting, Today's appointment is not
in appt-time-msg-list.

So basically put the attached diary and others files in $HOME and emacs
-q -l test.el and check appt-time-msg-list.

[diary (text/plain, attachment)]
[others (text/plain, attachment)]
[test.el (application/emacs-lisp, attachment)]
[Message part 5 (text/plain, inline)]
Leo

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Wed, 15 Sep 2010 07:17:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Wed, 15 Sep 2010 03:19:09 -0400
Leo wrote:

>> Using diary-number-of-entries > 1 and include files?
[...]
> (setq diary-number-of-entries 7)

Right, thought so. Should be fixed in emacs-23.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7019; Package emacs. (Wed, 15 Sep 2010 23:59:01 GMT) Full text and rfc822 format available.

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

From: Leo <sdl.web <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 7019 <at> debbugs.gnu.org
Subject: Re: bug#7019: 23.2; [PATCH] fix bugs in diary/appt
Date: Thu, 16 Sep 2010 01:00:46 +0100
On 2010-09-15 08:19 +0100, Glenn Morris wrote:
>>> Using diary-number-of-entries > 1 and include files?
> [...]
>> (setq diary-number-of-entries 7)
>
> Right, thought so. Should be fixed in emacs-23.

Thank you.

Leo




bug closed, send any further explanations to Leo <sdl.web <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 16 Sep 2010 03:59:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 14 Oct 2010 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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