Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ivy - it would be desirable to allow unordered search? #1303

Closed
ahungry opened this issue Nov 22, 2017 · 4 comments
Closed

ivy - it would be desirable to allow unordered search? #1303

ahungry opened this issue Nov 22, 2017 · 4 comments

Comments

@ahungry
Copy link
Contributor

ahungry commented Nov 22, 2017

This seems possible in helm, and a common use case would be for me to search:

lisp repo user

to first match all file types of '.lisp' type, then narrow to repositories directory, and then finally choose the user.lisp file (so, the candidate should match a target such as src/repository/user.lisp).

I implemented a custom ivy--regex-unordered function (it will generate a regex for every possible combo of terms - obviously quite slow if run against the full obarray list) - if ivy-re-match were modified to accept a list of regexes instead of a single regex (joined via an 'and) this performs nearly as fast as any of the existing ivy search mechanisms.

So, ideally, my search list would be narrowed similar to:

(remove-if-not (lambda (candidate) 
  (and (string-match-p "lisp" candidate)
           (string-match-p "repo" candidate)
           (string-match-p "user" candidate)) candidates)

Would a PR similar to that be desirable if it didn't break BC and relied on the user setting ivy-re-builders-alist to include a tuple with values similar to (t . 'ivy--regex-list-build)) - a function that would return a list of regexes (so, listp type) vs a single regex string?

@abo-abo
Copy link
Owner

abo-abo commented Nov 22, 2017

There is already ivy--regex-ignore-order that does what you describe

@ahungry
Copy link
Contributor Author

ahungry commented Nov 22, 2017

Awesome, thanks, not sure how I missed this! (actually I do know how, it isn't mentioned in the docstring for ivy-re-builders-alist 😄 )

Should it be added? Docstring reads as such:

Possible choices: ‘ivy--regex’, ‘regexp-quote’,
‘ivy--regex-plus’, ‘ivy--regex-fuzzy’.

@abo-abo
Copy link
Owner

abo-abo commented Nov 22, 2017

Yes, please PR.

@ahungry
Copy link
Contributor Author

ahungry commented Nov 22, 2017

Added #1308

@ahungry ahungry closed this as completed Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants