After studying the User Guide’s part about search syntax it seems like a bug to me, that TaskPaper always requires a start index in slices. So neither */not @done[:]
nor */not @done[:1]
works, but */not @done[0:]
or */not @done[0:1]
does the job without fuss. Maybe someone can help me to understand how slicing works in searches.
I think that most people don’t use some of those queries and that is the reason some things are never asked. I think @jessegrosjean is the best person to answer that question. I also think that there are easier or more natural ways to accomplish things without using slices the way you do.
Looking at https://github.com/jessegrosjean/birch-outline/blob/master/src/item-path-parser.pegjs reveals that the start index is indeed required:
Slice
= '[' start:Integer end:SliceEnd? ']' {
return {
start: start === null ? 0 : start,
end: end
}
}
Maybe it should be something like
Slice
= '[' start:Integer? end:SliceEnd? ']' {
return {
start: start === null ? 0 : start,
end: end
}
}
(note the question mark after Integer
).
Sorry for the slow reply. I think you are probably right, I’ve added this to the issue tracker. I don’t think this is really limiting functionality… let me know if I’m wrong on that… if that’s the case then I don’t expect to fix this in the near term. I’m busy working on the WriteRoom update at the moment, so that’s where I’m focused right now.
Actually, I just want to know what slices can be good for. Besides the example in the User’s Guide about finding the next (or next available) action, I couldn’t find yet any other practical use case for that. However, I would be very interested if anybody can post some real-life examples how he or she uses slices to resolve particular searching tasks.
I think that case is really the main one… that type of query wasn’t possible with existing syntax, so I needed to add an additional syntax to somehow allow selecting just the first item of a list of results. When trying to decide on what that syntax would look like I was introduced to pythons slice syntax for arrays. I decided to use that because it did what I wanted, but was more powerful, and somewhat standard (at least it’s been designed and used for years). So that’s why I adopted the slice syntax, but in day-to-day TaskPaper use it’s probably more flexible then is really needed.
Speaking about searching for next available action I want to introduce the solution I came up with when I wanted to mimic the OmniFocus behavior for sequential and parallel projects.
From OmniFocus User’s Manual: Sequential projects have actions that need to be completed in a predetermined order. The first action needs to be completed before you can move on to the next. Parallel projects consist of actions that can be completed in any order. In a parallel project, all incomplete actions are available.
In TaskPaper 3 you can mimic this behavior by tagging sequential projects with @seq
and searching for available tasks using the following syntax:
@seq//not @done[0] union not @seq//not @done intersect @type=task except @done//*
Tasks beyond the first available (not done) task in a sequential project are blocked, and will therefore not be shown. In parallel projects (those not tagged with @seq
) all incomplete tasks will be displayed.
Here is an example document consisting of one sequential (Conference) and one parallel (Project meeting) project:
Conference: @seq
- Submit abstract @done(2017-01-01)
- Register to the conference
- Book a hotel room
- Book a flight
- Prepare presentation slides
Project meeting:
- Select and invite participants @done(2017-07-10)
- Prepare and distribute meeting agenda
- Book conference room
- Print handouts for attendees
Querying the document using the above-mentioned search syntax will give you:
Conference: @seq
- Register to the conference
Project meeting:
- Prepare and distribute meeting agenda
- Book conference room
- Print handouts for attendees
Wow. That is amazing. I have been using TaskPaper as a database of sorts and I need to figure who to use what I just learned. I think that most people will read that and will not be able to understand it without a couple of examples. Thank you for the idea.
I added an example to my post above. Hope it will be useful for others.
Too bad it doesn’t work with nested projects… otherwise it was really cool