reddit / emacs

How to change consult-line behaviour ?

Xeroth95 · 2022-12-02 22:58
When I use consult-line in a buffer containing only 'some text' and search for 'text' it finds no matching lines, but when I search for ' text' it does find the line. In neither case will it find a line containing only '(text)'. consult-multi-line (like swiper) finds both lines in both cases. Is there a way to change consult-line's behaviour so that it matches that of consult-multi-line and swiper ?
JDRiverRun · 2022-12-03 03:07
You must have a config issue; consult-line works perfectly in all these scenarios for me. What `completion-styles` do you have configured? This is what determines how matches are actually made (not consult). I highly recommend the style `orderless`. But even `basic` should work for the simple cases you mention.
Xeroth95 · 2022-12-03 11:16
My completion-styles was set to (basic partial-completion emacs22). Downloading orderless and setting completion-styles to (orderless basic) fixed it. Thanks for your help!
oantolin · 2022-12-03 16:22
Minor correction: `basic` would not match the `text` in a line containing `some text`, because `basic` only matches at the start of the string. The `substring` completion style would match.
JDRiverRun · 2022-12-03 17:34
That was probably the issue. Basic is really not too appropriate for "selection of things" like consult-line. Thanks for orderless. It is amazing because it's really *all completion styles in one*, and you can *tune* it for specific cases to match the effective style to the source of completions better. It can be a bit complicated to do so with the dispatch functions/etc. Sometimes I wonder if packageable "tuning packs" for orderless for different contexts would help. For example, for LSP-provided completions, you want to leave the first search term entirely alone, i.e. use the passthrough style.
oantolin · 2022-12-03 18:07
The `orderless-define-completion-style` macro allows users to package any orderless configuration as a completion style. Then you can use standard mechanisms to indicate when you want that completion style used.