[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b4c4a7f 011/184: swiper.el (swiper--isearch-next-item): Ex
From: |
Oleh Krehel |
Subject: |
[elpa] master b4c4a7f 011/184: swiper.el (swiper--isearch-next-item): Extract |
Date: |
Wed, 16 Oct 2019 13:14:40 -0400 (EDT) |
branch: master
commit b4c4a7ff0f0850686992915eb09ebaf3e03ac4f4
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper--isearch-next-item): Extract
Re #2154
Re #2155
---
swiper.el | 54 ++++++++++++++++++++++++++----------------------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/swiper.el b/swiper.el
index f5a09dc..ea3d145 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1301,50 +1301,48 @@ See `ivy-format-functions-alist' for further
information."
(defvar swiper--isearch-start-point nil)
(defun swiper--isearch-function-1 (re backward)
- (let ((idx 0)
- cands idx-found)
+ (let (cands)
(save-excursion
(goto-char (if backward (point-max) (point-min)))
(while (funcall (if backward #'re-search-backward #'re-search-forward)
re nil t)
(when (swiper-match-usable-p)
- (unless idx-found
- (when (if backward
- (or (<= (match-end 0) swiper--isearch-start-point)
- (and (< (match-beginning 0)
swiper--isearch-start-point)
- (let ((mb-match
- (string-match-p
- re
- (buffer-substring-no-properties
- (match-beginning 0)
- swiper--isearch-start-point))))
- (eq mb-match 0))))
- (>= (match-beginning 0) swiper--isearch-start-point))
- (setq idx-found idx)))
- (cl-incf idx)
(let ((pos (if (or backward swiper-goto-start-of-match)
(match-beginning 0)
(point))))
(push pos cands)))))
- (cons
- (if idx-found
- (if backward
- (- (length cands) idx-found 1)
- idx-found)
+ (if backward
+ cands
+ (nreverse cands))))
+
+(defun swiper--isearch-next-item (re cands)
+ (if swiper--isearch-backward
+ (or
+ (cl-position-if
+ (lambda (x)
+ (and
+ (< x swiper--isearch-start-point)
+ (eq 0 (string-match-p
+ re
+ (buffer-substring-no-properties
+ x swiper--isearch-start-point)))))
+ cands
+ :from-end t)
0)
- (if backward
- cands
- (nreverse cands)))))
+ (or
+ (cl-position-if
+ (lambda (x) (> x swiper--isearch-start-point))
+ cands)
+ 0)))
(defun swiper--isearch-function (str)
(let ((re-full (funcall ivy--regex-function str)))
(unless (equal re-full "")
(let* ((case-fold-search (ivy--case-fold-p str))
(re (ivy-re-to-str re-full))
- (res (swiper--isearch-function-1 re swiper--isearch-backward))
- (idx-found (car res))
- (cands (cdr res)))
+ (cands (swiper--isearch-function-1 re swiper--isearch-backward))
+ (idx (swiper--isearch-next-item re cands)))
(setq ivy--old-re re)
- (ivy-set-index idx-found)
+ (ivy-set-index idx)
(setq ivy--old-cands cands)))))
(defcustom swiper-isearch-highlight-delay '(2 0.2)
- [elpa] master 0a9fb0c 009/184: swiper.el (swiper--isearch-function): Refactor, (continued)
- [elpa] master 0a9fb0c 009/184: swiper.el (swiper--isearch-function): Refactor, Oleh Krehel, 2019/10/16
- [elpa] master f0ec850 005/184: swiper.el (swiper-isearch): Fix for ivy-resume, Oleh Krehel, 2019/10/16
- [elpa] master 2a036b8 002/184: swiper.el (swiper--isearch-function): Change., Oleh Krehel, 2019/10/16
- [elpa] master ad0f605 008/184: swiper.el (swiper--isearch-function-1): Extract, Oleh Krehel, 2019/10/16
- [elpa] master dc7f5e0 012/184: swiper.el (swiper--isearch-function): Works for ivy--regex-ignore-order, Oleh Krehel, 2019/10/16
- [elpa] master 50ead7e 013/184: ivy-test.el (swiper-thing-at-point): Add and fix test, Oleh Krehel, 2019/10/16
- [elpa] master ec3e062 034/184: counsel (counsel-file-jump): Use temp buffer instead of split-string, Oleh Krehel, 2019/10/16
- [elpa] master 13be8ab 004/184: ivy.el (ivy--reset-state): Fix ivy-resume, Oleh Krehel, 2019/10/16
- [elpa] master 039353d 007/184: ivy.el (ivy--preselect-index): Fix ivy-resume for swiper-isearch, Oleh Krehel, 2019/10/16
- [elpa] master c7ffd06 016/184: swiper.el (swiper-isearch-action): Make ivy-previous-line-or-history work, Oleh Krehel, 2019/10/16
- [elpa] master b4c4a7f 011/184: swiper.el (swiper--isearch-next-item): Extract,
Oleh Krehel <=
- [elpa] master b9f3e3b 017/184: swiper.el (swiper-isearch-action): Simplify, Oleh Krehel, 2019/10/16
- [elpa] master 38b5d83 015/184: swiper.el (swiper--isearch-filter-ignore-order): Extract, Oleh Krehel, 2019/10/16
- [elpa] master 5f99723 019/184: counsel.el (counsel--async-last-command): Add for ease of debugging, Oleh Krehel, 2019/10/16
- [elpa] master fb486d8 024/184: ivy.el (ivy-immediate-done): Add copy-sequence to fix read-directory-name, Oleh Krehel, 2019/10/16
- [elpa] master f71f89a 029/184: ivy-test.el (ivy-swiper-wgrep): Expect fail on <=24.3, Oleh Krehel, 2019/10/16
- [elpa] master 230137b 047/184: ivy.el (ivy-restrict-to-matches): Work for dynamic collection, Oleh Krehel, 2019/10/16
- [elpa] master c3bd60c 041/184: ivy.el (ivy--occur-press-update-window): Don't error if buffer was killed, Oleh Krehel, 2019/10/16
- [elpa] master 6bf2cba 053/184: ivy.el (ivy-read-action-ivy): Don't recur, Oleh Krehel, 2019/10/16
- [elpa] master 1a4ebda 048/184: Allow virtual-buffers customization, Oleh Krehel, 2019/10/16
- [elpa] master b4af1a6 040/184: swiper.el (swiper-recenter-top-bottom): Works for swiper-isearch, Oleh Krehel, 2019/10/16