Jeff Mickey <j...@archlinux.org> writes:

> However.. my current issue: I'd like to sort my todo's by when I
> entered them. So in my capture template I put an inactive timestamp at
> the bottom, so my headlines look something like:
>
> --8<---------------cut here---------------start------------->8---
> * Todo
> ** TODO call mom
> - Ask about christmas
> - Talk about Dad
> - See if she bought a dog
>
>    [2012-12-05 Wed 16:36]
> ** TODO Yet another thing
>    [2012-12-05 Wed 16:37]
> --8<---------------cut here---------------end--------------->8---
>
> I'd love to have a way to bring up the agenda and have it sorted by
> this ctime I'm manually inserting. Do people have suggestions on the
> best way to support this?
>
> Maybe add a property to my TODOs that is this creation time?
> Has anyone else done something similar to this using
> org-agenda-cmp-user-defined?

Hmmm.
If your 'creation' timestamp is the only inactive timestamp, you won't
need a special property; org-entry-get should give you the right one.

I am not good at this, but what about something like:

--8<---------------cut here---------------start------------->8---
(defun my-agenda-sort-by-inactive-timestamp (a b)
  "Sort by interactive timestamp. Oldest first, items without any ts at the 
bottom."
  (let* ((ma (or (get-text-property 1 'org-marker a)
                 (get-text-property 1 'org-hd-marker a)))
         (mb (or (get-text-property 1 'org-marker b)
                 (get-text-property 1 'org-hd-marker b)))
         (tsa (org-entry-get ma "TIMESTAMP_IA"))
         (tsb (org-entry-get mb "TIMESTAMP_IA"))
         (ta (when tsa (date-to-time tsa)))
         (tb (when tsb (date-to-time tsb))))

    (cond  ((eq tsa nil) +1)
           ((eq tsb nil) -1)
           ((time-less-p ta tb)
                -1)
           ((time-less-p tb ta)
               +1)
           (t nil))))

(setq org-agenda-custom-commands
      '(("x" "Tasks" todo ""
               ((org-agenda-overriding-header "Tasks sorted by
               TIMESTAMP_IA")
               (org-agenda-cmp-user-defined 
'my-agenda-sort-by-inactive-timestamp)
                (org-agenda-sorting-strategy
                 '(user-defined-up)))
               )))
--8<---------------cut here---------------end--------------->8---

Does that work?

If you use :logbook:, entries within will 'override' your inactive
timestamp at the end of the entry. A special CREATED property would be
useful in this case.

> ... is this the wrong place to ask this question?

Definitely not :).

Memnon


Reply via email to