Skip to content

Commit fbbc8b3

Browse files
committed
Various sequence fixes in Swiper
* swiper.el (swiper--avy-candidates, swiper-all-function): Prefer cl-delete over cl-remove on fresh sequences. (swiper--re-builder, swiper--update-input-ivy): Use substring rather than regexp operations. (swiper--positive-regexps): Remove; replace all uses with ivy--positive-regexps.
1 parent 491a928 commit fbbc8b3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

swiper.el

+6-13
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ If the input is empty, select the previous history element instead."
302302
(cl-sort visible-overlays #'< :key #'overlay-start)))
303303
(min-overlay-start 0)
304304
(overlays-for-avy
305-
(cl-remove-if-not
305+
(cl-delete-if-not
306306
(lambda (ov)
307307
(when (and (>= (overlay-start ov)
308308
min-overlay-start)
@@ -781,7 +781,7 @@ Add a space after a leading `^' for `swiper', and apply
781781
This is the regex used in the minibuffer where candidates have
782782
line numbers. For the buffer, use `ivy--regex' instead."
783783
(let* ((re-builder (ivy-alist-setting ivy-re-builders-alist))
784-
(str (replace-regexp-in-string "\\\\n" "\n" str))
784+
(str (ivy--string-replace "\\n" "\n" str))
785785
(re (funcall re-builder str)))
786786
(if (consp re)
787787
(mapcar
@@ -948,24 +948,17 @@ the face, window and priority of the overlay."
948948
(or (display-graphic-p)
949949
(not recenter-redisplay)))
950950

951-
(defun swiper--positive-regexps ()
952-
(if (listp ivy-regex)
953-
(mapcar #'car (cl-remove-if-not #'cdr ivy-regex))
954-
(list ivy-regex)))
955-
956951
(defun swiper--update-input-ivy ()
957952
"Called when `ivy' input is updated."
958953
(with-ivy-window
959954
(swiper--cleanup)
960955
(when (> (length (ivy-state-current ivy-last)) 0)
961-
(let ((regexps (swiper--positive-regexps))
956+
(let ((regexps (ivy--positive-regexps))
962957
(re-idx -1)
963958
(case-fold-search (ivy--case-fold-p ivy-text)))
964959
(dolist (re regexps)
965960
(setq re-idx (1+ re-idx))
966-
(let* ((re (replace-regexp-in-string
967-
" " "\t"
968-
re))
961+
(let* ((re (ivy--string-replace " " "\t" re))
969962
(num (swiper--line-number (ivy-state-current ivy-last))))
970963
(unless (memq this-command '(ivy-yank-word
971964
ivy-yank-symbol
@@ -1272,7 +1265,7 @@ otherwise continue prompting for buffers."
12721265
"Search in all open buffers for STR."
12731266
(or
12741267
(ivy-more-chars)
1275-
(let* ((buffers (cl-remove-if-not #'swiper-all-buffer-p (buffer-list)))
1268+
(let* ((buffers (cl-delete-if-not #'swiper-all-buffer-p (buffer-list)))
12761269
(re-full ivy-regex)
12771270
re re-tail
12781271
cands match
@@ -1494,7 +1487,7 @@ that we search only for one character."
14941487
(lambda ()
14951488
(with-ivy-window
14961489
(swiper--add-overlays (ivy--regex ivy-text))))))
1497-
(dolist (re (swiper--positive-regexps))
1490+
(dolist (re (ivy--positive-regexps))
14981491
(swiper--add-overlays re))))
14991492

15001493
(defun swiper--isearch-candidate-pos (cand)

0 commit comments

Comments
 (0)