branch: master commit 38b5d833fe49fdb537e21888d73833375c5a6ca5 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
swiper.el (swiper--isearch-filter-ignore-order): Extract --- swiper.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/swiper.el b/swiper.el index b437b2d..0f6aa39 100644 --- a/swiper.el +++ b/swiper.el @@ -1338,6 +1338,20 @@ See `ivy-format-functions-alist' for further information." cands) 0))) +(defun swiper--isearch-filter-ignore-order (re-full cands) + (let (filtered-cands) + (dolist (re-cons re-full) + (save-excursion + (dolist (cand cands) + (goto-char cand) + (beginning-of-line) + (unless (if (re-search-forward (car re-cons) (line-end-position) t) + (not (cdr re-cons)) + (cdr re-cons)) + (push cand filtered-cands)))) + (setq cands (nreverse filtered-cands)) + (setq filtered-cands nil)))) + (defun swiper--isearch-function (str) (let ((re-full (funcall ivy--regex-function str))) (unless (equal re-full "") @@ -1348,18 +1362,7 @@ See `ivy-format-functions-alist' for further information." (regexp-opt (delq nil (mapcar (lambda (x) (and (cdr x) (car x))) re-full))))) (cands (swiper--isearch-function-1 re swiper--isearch-backward))) (when (consp re-full) - (let (filtered-cands) - (dolist (re-cons re-full) - (save-excursion - (dolist (cand cands) - (goto-char cand) - (beginning-of-line) - (unless (if (re-search-forward (car re-cons) (line-end-position) t) - (not (cdr re-cons)) - (cdr re-cons)) - (push cand filtered-cands)))) - (setq cands (nreverse filtered-cands)) - (setq filtered-cands nil)))) + (setq cands (swiper--isearch-filter-ignore-order re-full cands))) (setq ivy--old-re re) (ivy-set-index (swiper--isearch-next-item re cands)) (setq ivy--old-cands cands)))))