-
Notifications
You must be signed in to change notification settings - Fork 25
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
For Selectrum, add commands that toggle filtering methods. #72
Conversation
f3abe1d
to
4ea1323
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks great! Some comments.
README.md
Outdated
@@ -64,7 +64,7 @@ ones, and then the remaining candidates are sorted by length. If you | |||
don't like the algorithm used for filtering, you can choose a | |||
different one by customizing `prescient-filter-method`. | |||
|
|||
## Configuration | |||
## Configuration and Other Features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Configuration and Other Features | |
## Configuration and other features |
README.md
Outdated
@@ -90,6 +90,9 @@ different one by customizing `prescient-filter-method`. | |||
matching, regexp matching, fuzzy matching, prefix matching, or any | |||
combination of those. See the docstring for full details. | |||
|
|||
### Ivy-Specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Ivy-Specific | |
### Ivy-specific |
README.md
Outdated
@@ -110,6 +113,33 @@ different one by customizing `prescient-filter-method`. | |||
the Ivy documentation for information on how Ivy sorts by default, | |||
and how to customize it manually. | |||
|
|||
### Selectrum-Specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Selectrum-Specific | |
### Selectrum-specific |
README.md
Outdated
@@ -90,6 +90,9 @@ different one by customizing `prescient-filter-method`. | |||
matching, regexp matching, fuzzy matching, prefix matching, or any | |||
combination of those. See the docstring for full details. | |||
|
|||
### Ivy-Specific | |||
The following user options are specific to using Prescient with Ivy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following user options are specific to using Prescient with Ivy: | |
The following user options are specific to using `prescient.el` with Ivy: |
selectrum-prescient.el
Outdated
The toggling of commands is temporary and does not affect the | ||
default filtering settings determined by `prescient-filter-method'.") | ||
;; Create a binding similar to the Isearch toggles. | ||
(defvar selectrum-minibuffer-map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These defvar
/ declare-function
forms can go in stub/selectrum.el
with the others, so they're all centralized.
selectrum-prescient.el
Outdated
;; Create a binding similar to the Isearch toggles. | ||
(defvar selectrum-minibuffer-map) | ||
(define-key selectrum-minibuffer-map | ||
"\M-s" selectrum-prescient-filter-toggle-map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"\M-s" selectrum-prescient-filter-toggle-map) | |
(kbd "M-s") selectrum-prescient-filter-toggle-map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make it so that this binding is only activated when selectrum-prescient-mode
is enabled? While it's easy to do it this way, it's generally considered bad practice for simply loading a package to cause behavior changes.
I'd be happy to spend some time thinking about a good way of making this happen, if you're not sure.
selectrum-prescient.el
Outdated
(cons (quote ,filter-type) | ||
prescient-filter-method)) | ||
(message "%s filter toggled on." | ||
,(capitalize filter-type-name)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a good idea to report the new value of prescient-filter-method
after it's updated? It might be hard to keep track of which methods have been toggled on and off if there are multiple.
README.md
Outdated
| M-s i | selectrum-prescient-toggle-initialism | | ||
| M-s l | selectrum-prescient-toggle-literal | | ||
| M-s p | selectrum-prescient-toggle-prefix | | ||
| M-s r | selectrum-prescient-toggle-regexp | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps put these table entries in backticks, for consistency?
…o toggle-commands Merge new anchor filtering method.
…oggle-map. This seems more appropriate, since the names of the commands are of the form "selectrum-prescient-toggle-*".
I have tried to address what you wrote. Where else do you think things could be improved? |
@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. |
It looks great to me!
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 Feel free to change anything else you like, otherwise I'm happy to merge this. |
Yes, that sounds like a great feature! For orderless and other filter functions which use C completion functions internally we would need to set |
37c5d1b
to
309caee
Compare
I think I am happy with this. I don't have a use case for toggling the character folding, but I mentioned it because |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
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?