Based on the agenda view of Org mode it is possible to perform actions on a selection of headlines. This can be used to clean up the tasks list so that it stays current.

Spacemacs with example Org file

Spacemacs showing the example Org file.

Use the agenda view to bulk archive

Here is a quick list how to use it:

  • Go to the parent headline which contains the tasks: g h
  • Open up the agenda dispatcher: , a
  • Restrict to the current subtree: < <
  • Get the tasks with a specific TODO keyword: T
  • Choose DONE
  • Go through the tasks, flag the ones you want to archive with m for a bulk action
  • Use B $ to bulk archive the selected tasks

A small example

The following walk-trough is based on a very small example file to show how the different bits works together.

Example setup

Example structure of a simple Org file to track tasks:

* Tasks
  :PROPERTIES:
  :ARCHIVE:  %s_archive::* Archived Tasks
  :END:
** TODO Task A
** TODO Task B
** TODO Task C
** TODO Task D

At the end of a month

Over time the tasks change into the state DONE and new tasks tend to be added into the list:

* Tasks
  :PROPERTIES:
  :ARCHIVE:  %s_archive::* Archived Tasks
  :END:
** DONE Task A
** DONE Task B
** TODO Task C
** TODO Task D
** TODO A new task E
** TODO Another new task F

After the cleanup

After the cleanup, the file my-tasks.org should look like the following:

* Tasks
  :PROPERTIES:
  :ARCHIVE:  %s_archive::* Archived Tasks
  :END:
** TODO Task C
** TODO Task D
** TODO A new task E
** TODO Another new task F

And a new file called my-tasks.org_archive should be created:

#    -*- mode: org -*-


Archived entries from file /Users/johannes/tmp/org-exp/my-tasks.org


* Archived Tasks

** DONE Task A
   :PROPERTIES:
   :ARCHIVE_TIME: 2017-01-02 Mon 19:41
   :ARCHIVE_FILE: ~/tmp/org-exp/my-tasks.org
   :ARCHIVE_OLPATH: Tasks
   :ARCHIVE_CATEGORY: my-tasks
   :ARCHIVE_TODO: DONE
   :END:

** DONE Task B
   :PROPERTIES:
   :ARCHIVE_TIME: 2017-01-02 Mon 19:41
   :ARCHIVE_FILE: ~/tmp/org-exp/my-tasks.org
   :ARCHIVE_OLPATH: Tasks
   :ARCHIVE_CATEGORY: my-tasks
   :ARCHIVE_TODO: DONE
   :END:

Alternatives

Org mode has a very similar command called org-archive-subtree which can be used to achieve a similar result for the example case above. After going to the parent headline, pressing SPC u , A will start the command with the universal argument.


Comments

comments powered by Disqus