Change: (children, descendants) Return after finding one match

A simple optimization that can be significant in large subtrees.
This commit is contained in:
Adam Porter 2019-08-30 09:32:03 -05:00
parent e839397579
commit 802bc462d6

View file

@ -661,8 +661,12 @@ Or, when possible, fix the problem."
(funcall ,query)))
(t `(and (level ,level)
,query)))))
(catch 'found
(org-ql-select (current-buffer)
query :narrow t :action (lambda () t)))))))
query
:narrow t
:action (lambda ()
(throw 'found t)))))))))
(org-ql--defpred descendants (query)
"Return non-nil if current entry has descendants matching QUERY."
@ -670,8 +674,12 @@ Or, when possible, fix the problem."
(save-restriction
(org-narrow-to-subtree)
(when (org-goto-first-child)
(catch 'found
(org-ql-select (current-buffer)
query :narrow t :action (lambda () t))))))
query
:narrow t
:action (lambda ()
(throw 'found t))))))))
(org-ql--defpred category (&rest categories)
"Return non-nil if current heading is in one or more of CATEGORIES (a list of strings)."