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,7 +404,8 @@ If NARROW is non-nil, buffer will not be widened."
(goto-char (point-min))
(when (org-before-first-heading-p)
(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.
(cond (preamble-re (cl-loop while (and (when (re-search-forward preamble-re nil t)
(outline-back-to-heading 'invisible-ok)
t)
(funcall predicate))