shmulkinator · 2022-03-07 16:07
I'm using vertico (a very nice package BTW) for completion. One issue I have with completion is due to my mediocre typing skills: I often mistype the term I'm trying to complete. Are there any completion styles available which tolerate typos?
art_else · 2022-03-07 17:50
Perhaps [orderless](https://github.com/oantolin/orderless) will do?
wargxs · 2022-03-07 18:28
Or built in flex completion style ?
[deleted] · 2022-03-07 18:59
Last year implemented a [completion style that catches typos](https://paste.sr.ht/~pkal/de45d32f440cee32872f55bf528b1f687abc2a3e) (not that this is the current state in my site-lisp directory, and probably doesn't work as intended), and it thought me a lot about completion styles, the difference between try-completion and all-completion as well as the limitations of completing-read, especially when confused as to whether completion means narrowing or expansion.
The above links implements [Peter Norvig's spell checker](https://www.norvig.com/spell-correct.html), but isn't optimized (I haven't implemented any clever algorithm besides basic caching right now, but you'd probably need some search strategy and heuristic to avoid redundant computations) nor does it work completion functions (as these do their own thing, and don't have to respect completion-styles). The other main issues I encountered are that completion via try-completion is actually just expansion, which makes sense considering the background ("vanilla completion" takes a string and expands it to a longer string when tab is pressed, just like with bash), but typo-checking can also delete a letter or twist them around. You could disable these rules, but then you also loose spell-checking "intelligence", and you basically end up with a stricter, flexible matching style (as others have suggested). Another one that follows from this is that you could imagine a typo-cycle, that would break the expected behavior and might make completion more brittle (as you never know what a tab would do). A different issue, but that might be improved by using better algorithms, is that "narrowing completion" systems, that use all-completion instead of try-completions become very slow and impractical.
shmulkinator · 2022-03-08 15:44
Thanks for all the responses! This subreddit is great.
I've got orderless in place and although it is handy, it doesn't do what I'm asking for. I will check out flex, but I suspect the same will be true.
u/_pkal: what you've implemented sounds more along the lines of what I was considering, but after I posted my query I started to think that a spelling corrector ("levenstein distance"-based?) might make completion funkier in the case of correct input.
[deleted] · 2022-03-08 22:55
> I've got orderless in place and although it is handy, it doesn't do what I'm asking for. I will check out flex, but I suspect the same will be true.
Flex is basically the same as orderless, just with order, so I guess you know what you will be getting.
> I started to think that a spelling corrector ("levenstein distance"-based?) might make completion funkier in the case of correct input.
That can be avoided, if you decided to only "spell-check" input that is not part of a completion table.