Wai Hon's Blog

Distinguish Repeated Tasks in Org Agenda

2025-01-03 #emacs #org-mode

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:

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):

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.