I put together the function below but it doesn't work. The problem is get-text-property
returns nil for every task.
Any idea how to get the CREATED property and fix the entire thing?
(defun jarfar/org-agenda-cmp-user-defined-created-date (a b)
"Org Agenda user function to sort tasks based on CREATED property."
(let* (
(time-a (get-text-property 0 'CREATED a))
(time-b (get-text-property 0 'CREATED b))
(time-a (if time-a (org-time-string-to-time time-a) nil))
(time-b (if time-b (org-time-string-to-time time-b) nil)))
(if (and time-a time-b)
(if (org-time< time-a time-b)
-1
(if (org-time> time-a time-b)
1
nil))
(if time-a time-a time-b)
)))
EDIT: Here is an example data file:
* Tasks
** TODO Task 1
:PROPERTIES:
:CREATED: [2020-07-23 Thu]
:END:
** TODO Task 2
:PROPERTIES:
:CREATED: [2020-06-15 Tue]
:END:
** TODO Task 3
:PROPERTIES:
:CREATED: [2020-05-22 Sat]
:END:
** TODO Task 4
:PROPERTIES:
:CREATED: [2020-06-01 Tue]
:END:
EDIT: Update to the function:
(defun jarfar/org-agenda-cmp-user-defined-created-date (a b)
"Org Agenda user function to sort tasks based on CREATED property."
(let* (
(marker-a (get-text-property 0 'org-marker a))
(marker-b (get-text-property 0 'org-marker b))
(time-a (if marker-a (org-entry-get marker-a "CREATED") nil))
(time-b (if marker-b (org-entry-get marker-b "CREATED") nil))
(time-a (if time-a (org-time-string-to-time time-a) nil))
(time-b (if time-b (org-time-string-to-time time-b) nil)))
(if (and time-a time-b)
(if (org-time< time-a time-b)
-1
(if (org-time> time-a time-b)
1
nil))
(if time-a time-a time-b)
)))
org-journal-create-re
? The name implies that it's a regex, not a text property. If you doC-u C-x =
on the entry, does it report some sort ofcreated
text property?M-x describe-text-properties
to get the text properties at point.