Distinguish Repeated Tasks in Org Agenda
Problem: Repeated or Not?
In the Org agenda view, repeated and non-repeated tasks look the same. I always hesitate to mark a repeated task as done because I might forget to set the repeater (e.g., ++1w
) and the task would then never reappear.
It would be great if repeated tasks are distinguishable in the Org agenda. For example, showing the repeater (e.g., ++1w
) as part of the entry.
Solution: Setting Prefix Format
Thanks to the tip from yantar92 (our new Org maintainer), I am able to add the repeater to Org agenda with org-agenda-prefix-format
:
- Shorten the scheduled leaders to reserve space for repeater.
- Add a function to get the formatted repeater.
- Include the formatted repeater to
org-agenda-prefix-format
.
It needs only a few lines of Elisp:
;; Use shorter leaders to reserve space for repeater.
(setq org-agenda-scheduled-leaders '("Sched" "S.%2dx"))
(defun my/org-agenda-repeater ()
"The repeater shown in org-agenda-prefix for agenda."
(if (org-before-first-heading-p)
"-------" ; fill the time grid
(format "%5s: " (or (org-get-repeat) ""))))
;; Add `my/org-agenda-repeater' to the agenda prefix.
(setcdr (assoc 'agenda org-agenda-prefix-format)
" %i %-12:c%?-12t%s%(my/org-agenda-repeater)")
Alternatives
Using the Agenda Finalize Hook (Hacky)
Before yantar92’s tip, I had a hackier solution (gist):
- Fetch the repeater using the Org entry as text properties
- Use
org-agenda-finalize-hook
which happens after the agenda view is built but before it is displayed, to add the repeater.
Using Column View (Cluttered)
Before that, I had another solution using the column view (M-x org-agenda-columns
) by showing the scheduled date as a column by setting the COLUMNS
attribute.
(setq org-columns-default-format-for-agenda
"%TODO %PRIORITY(Pri) %60ITEM(Task) %SCHEDULED")
While it works and is built-in, the strings are too verbose and hard to parse. Hence, I looked for the above solution witch custom Elisp.