View Single Post
Originally Posted by kingsinger View Post
Here's what I've got as far as the code I'm entering:
I've split it up to make it easier to comment on what I think's happening.

[1] ofexport
[2] -p 'note="#currentfocus"'
[3] -a flatten
[4] -t next
[5] -E -a done=any
[6] -E -t "name='Phase 2: Substantive Work'"
[7] -E -t "name='Phase 3: Tie up loose ends and close transaction'"
[8] -E -t "name='Phase 1: Admin'"
[9] -E -t "name='Document Drafting:'"
[10] -E -t "name='Document Review:'"
[11] -E -t "name='Invoice and Payment'"
[12] -E -t "name='Draft Remaining Formation Paperwork'"
[13] -C -a prune
[14] -t "sort due"
[15] -T flat
[16] -v
[17] --open -o ~/Desktop/x.txt

I think the tool is doing what it's "supposed" to do, but not what you want :-)

Sort Issue 1 - fixable:

[14] -t "sort due" --> -c "sort due"

The sort feature works by sorting the contents of a structural item. Here you want the contents of contexts sorted so you'd use -c "sort due". This might seem needlessly weird - but I did start out by specifying the items you wanted TO BE sorted, but it didn't work at the conceptual level. The problem is that Folders can contain Sub-Folders AND Projects and Context can contain Sub-Contexts AND Tasks. To say that you want a particular type in sort order doesn't cover the case where two types are mixed in the same list.

Sort Issue 2 - Not so fixable:

[15] -T flat

So with the first problem sorted it's all ok? Well no. By the time we get to 15 you should have all your tasks organised into contexts and all the tasks within them sorted by due. However the flat template simply omits the parent contexts in the output, the internal structure remains. So what you'd see would be blocks of tasks in sort order but then a discontinuity as it jumped to the next context.

In hindsight the "flat" template is a bit of a hack, I think what's required is a filter like the flatten filter but that pulls all the tasks up to the root in the model so that the other filters (like sort) can do their thing on that.

I might have a look at that, it would seem to be quite useful and avoids the need for template hackery.