Note: This PR is heavily informed by the fzf advanced use documentation. For complete context, do read the documentation. Although the documentation mentions ripgrep specifically, the ideas expand to any kind of custom narrowing (although the performance gain may not)
Changes
in descending priority order
Reintroduce FZF_DEFAULT_COMMAND usage to support custom narrowing
From the fzf documentation:
Instead of starting fzf in rg ... | fzf form, we start fzf without an explicit input, but with a custom FZF_DEFAULT_COMMAND variable. This way fzf can kill the initial Ripgrep process it starts with the initial query. Otherwise, the initial Ripgrep process will keep consuming system resources even after reload is triggered.
Add fzf-grep-with-narrowing, fzf-grep-in-dir-with-narrowing, and fzf-grep-dwim-with-narrowing
These functions use the fzf/grep-command as the narrowing function to incrementally expand/contract the search space. This adds the functionality requested in #72
From the fzf documentation:
fzf will restart Ripgrep every time the user updates the query string on fzf. Searching and filtering is completely done by Ripgrep, and fzf merely provides the interactive interface. So we lose the "fuzziness", but the performance will be better on larger projects, and it will free up memory as you narrow down the results.
fzf-with-command now takes an optional "bool" arg as-filter. When non-nil, the command arg will also be used as the narrowing filter instead of the typical fuzzy filtering.
Remove the cmd arg from fzf/start in favor of the previous strategy of setting FZF_DEFAULT_COMMAND. Update fzf/start to take an optional custom-args param. In order to use a custom narrowing function, we need to disable fzf's fuzzy filtering and provide it with additional options to define the narrowing function.
Update fzf-grep to read the search term interactively using read-from-minibuffer instead of using interactive with a required argument. This makes it easier to re-use it in other grep functions that may want to have interactive input.
Only show the directory in the modeline if provided.
This prevents showing nil when using fzf-with-entries (e.g. fzf-switch-buffer)
Grouped setqs in fzf/start
Breaking Changes
None. All function signatures have been updated to add tail optional params, or in the case of fzf-grep, updated to maintain parity with the previous implementation.
Upcoming
I tested all the functions by hand to check for regressions, but this package is growing beyond that. I am going to look into adding unit tests next.
Changes
in descending priority order
FZF_DEFAULT_COMMAND
usage to support custom narrowingfzf
documentation:fzf-grep-with-narrowing
,fzf-grep-in-dir-with-narrowing
, andfzf-grep-dwim-with-narrowing
fzf/grep-command
as the narrowing function to incrementally expand/contract the search space. This adds the functionality requested in #72fzf
documentation:fzf-with-command
now takes an optional "bool" argas-filter
. When non-nil, thecommand
arg will also be used as the narrowing filter instead of the typical fuzzy filtering.cmd
arg fromfzf/start
in favor of the previous strategy of settingFZF_DEFAULT_COMMAND
. Updatefzf/start
to take an optionalcustom-args
param. In order to use a custom narrowing function, we need to disablefzf
's fuzzy filtering and provide it with additional options to define the narrowing function.fzf-grep
to read the search term interactively usingread-from-minibuffer
instead of usinginteractive
with a required argument. This makes it easier to re-use it in other grep functions that may want to have interactive input.nil
when usingfzf-with-entries
(e.g.fzf-switch-buffer
)setq
s infzf/start
Breaking Changes
None. All function signatures have been updated to add tail optional params, or in the case of
fzf-grep
, updated to maintain parity with the previous implementation.Upcoming
I tested all the functions by hand to check for regressions, but this package is growing beyond that. I am going to look into adding unit tests next.