-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to disable prescient in counsel-find-file? #64
Comments
You could check to make sure the command you expect is being run, with |
Thank you @raxod502. The function being run is indeed It must be something with the way |
Yeah, I'm afraid I'm not sure what's happening there. It does sure seem like |
Yep. This is almost certainly an edge case. Here https://github.com/abo-abo/swiper/blob/d2891aab7b816aebf21ebd01ce33933a6ac6244f/ivy.el#L2271-L2317 there's an explicit call to |
I've managed to get file-name completion back to normal using this: (add-hook 'ivy-prescient-mode-hook
(defun ivy-prescient-disable-sort-find-file+ ()
(when (and (eq (car ivy-prescient-sort-commands) :not)
(memq 'counsel-find-file
(cdr ivy-prescient-sort-commands)))
(ivy--alist-set 'ivy-sort-functions-alist
#'read-file-name-internal #'ivy-sort-file-function-default)))) but it doesn't disable sorting based on |
Adopted the quickfix proposed in radian-software/prescient.el#64
Is there something similar to disable it for selectrum-prescient.el for certain commands? |
There's (defvar selectrum-find-file-keep-prescient-sorting+ nil
"When true, `selectrum-find-file' keeps sorting based on `prescient-sort' but
still tries to group directories before files..")
(defun selectrum-prescient-preprocess+ (func cands)
(cond
;; Finding file-names should sort directories first.
((eq minibuffer-completion-table 'read-file-name-internal)
(if selectrum-find-file-keep-prescient-sorting+
;; WARN: Adapted from ivy, doesn't maintain prescient based sorting
(cl-loop for cand in (funcall func cands)
with dirs = nil
with files = nil
do (if (eq (aref cand (- (length cand) 1)) ?/)
(setq dirs (cons cand dirs))
(setq files (cons cand files)))
finally return `(,@(nreverse dirs) ,@(nreverse files)))
(sort cands
(lambda (x y)
(let ((x-dir (eq (aref x (- (length x) 1)) ?/))
(y-dir (eq (aref y (- (length y) 1)) ?/)))
(cond
((and x-dir y-dir)
(string< (directory-file-name x) (directory-file-name y)))
(x-dir t)
(y-dir nil)
(t (string< x y))))))))
(t (funcall func cands))))
(advice-add 'selectrum-prescient--preprocess :around #'selectrum-prescient-preprocess+) |
Just found |
See also discussion on the Selectrum side about adding a way to configure completion behavior on a per-command basis: radian-software/selectrum#265 Fair warning, it is nontrivial, assuming that we actually want to do it in a reliable and not-surprising-to-the-user way, rather than as a hack. |
Hi, for some reason adding
find-file
orcounsel-find-file
to a negated list inivy-prescient-sort-commands
has no effect, and the function continues to have its candidates sorted. I can tell it is prescient that is doing this because disablingivy-prescient-mode
automatically disables sorting offind-file
. Any ideas on how I can get this to work?I have configured the variable in the following manner:
The text was updated successfully, but these errors were encountered: