alphapapa / org-ql

A searching tool for Org-mode, including custom query languages, commands, saved searches and agenda-like views, etc.
GNU General Public License v3.0
1.42k stars 110 forks source link

Design and document predicates that return values #122

Open dsdshcym opened 4 years ago

dsdshcym commented 4 years ago

I wanted to know how many tasks in my org files are closed on the same day as they were scheduled.

I then tried (closed :on scheduled) but it didn't work as I expected (the where clause didn't filter out anything).

So I'm wondering if it's possible to use data from heading in the query expression? If so, org-ql can really become more powerful and help me analyze my notes/tasks:

Finally, thanks for this great package!!!

alphapapa commented 4 years ago

Some predicates do return the values they test. That's not formally documented or designed yet, but it would be good to do so in the future.

I don't remember if (closed) and (scheduled) do. If they do, you could do something like (org-ql-select FILES '(equal (closed) (scheduled))), however that would likely include the hour-minute timestamp, which wouldn't work for testing the day. So you'd probably need to convert the Org timestamp strings to timestamps and compare the difference (you could use the ts library, which org-ql uses internally).

Thanks for the kind words. I'm glad it's useful to you.

dsdshcym commented 4 years ago

I tried '(equal (ts-parse-org (closed)) (ts-parse-org (scheduled))), but ran into an error (wrong-type-argument stringp 1642)

I think it's because (closed) doesn't return the org timestamp, right?

Well, we don't need to figure out how to do it currently. I just hope this feature can be added to the project roadmap, so we can use an formally supported version of it.