39

I would like to be able to switch on & off display of "done" entries in org-mode.

Alternative - is it possible to open only not-done entries

Julien Chastang
  • 17,592
  • 12
  • 63
  • 89
Sergey Porfiriev
  • 491
  • 1
  • 4
  • 4
  • 5
    You could also archive all done tasks, e.g. http://stackoverflow.com/questions/6997387/how-to-archive-all-the-done-tasks-using-a-single-command – N.N. Feb 10 '12 at 22:58
  • Another approach might be to fold all the DONE tasks, so their subtrees and any text they contain would be hidden. – Robert P. Goldman Jul 19 '13 at 21:20
  • 1
    The answer [here](https://stackoverflow.com/questions/7602787) is relevant -- TLDR: make sure all TODO headlines are not top-level, and use `org-show-todo-tree`. – Mark Nov 30 '20 at 20:03

2 Answers2

40

C-c / t (org-show-todo-tree) will redisplay the current document as a sparse tree which only shows TODO items. Alternatively, to show only DONE items, you can use C-c / T DONE.

For more details on sparse trees, see the Org manual.

fnl
  • 2,209
  • 19
  • 17
26

fnl's answer is good, and you might also look into archiving. Once completed, I never need to see the vast majority of my todo items again, so I use C-c C-x C-s (or some key mapping of that). This can be used for any tree or subtree in Org.

This command moves the tree headline that point was on to a separate archive file. If your original file was, say, index.org, items archived with this command would be moved to index.org_archive. Moved files are automatically given additional metadata like when it was archived and what file it originally came from so that you can do research, stats, or restoration on archived items.

There are two other archive commands. C-c C-x a just marks the item with an :ARCHIVED: tag. The headline for the tree will still show, but tabbing won't expand it, and it won't show up in the agenda.

The last archive command is C-c C-x C-A, and it keeps the archived items in the same file, but moves the archived item into a separate headline. This keeps your file cleaner without needing to move the completed todos to a different file if that is more desirable to you.

These three methods are somewhat analogous to the way CSS works for web pages: you can style anywhere in the .html file using an attribute, use a style tag to keep styling separate but still in the same file, or keep it completely separate in a linked file.

To invoke org-archive-to-archive-sibling automatically when marking as done:

(add-hook 'org-after-todo-state-change-hook
          (lambda () (when (equal "DONE" org-state)
                       (call-interactively #'org-archive-to-archive-sibling))))
labyrinth
  • 13,397
  • 7
  • 35
  • 44
  • 5
    Can I make C-c C-x C-A be invoked automatically when I mark the item as Done? – AlwaysLearning Aug 23 '15 at 07:10
  • 2
    I'm sure it could be done since Emacs is awesome at this kind of thing, but I went back to pure vim after using Emacs exclusively for 3 years. I hope someone else will answer your question, but I've been away from it for too long. – labyrinth Aug 24 '15 at 20:56