diff --git a/org-ql.el b/org-ql.el index 1764efb..3c323d2 100644 --- a/org-ql.el +++ b/org-ql.el @@ -416,12 +416,11 @@ If NARROW is non-nil, buffer will not be widened." (when (org-before-first-heading-p) (outline-next-heading)) ;; `cl-loop' makes this double-while much clearer than the expanded form. - (cond (preamble-re (cl-loop while (and (when (re-search-forward preamble-re nil t) - (outline-back-to-heading 'invisible-ok) - t) - (funcall predicate)) + (cond (preamble-re (cl-loop while (re-search-forward preamble-re nil t) + do (outline-back-to-heading 'invisible-ok) + when (funcall predicate) collect (funcall action) - while (outline-next-heading))) + do (outline-next-heading))) (t (cl-loop when (funcall predicate) collect (funcall action) while (outline-next-heading))))))) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index afd2b02..0925ba6 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -459,7 +459,16 @@ Based on Buttercup macro `it'." (expect (org-ql test-buffer (ts :on "2019-06-09") :action (org-ql-test-org-get-heading)) - :to-equal nil))))) + :to-equal nil))) + + (describe "Compound queries" + + (org-ql-it "Tags and to-do" + (expect (org-ql test-buffer + (and (todo "SOMEDAY") + (tags "Emacs")) + :action (org-ql-test-org-get-heading)) + :to-equal '("Rewrite Emacs in Common Lisp")))))) ;; Local Variables: ;; truncate-lines: t