Catch agenda error when there is a tie stamp before the first headline

* lisp/org-agenda.el (org-agenda-get-timestamps): No errors
while getting TODO state.
(org-agenda-highlight-todo): No error when no keyword has
been matched.

Eric Arneson writes:

> I've discovered a bug in `org-agenda-get-timestamps' wherein an active
> timestamp before the first headline causes it to fail.  I realize that
> this is probably an error in my use of active timestamps, but there was
> no really handy error message and this bugged me for weeks.
>
> I'm not familiar enough with org-mode to know what the correct behavior
> should be here (it'd be nice to get an error message saying "Don't use
> active timestamps that way!"), but here's an example .org file that will
> trigger the bug:
>
> --8<---------------cut here---------------start------------->8---
> #+BEGIN: clocktable :maxlevel 3 :scope today
> Clock summary at [2010-06-20 Sun 13:09]
>
> | L | Headline                              | Time   |
> |---+---------------------------------------+--------|
> |   | *Total time*                          | *0:13* |
> |---+---------------------------------------+--------|
> | 1 | Track down funky bug <2010-06-20 Sun> | 0:13   |
> #+END:
>
> * Track down funky bug <2010-06-20 Sun>
>  :LOGBOOK:
>  CLOCK: [2010-06-20 Sun 12:43]
>  CLOCK: [2010-06-20 Sun 12:30]--[2010-06-20 Sun 12:43] =>  0:13
>  :END:
> --8<---------------cut here---------------end--------------->8---
>
> I hope this can help somebody else track down the right place to fix
> this bug.
This commit is contained in:
Carsten Dominik 2010-06-24 08:53:34 +02:00
parent 1fc1dc389b
commit 08f8875ecd
1 changed files with 7 additions and 6 deletions

View File

@ -4344,7 +4344,7 @@ the documentation of `org-diary'."
clockp (and org-agenda-include-inactive-timestamps
(or (string-match org-clock-string tmp)
(string-match "]-+\\'" tmp)))
todo-state (org-get-todo-state)
todo-state (ignore-errors (org-get-todo-state))
donep (member todo-state org-done-keywords))
(if (or scheduledp deadlinep closedp clockp
(and donep org-agenda-skip-timestamp-if-done))
@ -5162,11 +5162,12 @@ HH:MM."
(or (match-end 1) (match-end 0)) (match-end 0)
(list 'face (org-get-todo-face (match-string 2 x)))
x)
(setq x (concat (substring x 0 (match-end 1))
(format org-agenda-todo-keyword-format
(match-string 2 x))
(org-add-props " " (text-properties-at 0 x))
(substring x (match-end 3)))))
(when (match-end 1)
(setq x (concat (substring x 0 (match-end 1))
(format org-agenda-todo-keyword-format
(match-string 2 x))
(org-add-props " " (text-properties-at 0 x))
(substring x (match-end 3))))))
x)))
(defsubst org-cmp-priority (a b)