deadgrep icon indicating copy to clipboard operation
deadgrep copied to clipboard

Deadgrep lacks multi-directory support available through rg

Open derek-upham opened this issue 5 years ago • 2 comments

M-x deadgrep calls deadgrep-project-root-function to get a directory, and passes that directory down to deadgrep--buffer.

I have a situation where I want to search through my directory tree, plus various other directory trees in on-disk caches stored elsewhere. The underlying rg command supports that:

       rg [OPTIONS] PATTERN [PATH...]

Deadgrep doesn't: the user can only request one PATH. Can you extend the code to support a single directory or a list of directories? Once that's in place it should be simple to dynamically bind deadgrep-project-root-function in new commands to do what I need.

(Ag has the same problem, and ages ago I hand-copied the appropriate function to my .emacs and tweaked it. It's a brittle approach, though.)

derek-upham avatar Jun 28 '19 03:06 derek-upham

Interesting, I didn't know this was possible with rg. Looking at the docs:

    <PATH>...    
            A file or directory to search. Directories are searched recursively. Paths specified on
            the command line override glob and ignore rules.  

I think the best option here is to allow deadgrep-project-root-function to return a list, as you say. However, I don't think returning "/foo" will be the same as returning '("foo"), because passing a list of paths doesn't have the globbing or gitignore features.

Wilfred avatar Aug 23 '19 00:08 Wilfred

To clarify, I'm interested in supporting '("/path/to/src" "/cache/path/to/lib1/src" "/cache/path/to/lib2/src") as the general case, with "/path/to/src" converted to '("/path/to/src") for backwards compatibility. Sometimes its useful to search across all of my library sources; sometimes it isn't.

I think the reference to overriding glob and ignore rules just means "if you ask for any specific path on the command line, we trust that you really want it and we won't try to hide it from you".

derek-upham avatar Aug 23 '19 02:08 derek-upham