To understand the regression consider this recipe where the 'fo'
pattern is typed by the user in the last step.
emacs -Q
C-x b foo RET
C-x b afoo RET
C-x b *scratch* RET
M-x fido-mode RET
C-x b fo
This used to offer both 'foo' and 'afoo' as candidates but now only
offered 'foo'. This is because the pattern 'fo' matches 'foo', but
not 'afoo' with 'basic' completion style.
Fido mode, however, prioritizes 'flex' completion style, and that is
not happening here as it used to.
This was introduced in this commit
commit
bf81df86e52fdc995bec8d9646f84d114cb896d1
Author: João Távora <joaotavora@gmail.com>
Date: Wed Dec 7 10:43:59 2022 +0000
Don't override completion-category-defaults in fido-mode
I took away the nil setting of 'completion-category-defaults; in Fido
mode's minibuffer. It seemed generally the correct thing to do, and
was done mainly because Eglot added its style preferences to that
variable instead of completion-category-overrides directly, which is a
nono. So, to be able use the Fido UI with Eglot successfully,
'completion-category-defaults' should stay untouched. Or so I
thought.
However, I failed to notice that, for most categories, the default
value of 'completion-category-defaults' prioritizes the 'basic'
completion style.
For example, in the 'buffer' category, the default value has the
styles list '(basic substring)'. This means that if a pattern matches
accoring to the 'basic' style, 'substring' will not be tried. And
neither will 'completion-styles' which in Fido mode's case happens to
be 'flex'.
The solution in this commit is to craft a value for completion
category defaults that is just like the default one, but prioritizes
'flex' completion for every category.
* lisp/icomplete.el (icomplete--fido-ccd): New helper.
(icomplete--fido-mode-setup): Use it.
"C-." #'icomplete-forward-completions
"C-," #'icomplete-backward-completions)
+(defun icomplete--fido-ccd ()
+ "Make value for `completion-category-defaults' prioritizing `flex'."
+ (cl-loop
+ for (cat . alist) in completion-category-defaults collect
+ `(,cat . ,(cl-loop
+ for entry in alist for (prop . val) = entry
+ if (eq prop 'styles)
+ collect `(,prop . (flex ,@(delq 'flex val)))
+ else collect entry))))
+
(defun icomplete--fido-mode-setup ()
"Setup `fido-mode''s minibuffer."
(when (and icomplete-mode (icomplete-simple-completing-p))
icomplete-scroll (not (null icomplete-vertical-mode))
completion-styles '(flex)
completion-flex-nospace nil
+ completion-category-defaults (icomplete--fido-ccd)
completion-ignore-case t
read-buffer-completion-ignore-case t
read-file-name-completion-ignore-case t)))