I’d like to create a custom agenda search which will find TODO items based on time entries in the LOGBOOK. Specifically, I’d like to find items tagged WAITING based on the timestamp which marked the entry to the waiting state. These entries look like this:
:LOGBOOK:
- State "WAITING" from "TODO" [2011-11-02 Wed 15:10] \\
Emailed so-and-so about such-and-such.
:END:
Can I do this with the information in the logbook? I’m using version 7.5 but can upgrade if necessary.
Thanks!
Edit: One use case might be to find WAITING todo’s which have been the waiting state for more than a week. (Which usually means I need to bug somebody again.)
The following should do what you need. You’ll simply have to adjust the Custom Agenda commands to fit your use-case. (When testing and configuring it I used my TODO keywords). It is possible that one portion of this code duplicates the work of a built-in org function, particularly since it resembles the Scheduled and Deadline approach/overdue behaviour, yet I could not see any specific function that would be reusable.
The actual function to use in the custom command follows.
The following function finds logbook entries through re-search-forward.
The last function determines the number of days difference between today and the timestamp found by the above function.
Two sample custom agenda commands using the above functions. The first matches up to your use-case, you’ll simply have to change “PEND” to “WAITING” for it to match the right keyword. The second looks for DONE keywords that were completed more than 30 days ago (As opposed to looking for timestamps that have a month matching this/last month as done in the example I’d linked in my first comment).