I've got an org file that looks like this:

* Project Cats
** Get them
*** TODO Find a tabby
*** DONE Find one that's orange
    CLOSED: [2016-11-08 Tue 15:32]
** Feed them
*** DONE Buy some food
    CLOSED: [2016-11-08 Tue 15:32]
*** TODO Put it in bowls

Is there a command that, with my cursor on the top headline, will archive everything marked as DONE that's a descendant? After running such a command, I'd expect to see this:

* Project Cats
** Get them
*** TODO Find a tabby
** Feed them
*** TODO Put it in bowls
  • The doc-string for org-archive-subtree states the options that are presently available -- M-x describe-function RET org-archive-subtree RET In particular, read about the prefix argument and see if that achieves the desired result.
    – lawlist
    Nov 9, 2016 at 2:35
  • @lawlist the prefix arguments to org-archive-subtree will examine only the direct children of the headline, and they will archive a child only if all tasks it contains are done. (Or all timestamps are in the past.) I want to examine anything that's a descendant of the headline, and I want to archive individual items marked as done.
    – DGrady
    Nov 9, 2016 at 16:03

3 Answers 3


I don't know of a single command, but the following sequence accomplishes this:

  1. C-c a to look at the agenda
  2. < < to restrict the agenda to the buffer and then to the current sub-tree
  3. M DONE to show everything matching a TODO keyword (search for DONE items in the current sub-tree)
  4. * to mark everything in the agenda (all DONE items in the current subtree).
  5. B $ to bulk archive everything you marked (i.e. everything)
  • Any insight into why there isn't a standard command to do this? I'm still learning org-mode and this seemed like a natural thing to do.
    – DGrady
    Nov 10, 2016 at 19:35
  • 2
    @DGrady Just guessing, but probably nobody asked for it. There are so many ways to use org-mode that they can't account for all of them. So instead they provide basic building blocks: agendas, filters, bulk actions. You can put those together into anything you need.
    – erikstokes
    Nov 10, 2016 at 23:11

On my e-macs using iTerm2 and macOS it is not exactly the same sequence to archive all the done tasks (in a whole given doc):

  • C-c a to display the agenda
  • T DONE to match all entries with the keyword DONE
  • * to mark them all
  • B $ to archive

Based on Robert's Answer

(require 'org)
(require 'org-archive)
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook 'org-archive-all-done nil t)))
  • FWIW: It's generally better not to use anonymous functions (lambdas) on hooks. A named function is easier to remove, for example. Function comparison is problematic; symbol comparison is not.
    – Drew
    Nov 17, 2022 at 17:12
  • Thanks, I'm noob and learning everyday about emacs and lisp, I didn't knew this, feel free to edit the answer with a named function.
    – nitin
    Nov 29, 2022 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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