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

Expand DSL so we can check timestamps on specific properties #438

Open
Trevoke opened this issue Jun 24, 2024 · 1 comment
Open

Expand DSL so we can check timestamps on specific properties #438

Trevoke opened this issue Jun 24, 2024 · 1 comment

Comments

@Trevoke
Copy link

Trevoke commented Jun 24, 2024

OS/platform

Linux

Emacs version and provenance

29 - compiled from source

Org version and provenance

9.7.5 - from elpa

org-ql package version and provenance

0.8.6 - melpa

Description

I would love to be able to write something like this:

;; find all headings with CUSTOM_PROP where the value is a timestamp in the past
(org-ql-search (org-agenda-files)
      '(property :CUSTOM_PROP '(ts-active :to :today)))

I know I can write custom code to match presence of CUSTOM_PROP and then do precise validation but I think it would be amazing if I could do this all within org-ql's DSL!

Etc.

No response

@alphapapa
Copy link
Owner

alphapapa commented Jun 24, 2024

That's not a bad idea. It would be somewhere more than trivial but less than difficult to implement. I don't expect to have the time to work on this myself anytime soon.

In the meantime, it wouldn't take much code to do this now. Here are a couple of examples:

(org-ql-select BUFFERS
  `(when-let ((ts (property :CUSTOM_PROP)))
     (ts< (ts-parse-org ts) ,(ts-fill (ts-parse "2024-07-01")))))

;; With a custom predicate:

(org-ql-defpred property-ts< (property greater-ts)
  "Docstring."
  :body (when-let ((ts-value (org-entry-get nil property)))
          (ts< (ts-parse-org ts-value) greater-ts)))

(org-ql-select BUFFERS
  `(property-ts< :CUSTOM_PROP ,(ts-fill (ts-parse "2024-07-01"))))

@alphapapa alphapapa added this to the Future milestone Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants