I am trying to write an interactive command that will search a set of files for a regexp. The files are selected programmatically, for example, as a list of files that match some date criteria, or recently modified criteria and are in a list of paths that has been computed. These paths are likely to be in different directories, and not to match a regular pattern. The command will compute this list, e.g. for files in the last week, or last month, etc.
I want to search this list of files for a regexp. I have been able to get an approach like this to work with grep. Here, assume that the list of files is computed elsewhere
(grep
(format "grep -nH -i %s %s"
regexp
(mapconcat 'identity files " "))))
But I wondered if there is a better way to let-bind a variable to a file list, or to use occur/swiper, etc on this list. So far I have only found ways to search files that match a regexp, for example, and not to search a set of files.
Also I am concerned about what would happen if you had hundreds of files and if the length of that command got very long, so it might be better to search in buffers?
Something like swiper-multi would be great, but I can't figure out how to specify the list of buffers/files for it.
% g
indired
andM-x grep
.