Change: (children, descendants) Return after finding one match
A simple optimization that can be significant in large subtrees.
This commit is contained in:
parent
e839397579
commit
802bc462d6
1 changed files with 12 additions and 4 deletions
16
org-ql.el
16
org-ql.el
|
|
@ -661,8 +661,12 @@ Or, when possible, fix the problem."
|
||||||
(funcall ,query)))
|
(funcall ,query)))
|
||||||
(t `(and (level ,level)
|
(t `(and (level ,level)
|
||||||
,query)))))
|
,query)))))
|
||||||
(org-ql-select (current-buffer)
|
(catch 'found
|
||||||
query :narrow t :action (lambda () t)))))))
|
(org-ql-select (current-buffer)
|
||||||
|
query
|
||||||
|
:narrow t
|
||||||
|
:action (lambda ()
|
||||||
|
(throw 'found t)))))))))
|
||||||
|
|
||||||
(org-ql--defpred descendants (query)
|
(org-ql--defpred descendants (query)
|
||||||
"Return non-nil if current entry has descendants matching QUERY."
|
"Return non-nil if current entry has descendants matching QUERY."
|
||||||
|
|
@ -670,8 +674,12 @@ Or, when possible, fix the problem."
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(org-narrow-to-subtree)
|
(org-narrow-to-subtree)
|
||||||
(when (org-goto-first-child)
|
(when (org-goto-first-child)
|
||||||
(org-ql-select (current-buffer)
|
(catch 'found
|
||||||
query :narrow t :action (lambda () t))))))
|
(org-ql-select (current-buffer)
|
||||||
|
query
|
||||||
|
:narrow t
|
||||||
|
:action (lambda ()
|
||||||
|
(throw 'found t))))))))
|
||||||
|
|
||||||
(org-ql--defpred category (&rest categories)
|
(org-ql--defpred category (&rest categories)
|
||||||
"Return non-nil if current heading is in one or more of CATEGORIES (a list of strings)."
|
"Return non-nil if current heading is in one or more of CATEGORIES (a list of strings)."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue