Ilya Shlyakhter <ilya_...@alum.mit.edu> wrote:

> In the head revision, if the org file has headlines that start with a
> timestamp, the command to create a timeline of the file (C-a L)
> crashes.
> 
> 
> * things
> *** <2011-10-06 Thu 22:24>
> 
>     some text
> 
> 
> mapcar: Args out of range: #("  " 0 2 (org-category "mt3" tags nil
> org-highest-priority 65 org-lowest-priority 69 time-of-day 2224 ...)),
> 0, 37
> 

Confirmed. The culprit seems to be some not-so-robust code in
org-agenda-highlight-todo. Here's the code:

--8<---------------cut here---------------start------------->8---
      ...
      (let ((pl (text-property-any 0 (length x) 'org-heading t x)))
          (setq re (get-text-property 0 'org-todo-regexp x))
          (when (and re
                     (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)")
                                          x (or pl 0)) pl))
            (add-text-properties
             (or (match-end 1) (match-end 0)) (match-end 0)
             (list 'face (org-get-todo-face (match-string 2 x)))
             x)
            (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)))))))
      ...
--8<---------------cut here---------------end--------------->8---

The problem is that pl is nil in this case and so is the
value of

      (string-match (concat "\\(\\.*\\)" re "\\( +\\)") x (or pl 0))

but they compare equal, so the body of the

    (when (and re ...)
      <body>
     )

is evaluated with disastrous results: the string-match has failed so it
has not set any matches for (match-end ...) to find. In this case,
(match-end 1) evaluated to 36 (that's in a 3-character string :-).

AFAICT, the whole body should be skipped in the case when pl is nil:

        (let ((pl ...))
          (when pl
            (setq re (...)
            (when (and re (...))
               ...
               ...))))

But it's not clear to me whether this is the only bug.

Nick

Reply via email to