The following is an example of how to examine the text-properties of the items being generated by org-agenda-list
, and modify the string based on certain criteria. In this example, the value of the text property ts-date
is obtained and compared against the current date -- if it is overdue, we add OLD:
; if it is current, we add CURRENT:
, if its future, we add FUTURE:
. The original poster can customize this example add a new line and/or a divider line at select locations. The customization may vary depending upon the sorting criteria chosen by the original poster in the org-agenda-sorting-strategy
, etc.
In this example, the function org-agenda-finalize-entries
has been modified near the bottom between the sections labeled ;; BEGIN modification
and ;; END modification
.
(require 'org-agenda)
(defun org-agenda-finalize-entries (list &optional type)
"Sort, limit and concatenate the LIST of agenda items.
The optional argument TYPE tells the agenda type."
(let ((max-effort (cond ((listp org-agenda-max-effort)
(cdr (assoc type org-agenda-max-effort)))
(t org-agenda-max-effort)))
(max-todo (cond ((listp org-agenda-max-todos)
(cdr (assoc type org-agenda-max-todos)))
(t org-agenda-max-todos)))
(max-tags (cond ((listp org-agenda-max-tags)
(cdr (assoc type org-agenda-max-tags)))
(t org-agenda-max-tags)))
(max-entries (cond ((listp org-agenda-max-entries)
(cdr (assoc type org-agenda-max-entries)))
(t org-agenda-max-entries))) l)
(when org-agenda-before-sorting-filter-function
(setq list
(delq nil
(mapcar
org-agenda-before-sorting-filter-function list))))
(setq list (mapcar 'org-agenda-highlight-todo list)
list (mapcar 'identity (sort list 'org-entries-lessp)))
(when max-effort
(setq list (org-agenda-limit-entries
list 'effort-minutes max-effort 'identity)))
(when max-todo
(setq list (org-agenda-limit-entries list 'todo-state max-todo)))
(when max-tags
(setq list (org-agenda-limit-entries list 'tags max-tags)))
(when max-entries
(setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
;; BEGIN modification
(setq list
(mapcar
(lambda (string)
(let* (
(current-date (time-to-days (current-time)))
(ts-date (get-text-property 0 'ts-date string)) )
(if ts-date
(cond
((< ts-date current-date)
(message "The task dated %s is overdue." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "OLD: " string))
((= ts-date current-date)
(message "The task dated %s is due today." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "CURRENT: " string))
((> ts-date current-date)
(message "The task dated %s is not due yet." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "FUTURE: " string)))
string)))
list))
;; END modification
(mapconcat 'identity list "\n")))