radian-software / prescient.el

☄️ Simple but effective sorting and filtering for Emacs.
MIT License
615 stars 25 forks source link

For Selectrum, add commands that toggle filtering methods. #72

Closed okamsn closed 4 years ago

okamsn commented 4 years ago

While using Selectrum, I sometimes want to change what filtering method the current search is using, similar to Isearch's isearch-toggle-* commands. This pull request adds commands for this to selectrum-prescient.el.

Currently, this toggling only affects the running Selectrum buffer. Using a prefix argument with a command locally sets prescient-filter-method to only use the method corresponding to that command.

Is there anything that you would like changed?

okamsn commented 4 years ago

I have tried to address what you wrote. Where else do you think things could be improved?

okamsn commented 4 years ago

@raxod502 Do you think it makes sense to add commands for toggling case and character folding buffer-locally? They're not Prescient features, but fit the general idea of the pull request.

raxod502 commented 4 years ago

Where else do you think things could be improved?

It looks great to me!

Do you think it makes sense to add commands for toggling case and character folding buffer-locally?

I think those probably make more sense to add on the Selectrum side, cc @clemera. They would presumably be useful even to people who don't use prescient.el.


Feel free to change anything else you like, otherwise I'm happy to merge this.

clemera commented 4 years ago

They would presumably be useful even to people who don't use prescient.el

Yes, that sounds like a great feature! For orderless and other filter functions which use C completion functions internally we would need to set completion-ignore-case in addition to case-fold-search. I'm not sure ab out char folding as I'm not very familiar with it but it seems all that would be necessary would be to transform the input using char-fold-to-regexp before passing it to the filter function.

okamsn commented 4 years ago

I think I am happy with this.

I don't have a use case for toggling the character folding, but I mentioned it because prescient.el uses it automatically for the literal filter.

raxod502 commented 4 years ago

I mentioned it because prescient.el uses it automatically for the literal filter.

You're right. This definitely complicates my idea above to just have the completion framework handle this kind of thing. Some work is required to figure out what the right interface between the two packages is. If somebody is interested in this feature, then I can see if I can come up with an idea.