dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
465 stars 38 forks source link

Searching through a set of files that are listed in a file. #130

Open sje30 opened 2 years ago

sje30 commented 2 years ago

Hi,

thanks for the rg.el package. I'm trying to set it up so that I can search all my org-mode files that are stored in lots of different directories under my home directory. I have a workflow from the shell, which is:

Step 1: find the .org files

This takes a few seconds to search through my home directory, and so I would like to cache the results in a file:

cd; fd -t f -e org > all-org.txt

(for context, there about nearly 1200 matches)

Step 2: search through that file list.

I can then use xargs to pass through the filenames (none of the filenames have spaces in them, else xargs -0 might be needed), and for example, here search for 'defun':

  cd; xargs -a all-org.txt rg defun

How best might I use rg.el to do similar, such that the rg buffer is more useful? Should I look into defining a new search? I have confirmed that if I do C-u M-x rg then add the xargs ... at the start of the command, it will work, but I'd rather not do that every time.

note: there has been discussion, not yet implemented, about adding --files-from flag to rg for this case: https://github.com/BurntSushi/ripgrep/issues/273

dajva commented 2 years ago

This is not something that is currently not very well supported in this package. The main premise for this package are the three parameters, directory, query string and file-type/glob. Using full command line search means we can't modify the search parameters which cripples the result buffer. I know, the full command search is in there, just saying that this code path is not prioritized and is mostly there because of legacy compatibility with built-in grep package. I do see the need for making this more flexible though, both for my own usage and some feature requests that pops up now and then. To have this working I think we would have to modify rg-define-search a bit to accept full command searches as a special case.

sje30 commented 2 years ago

Thanks for the considered reply. Happy to test if you incorporate something similar in the future.