reddit / emacs

Ask r/Emacs - how do I configure Vertico to ignore - (dashes)

ocodo · 2022-05-11 10:24
I'm just starting out using Doom emacs. One thing I used to like with my other selection tools, ido & ivy is that I could write a command in M-x minibuffer and it would ignore the dashes in the command name. I guess there's a way to configure the matcher in Vertico, but googling and searching the github repo hasn't given me the answer I'm looking for so far. I wonder if anyone here can help me out? Edit: so I remembered I had configured Ido with flex matching and set it to vertical. Flex matching was easy to apply to Vertico (thanks to u/nullmove) Orderless looks like it's worth investigating further, but flex will work for me. Thanks for the help everyone.
nullmove · 2022-05-11 12:13
Can you give an example of what did you mean by 'ignore the dashes in command name'? My best guess is you want a completion style like [orderless](https://github.com/oantolin/orderless), are you already using that package?
pgronkievitz · 2022-05-11 12:55
I guess they want to match `qwe-zxcbnmasd` after writing e.g. `qwe-asd` Edit: pronouns
nullmove · 2022-05-11 13:16
Yeah in that case by default orderless won't work, though it will work when input is `qwe asd` I think, which I find more intuitive anyway. There is built-in `flex` style which should work with `qwe-asd` without orderless. It can also be made to work in orderless if `orderless-flex` is enabled in the `orderless-matching-styles`.
samsjj · 2022-05-11 14:18
I recently moved to selectrum from ido,flx-ido and was looking for same functionality. It’s already mentioned in the comments about orderless package. https://github.com/oantolin/orderless You need this to be set. orderless-flex the characters of the component should appear in that order in the candidate, but not necessarily consecutively. This maps abc to a.*b.*c. The variable orderless-matching-styles can be set to a list of the desired matching styles to use. By default it enables the literal and regexp styles.
ocodo · 2022-05-11 17:11
I've noticed Orderless, I'll give that a try. To clarify I'll edit the question. But to answer here I'll try to explain better. When I'm using M-x I want to be able to find a command name without typing dashes between words. For example if I'm looking for a command "kill-emacs" I expect to get a candidate match by typing "kiem". The m-x extension I used to use was called **smex** (I think the matching engine was **flex**.) Hope that's clarified it a bit.
ocodo · 2022-05-11 17:13
Thank you I'll give orderless a try.
nandryshak · 2022-05-11 17:15
Hot take: Just use helm, ivy, or ido. Vertico, orderless, selectrum, maginalia, consult, etc. are all just over-hyped, less-featureful rewrites of packages that have already solved this problem. These packages are for people who want to tinker with their config. Yes, they can be nice once you figure out how to configure them, but if you want something that works great out of the box, use helm or ivy. You said you liked ido & ivy, just use those. So why switch? If they have features that you want, and vertico doesn't, what benefit do you get from switching? Be skeptical of anyone calling helm or ivy "bloated". One person's "bloated" is another one's "featureful". Helm and ivy are plenty fast and they have great support for many different sources. If any of the completion frameworks mentioned above are running slowly, it's most likely the fault of their sources.
nullmove · 2022-05-11 17:24
Yeah, the other reply to my comment helped me understand your intent. You can either go with orderless and enable `orderless-flex` or you can give built-in flex style a try which doesn't need anything else, like: (add-to-list 'completion-styles 'flex)
ocodo · 2022-05-11 17:41
> So why switch? I'm trying out Doomemacs, and I like it. I have a 30+ year run going with Emacs and it's the only time I've been interested in an off the shelf config. I am bringing some of my old config over. Vertico is installed by default and it's nice enough that the only thing I want to maybe change is the completion matching style. It's also a good opportunity to ditch a lot of redundant stuff in my old config. Edit: just adding `(add-to-list 'completion-styles 'flex)` to the config fixed it.
by_wicker · 2022-05-11 17:42
I agree there's no pressing *need* to switch. There is something to be said for sticking with the mature systems and letting these newer packages mature even further (though they're in a great place already). However, > These packages are for people who want to tinker with their config. My config to use these is of the ilk: (use-package vertico :init (vertico-mode)) So I really don't think that's true at all. They are packages that integrate with Emacs's way of doing things rather than reinventing it in opinionated ways. They are small focused orthogonal packages doing one narrow job each, rather than monoliths implementing multiple of those facilities in one large system. The bloat isn't performance bloat or lines of code, it's creating its own expansive ecosystem rather than adapting and augmenting the standard Emacs one. It seems all OP wanted was flex matching, which is definitely already supported, not something you need ivy/helm for.
ocodo · 2022-05-11 17:46
Using flex does what I want. Thanks for reminding me about it!
Enough-Salary7212 · 2022-05-11 18:12
Ido is certainly not featureful. Ivy did not solve "the problem" - just look at the number of issues on its tracker. Helm builds its own complex ecosystem.
super-linux-nerd · 2022-05-11 22:57
the built-in flex is great, I find it to be the most intuitive completion style
JDRiverRun · 2022-05-12 00:09
Just to set your expectations, orderless is a chameleon, and the super-set of all completion styles. Very quickly you grow used to "py$", "xref !--", "\^buf\[0-9\]", etc. You can write your own little mini codes (like the ! there) using the "dispatcher". You grow so used to it you want orderless for in-buffer completion too, so you reach for corfu.
ocodo · 2022-05-12 02:29
Thanks for the info. I'll experiment with it.
bdarcus · 2022-05-12 16:55
>I'm trying out Doomemacs, and I like it.... Vertico is installed by default and it's nice enough that the only thing I want to maybe change is the completion matching style. Does it not already do what you want? From what I can tell, it should. [https://docs.doomemacs.org/latest/modules/completion/vertico/#/usage/orderless-filtering](https://docs.doomemacs.org/latest/modules/completion/vertico/#/usage/orderless-filtering) E.g. to complete a command `foo-baz-bar` you could do `M-x bar foo` or `M-x foo baz`.
ocodo · 2022-05-13 01:47
As you can see from the other comments, I was looking for flex matching (aka fuzzy) because I'm used to that. I like the default too, but it's jarring after using flex matching method for at least 7 years. The basic difference is trivial though so I could switch it off after a while and go to the default Orderless. For reference flex does this. **Input:** `abc` **Flex matches as**: (regexp) `a.*b.*c` This is powerful and works well for quickly matching complicated names. There's a clear risk that it will give an unexpected match a high rank, although in practice it's usually a good match after 4 or 5 chars. Edit: it's great for commands you know which you don't bind to keys. Orderless looks good for things you want to discover (if I'm understanding correctly, separate tokens are matched in any position to generate matches, which is pretty cool!)
bdarcus · 2022-05-13 11:20
I know; but the doom module includes flex matching too, although you do need to prefix it with a character to turn it on (`~abc`). But the nice thing is it's easy enough to change these completion styles.
ocodo · 2022-05-13 11:33
> the doom module includes flex matching too That's what I used.