When I am refactoring code, I often need to make the same change in my files. My current workflow is often something like this:
- Go to first hit
M-x replace-string RET foo.bar RET foo
- Go to next hit
- Repeat previous two lines until no more hits
Keyboard macros and
M-p can help with this, but I tried to write a function to do all the replacements in a simple command:
M-x my-replace-grep-hits RET foo.bar RET foo.
I am having trouble figuring out how to actually get to the file with the error. It seems that
(compilation-next-file 1) (compile-goto-error)
should do what I want, but I get an error that the buffer is read-only, so clearly
compile-goto-error is not changing the buffer when I call it programatically.
What do I need to do?