Add option to filter on transformed candidates (e.g. with ivy-rich) for a given command #2936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As an happy user of https://github.com/Yevgnen/ivy-rich, I've been looking for a way to augment the filtering of my beloved
ivy-switch-buffer
(aka.C-x b
) function with the extra columns. In fact this issue has been raised a few times, to my knowledge:#2847
Yevgnen/ivy-rich#28
Yevgnen/ivy-rich#60
Yevgnen/ivy-rich#89
After recognizing the inherent performance problem with a general solution, I came up with this solution, which allows to easily turn on the feature on a per command basis, at the price of an extra custom variable, and a simple modification to
ivy--re-filter
. For instance if you are already usingivy-rich
and yourivy-rich-display-transformers-list
is set, as mine, to:then doing:
will allow you to filter your buffers by their project names and major modes, in addition to the file names, which in my case at least, is quite handy. You can turn off the feature by setting the same value to
nil
.As mentioned earlier the problem with this approach is that if you try to use it with a version of
counsel-M-x
augmented with function descriptions, for instance, there will be a very noticeable performance cost, because there are simply too many candidates, and the transform function is quite expensive. I think my per-command solution is an acceptable compromise however, and works particularly well withivy-switch-buffer
(although I admit my particular style is not to have hundreds of open buffers at any time though). Moreover there might be a way to speed up things by using caching or async logic, but that is outside of the scope of this PR.