Comments (12)
That is the expected behavior. Orderless splits the input into components, compiles each to a regexp, and a string is considered to match if each component's regexp matches somewhere in the string. In particular it follows that repeating components makes no difference to whether a string matches or not.
For the particular example of matching something like fi fi
to find-file
, I'd suggest using the orderless-prefixes
matching style and phrasing the input as fi-fi
instead. Or you could use the orderless-regexp
style and type fi.*fi
.
from orderless.
I wonder if it makes sense to add a special rule which compiles repeated patterns to literals separated by .*
.
Alternatively one could combine all the styles but I don't think the quadratic, cubic behavior, etc would be a great idea.
from orderless.
Even if we added that special rule, I'd still use fi-fi
with orderless-prefixes
for this example, because it matches fewer things as it means \<fi.*-fi
. I think I'm happy with being precise about whether I mean \<fi.*-fi
or just fi.*fi
specially since I get to pick the syntax for those things. I've never found much use for fi.*fi
so I don't mind typing two characters (.
and *
) to get that meaning, and I do have orderless-prefixes
setup for components with dashes or a few other separators in them.
from orderless.
We don't need that special rule since it is easy to do in your own configuration:
(defun respect-repeats (string)
(mapcar
(lambda (group) (string-join (cdr group) ".*"))
(seq-group-by #'identity (split-string string))))
(setq orderless-component-separator #'respect-repeats)
from orderless.
I'm closing this since I think this should be handled in configuration like in the above example code.
from orderless.
from orderless.
from orderless.
Thanks for the explanation and a proposed solution by treating the repeated pattern as a special case that needs to use .*
in order to concatenate the two terms.
But I think the problem is more general than this. Some users may naturally think in terms of the matches to the sequence of pattern components separated by spaces as being 'consumed' by the matching algorithm in some order, so that in the case of the OP, the first 'fi' in find-file would match, and then remove from further consideration, the fi in 'find', leaving just 'nd-file' for the second 'fi' to match.
Viewed from this perspective, the issue is no longer just about repeated pattern components.
Is there an easy way to configure orderless so that the matches to the individual pattern components cannot overlap in a successful candidate?
from orderless.
Well, programs in the "machine language" that orderless compiles to are just list of regexps and the semantics are that a string matches the list if every regexp matches. Which is why orderless's semantics is chosen to be similar: input matches if each component matches according to the chosen styles.
But I think it's not too hard to do an alternative component separator where something like ab bc ef
compiles to the list ("ab.*bc\|bc.*ab" "ef")
. I'll try my hand at it when I get the chance.
from orderless.
Related Issues (20)
- Orderless breaks ESS completion in region HOT 1
- orderless doesn't work with fido HOT 5
- Document `(orderless basic)` as recommended configuration HOT 18
- Different completion candidates in Corfu and Company HOT 2
- Failed to install orderless HOT 2
- Release new version 0.8 on GNU ELPA HOT 7
- Completion variables recommended configuration HOT 3
- Orderless never returns a sole match for `switch-to-buffer` HOT 2
- Non-greedy match for orderless-flex? HOT 9
- Prescient defines a completion style
- How do I dispatch filtering on a suffix? HOT 3
- Ido or icomplete HOT 2
- Multiple matches, and/or over specifying candidates HOT 2
- I can't get the suggsted configuration for integration with Company to work. HOT 3
- Confusing highlighting when using `orderless-flex` style HOT 3
- Orderless with a single component HOT 3
- It doesn't seem to affect `C-x b` the same way as, e.g., `M-x` HOT 2
- Add simple affix dispatcher HOT 11
- I've been thinking about using it for Embark and maybe removing the `embark-define-keymap` macro in favor of `defvar-keymap`. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orderless.