-
-
Notifications
You must be signed in to change notification settings - Fork 338
Closed
Description
i did some hacking and was able to get a prototype working with flx. here's what it looks like so far:
(setq ivy-sort-functions-alist '((t . nil)))
(setq my-ivy-cache (flx-make-string-cache))
(defun ivy--filter (name candidates)
(if (> (length name) 0)
(let ((scores))
(setq scores (mapcar (lambda (e)
(let ((score (flx-score e ivy-text my-ivy-cache)))
`(,e . ,score))) candidates))
(setq scores (cl-delete-if-not (lambda (e) (cdr e)) scores))
(setq scores (cl-sort scores (lambda (a b)
(let ((score1 (cdr a))
(score2 (cdr b)))
(> (car score1) (car score2))))))
(mapcar (lambda (e) (car e)) scores))
candidates))
what i did was a brute-force approach...and it will break other functionality like auto-selecting the previous selection. i'm curious to see how to better integrate into ivy. worthy of note is that there is a (flx-make-filename-cache)
which is optimized for files, so the algorithm would need to be applied differently depending on the source.
any help is appreciated. thanks!
Metadata
Metadata
Assignees
Labels
No labels