From cd4f3cc99b57eb54ab74b48e29e959d2f2cc0805 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 9 Aug 2019 17:07:49 -0500 Subject: [PATCH] Add: (scheduled) preamble --- notes.org | 26 ++++++++++++++++++++++++++ org-ql.el | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/notes.org b/notes.org index 7f834e0..8397172 100644 --- a/notes.org +++ b/notes.org @@ -508,6 +508,32 @@ Not sure if clearing the cache is necessary here, because it seemed to make near | preamble: (property "agenda-group" "plans") | 72.54 | 0.016862 | 0 | 0 | | no preamble: (property "agenda-group" "plans") | slowest | 1.223197 | 0 | 0 | +*** =scheduled= + +#+BEGIN_SRC elisp + (org-ql-preamble-bench :times 1 + :file "~/org/inbox.org" + :query (scheduled)) +#+END_SRC + +#+RESULTS: +| Form | x faster than next | Total runtime | # of GCs | Total GC runtime | +|--------------------------+--------------------+---------------+----------+------------------| +| preamble: (scheduled) | 4.45 | 0.100968 | 0 | 0 | +| no preamble: (scheduled) | slowest | 0.449321 | 0 | 0 | + +#+BEGIN_SRC elisp + (org-ql-preamble-bench :times 1 + :file "~/org/inbox.org" + :query (scheduled <= "2019-01-01")) +#+END_SRC + +#+RESULTS: +| Form | x faster than next | Total runtime | # of GCs | Total GC runtime | +|------------------------------------------+--------------------+---------------+----------+------------------| +| preamble: (scheduled <= "2019-01-01") | 4.13 | 0.111067 | 0 | 0 | +| no preamble: (scheduled <= "2019-01-01") | slowest | 0.458726 | 0 | 0 | + *** =tags= If tag inheritance is enabled, we have to check tags on every heading. When it's disabled, we can search directly to headings with the given tags. diff --git a/org-ql.el b/org-ql.el index 0a9f431..0cdaa2c 100644 --- a/org-ql.el +++ b/org-ql.el @@ -375,6 +375,15 @@ replace the clause with a preamble." ;; (setq org-ql-preamble (rx-to-string `(seq bol (0+ space) ":" (1+ (not (or space ":"))) ":" ;; (1+ space) (minimal-match (1+ not-newline)) eol))) ;; element) + (`(scheduled . ,_) + (setq org-ql-preamble + (rx-to-string `(seq bol (0+ (any " ")) "SCHEDULED" ":" (1+ space) (1+ not-newline)) t)) + ;; Return element, because the predicate still needs testing. + element) + (`(scheduled) + (setq org-ql-preamble (rx-to-string `(seq bol (0+ (any " ")) "SCHEDULED" ":") t)) + ;; Return element, because the predicate still needs testing. + element) ((and `(tags . ,tags) (guard (not org-use-tag-inheritance))) ;; When tag inheritance is disabled, we only consider direct tags, ;; so we can search directly to headings containing one of the tags.