Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add predicate for checking DONE state changes #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

teeann
Copy link

@teeann teeann commented Aug 20, 2021

This PR fixes issue #192
Apart from the regex, every other added code is almost copied/pasted.
Further improvements are welcome

Copy link
Owner

@alphapapa alphapapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@@ -60,6 +60,11 @@
Like `org-clock-line-re', but matches the timestamp range in a
match group.")

(defconst org-ql-log-done-regexp
(rx bol "- State \"DONE\"" (1+ blank) "from \"WAITING\"" (1+ blank) (group (1+ not-newline)))
;; TODO: Remove hardcoded states, i.e DONE & WAITING
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This todo should be fixed before merging. So the regexp, rather than matching DONE from WAITING, should probably match an arbitrary state from an arbitrary state, so the predicate could work like (logbook-state "DONE") or (logbook-state "DONE" "WAITING").

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me with this @alphapapa ?
I've tried adding these arguments to the predicate, but don't know how to change the preambles and normalizers part.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are pcase forms. Pcase isn't the easiest tool to learn, but it's very powerful. I'll take a look at this when I get time, but that may not be for a while, so don't be afraid to dive in to Pcase's documentation in the meantime.

@@ -60,6 +60,11 @@
Like `org-clock-line-re', but matches the timestamp range in a
match group.")

(defconst org-ql-log-done-regexp
(rx bol "- State \"DONE\"" (1+ blank) "from \"WAITING\"" (1+ blank) (group (1+ not-newline)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think logbooks always use the - character as their bullet character, but we should make sure of that before merging.

@@ -1969,6 +1974,24 @@ ignored."
:body
(org-ql--predicate-ts :from from :to to :regexp org-ql-clock-regexp :match-group 1))

(org-ql-defpred log-done (&key from to _on)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate should probably be named something like logbook-state so it could be more flexible.

@alphapapa
Copy link
Owner

Also please note that this feature will need tests and documentation before being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants