3

When I complete a task and move its todo state to "Done", it adds the date the task was completed. Later during the weekend, I might archive these "Done" tasks so that they are moved into an .org_archive file.

I would like to view these archived tasks in a few different ways, namely by project structure and by completion date.

Suppose I have a project like this:

** TODO My Project
*** TODO Task 1
*** TODO Task 2

Let's say I complete Task 1, and then Task 2, which also completes the entire project. In my archive file, I would have something like this:

* DONE Task 1
  CLOSED: [some date]
  :PROPERTIES:...
* DONE Task 2
  CLOSED: [some date]
  :PROPERTIES:...
* DONE My Project
  CLOSED: [some date]
  :PROPERTIES:...

This is useful for keeping a log of archived items, usually sorted by completion date. However, if completing Task 2 takes place several months after Task 1, it becomes difficult to recall what project Task 1 and 2 belong to.

Is there a way to "sort" the archive file such that I could view it both as a completion log (sorted by "CLOSED" date), as well as sorting the file as to retain the project structure, e.g.

** DONE My Project
   CLOSED: [some date]
   :PROPERTIES:...
*** DONE Task 1
    CLOSED: [some date]
    :PROPERTIES:...
*** DONE Task 2
    CLOSED: [some date]
    :PROPERTIES:...
  • Would you prefer an *Org Agenda* view that displays select portions of org-mode files based upon a particular search criteria (without modifying the underlying file(s) in any manner whatsoever); or, would you rather manipulate the org-mode file(s) using something like org-sort-entries and a custom function (as alluded to in the doc-string) of said function? – lawlist Aug 4 '16 at 0:33
  • @lawlist Either will do, though I'm intrigued by the org agenda view solution. So long as I can view the archive file in both ways (structured/in-context and by closed date), either will likely work. – wiuah Aug 4 '16 at 3:00
  • @lawlist Have any ideas on how this would be done? – wiuah Aug 9 '16 at 18:38
  • You can place your cursor on a main tasks (with subtasks underneath) and type M-x org-sort-entries and then select t for time. Or, you can highlight the tasks to be sorted so that the region is selected and then do the same thing -- i.e., M-x org-sort-entries and then select t for time. When archiving or re-filing, you can select (or create if necessary) headings as targets so that your tasks are not strewn all over the place. You can even have an automatic sort after archiving using (org-sort-entries . . .) with the appropriate argument. – lawlist Aug 9 '16 at 20:37
  • See also Keeping the context when archiving in Emacs org-mode: stackoverflow.com/questions/10143959/… – lawlist Aug 9 '16 at 20:57

Your Answer

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

Browse other questions tagged or ask your own question.