Similar to this thread and this one, I want to show an agenda view with all items marked as "DONE" in the last two weeks, but without the lines Clocked: (1:00) DONE Some task (because for that I only care about the totals and use a clock-report dynamic block). I would also like to restrict to second-level items only.

I tried this code and succeeded in restricting to second-level headings only:

(add-to-list 'org-agenda-custom-commands
             '("W" "Weekly review"
               agenda ""
               ((org-agenda-span 'week)
                (org-agenda-start-on-weekday 1)
                (org-agenda-start-with-log-mode nil)
                 '(org-agenda-skip-entry-if 'notregexp "^\\*\\* DONE "))

If I set org-agenda-start-with-log-mode to t, then Clocked: ... lines show, e.g.:

Monday     30 September 2019 W40
  gtd:        10:49-10:59 Clocked:   (0:10) DONE some task
  gtd:        10:50...... Closed:     DONE Some other task

If I set it to nil, then Closed: ... lines do not show.

Also, if I set org-agenda-span to 14, to include the past 14 days, it shows 14 days starting from today.

How can I include only Closed: ... lines, and list tasks in the past?


To include only Closed: ... use:

(org-agenda-start-with-log-mode '(closed))

To show the past 14 days offset the start day:

(org-agenda-start-day "-14d")

This results in:

(add-to-list 'org-agenda-custom-commands
             '("W" "Weekly review"
               agenda ""
               ((org-agenda-start-day "-14d")
                (org-agenda-span 14)
                (org-agenda-start-on-weekday 1)
                (org-agenda-start-with-log-mode '(closed))
                (org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp "^\\*\\* DONE ")))))

You might also want to include archived items with:

(org-agenda-archives-mode t)

Note: Use C-h v to describe a variable like org-agenda-start-with-log-mode to see the possibilities or M-x custmoize-variable to customize it (this shows all possibilities in the customize interface).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.