summaryrefslogtreecommitdiff
path: root/lisp/icomplete.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2023-03-06 22:28:47 +0000
committerJoão Távora <joaotavora@gmail.com>2023-03-06 22:58:11 +0000
commitbd07cec844257ba8ae95b2ab2e66982360576c9d (patch)
tree380c2ee12b169a5724d67c4336eca3be1586d8f1 /lisp/icomplete.el
parent0e3c7ac13da7039d873fdd0f879c2bea75fe7d5a (diff)
downloademacs-bd07cec844257ba8ae95b2ab2e66982360576c9d.tar.gz
Fix regression in Fido mode (bug#62015)
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.
Diffstat (limited to 'lisp/icomplete.el')
-rw-r--r--lisp/icomplete.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 0adb0e5afeb..f46127a20e0 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -419,6 +419,16 @@ if that doesn't produce a completion match."
"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))
@@ -430,6 +440,7 @@ if that doesn't produce a completion match."
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)))