With default completion, files ending with extensions listed in completion-ignored-extensions are not shown unless they are the only results. Maybe we could port this concept and also extend it by using a similar feature as used by selectrum-read-buffer which shows hidden buffers by typing a leading space. There could also be a user option to hide dotfiles by default as well. Maybe we could also have a command which allows to toggle file hiding.
This might work well, but we have to be a bit careful. For example, with this feature then .git would be hidden by default, and it might be very surprising because with Selectrum you expect to actually see all the files at once. I wonder if there is an elegant and performant way to force certain candidates to be sorted at the end? If so, perhaps that would be a better solution. Then again, if you actually navigate into .git, we probably want to sort it first when using selectrum-prescient.el. I do not know if there is a good compromise.
the following hack lets selectrum honor completion-ignored-extensions for the time being:
(defun my-filename-good-p (fn)
"check if given filename FN is good for completion reads (and should not be ignored
according to `completion-ignored-extensions')."
(not (seq-contains-p completion-ignored-extensions (file-name-extension fn t))))
(defun my-advice-selectrum-read-file-name (oldfun
prompt &optional dir default-filename mustmatch initial predicate)
"advice making `selectrum-read-file-name' honoring `completion-ignored-extensions'."
(let* ((predicate-new (if predicate
(lambda (fn) (and (funcall predicate fn)
(my-filename-good-p fn)))
#'my-filename-good-p)))
(funcall oldfun prompt dir default-filename mustmatch initial predicate-new)))
(advice-add #'selectrum-read-file-name :around
#'my-advice-selectrum-read-file-name)
edit: fixed a bug in line 10.
Thanks, note that adjusting the predicate can slow down file completions significantly for tramp and slow file systems, see #335
I think a combination of what @ddugue proposed and the ideas mentioned above could work to incorporate completion-ignored-extensions into Selectrum, to summarize the ideas so far:
Just a ping, I'd like to see selectrum honor completion-ignored-extensions
Most helpful comment
Just a ping, I'd like to see selectrum honor completion-ignored-extensions