Yes, what I'm looking for is (something close to) a command that iterates over matched files in the grep buffer and calls query-replace for each.
OK, I just added command diredp-compilation-files-other-window
to Dired+, which can help with this.
You use it in a compilation buffer (any buffer, such as *grep*
, that is in a mode derived from `compilation-mode').
It prompts you for the name of a new Dired buffer, and it opens Dired on all of the files corresponding to the compilation hits, regardless of what directories they are in. IOW, the files can be in different directories.
In that Dired buffer, you can then:
- Use
t
to mark all of the files. - Use
Q
to query-replace across all of the files.
(Q
is standard Dired command dired-do-query-replace-regexp
).
As an alternative to using t
to mark all of the files, with Dired+ you can just use C-u C-u Q
to act on all files (without bothering to mark them). With Dired+, most commands that operate on the marked files let you use multiple C-u
to act on all files, ignoring marks.
Instead of Q
you can use A
to search the files, D
to delete them, P
to print, Z
to compress, !
to run a shell command, etc.