Fix: (--select) Don't iterate over every heading with preamble

Oops, using "when" instead of "while" did outline-next-heading even
when re-search-forward found no more matches.  That unnecessarily
slowed down some searches, negating almost all of the gains.
This commit is contained in:
Adam Porter 2019-07-25 07:51:28 -05:00
parent 81ef7adbca
commit b5ccc3294e

View file

@ -404,10 +404,11 @@ If NARROW is non-nil, buffer will not be widened."
(goto-char (point-min)) (goto-char (point-min))
(when (org-before-first-heading-p) (when (org-before-first-heading-p)
(outline-next-heading)) (outline-next-heading))
(cond (preamble-re (cl-loop when (and (when (re-search-forward preamble-re nil t) ;; `cl-loop' makes this double-while much clearer than the expanded form.
(outline-back-to-heading 'invisible-ok) (cond (preamble-re (cl-loop while (and (when (re-search-forward preamble-re nil t)
t) (outline-back-to-heading 'invisible-ok)
(funcall predicate)) t)
(funcall predicate))
collect (funcall action) collect (funcall action)
while (outline-next-heading))) while (outline-next-heading)))
(t (cl-loop when (funcall predicate) (t (cl-loop when (funcall predicate)