Remove ivy-{standard,alternative}-search #2314

Turns out ivy and counsel have a number of hard-coded checks for flx
against ivy--regex-fuzzy:

- https://github.com/abo-abo/swiper/blob/master/ivy.el#L3531
- https://github.com/abo-abo/swiper/blob/master/ivy.el#L3637
- https://github.com/abo-abo/swiper/blob/master/ivy.el#L4643
- https://github.com/abo-abo/swiper/blob/master/counsel.el#L1359
- https://github.com/abo-abo/swiper/blob/master/counsel.el#L1561

This means, by assigning our own delegates around ivy regex functions
will break flx sorting (reported in #2314), and possibly other behavior.
This commit is contained in:
Henrik Lissner 2020-01-06 01:29:22 -05:00
parent 9fce4d5106
commit ae8dc2749f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 18 additions and 34 deletions

View file

@ -13,16 +13,6 @@
(and (not (eq buffer (current-buffer))) (and (not (eq buffer (current-buffer)))
(+workspace-contains-buffer-p buffer)))) (+workspace-contains-buffer-p buffer))))
;;;###autoload
(defun +ivy-standard-search (str)
"TODO"
(funcall +ivy-standard-search-fn str))
;;;###autoload
(defun +ivy-alternative-search (str)
"TODO"
(funcall +ivy-alternative-search-fn str))
;;;###autoload ;;;###autoload
(defun +ivy-rich-buffer-name (candidate) (defun +ivy-rich-buffer-name (candidate)
"Display the buffer name. "Display the buffer name.

View file

@ -14,21 +14,6 @@ When 'everything, also preview virtual buffers")
"A plist mapping ivy/counsel commands to commands that generate an editable "A plist mapping ivy/counsel commands to commands that generate an editable
results buffer.") results buffer.")
(defvar +ivy-standard-search-fn
(if (featurep! +prescient)
#'+ivy-prescient-non-fuzzy
#'ivy--regex-plus)
"Function to use for non-fuzzy search commands.
This uses the standard search algorithm ivy uses (or a variant of it).")
(defvar +ivy-alternative-search-fn
(cond ((featurep! +prescient) #'ivy-prescient-re-builder)
((featurep! +fuzzy) #'ivy--regex-fuzzy)
;; Ignore order for non-fuzzy searches by default
(#'ivy--regex-ignore-order))
"Function to use for fuzzy search commands.
This uses a search algorithm other than ivy's default.")
;; ;;
;;; Packages ;;; Packages
@ -36,15 +21,24 @@ This uses a search algorithm other than ivy's default.")
(use-package! ivy (use-package! ivy
:after-call pre-command-hook :after-call pre-command-hook
:init :init
(setq ivy-re-builders-alist (let ((standard-search-fn
`((counsel-rg . +ivy-standard-search) (if (featurep! +prescient)
(swiper . +ivy-standard-search) #'+ivy-prescient-non-fuzzy
(swiper-isearch . +ivy-standard-search) #'ivy--regex-plus))
(t . +ivy-alternative-search)) (alt-search-fn
ivy-more-chars-alist (cond ((featurep! +prescient) #'ivy-prescient-re-builder)
'((counsel-rg . 1) ((featurep! +fuzzy) #'ivy--regex-fuzzy)
(counsel-search . 2) ;; Ignore order for non-fuzzy searches by default
(t . 3))) (#'ivy--regex-ignore-order))))
(setq ivy-re-builders-alist
`((counsel-rg . ,standard-search-fn)
(swiper . ,standard-search-fn)
(swiper-isearch . ,standard-search-fn)
(t . ,alt-search-fn))
ivy-more-chars-alist
'((counsel-rg . 1)
(counsel-search . 2)
(t . 3))))
(define-key! (define-key!
[remap switch-to-buffer] #'+ivy/switch-buffer [remap switch-to-buffer] #'+ivy/switch-buffer