I want emacs grep to always search from the root project directory, not the directory of the currently opened file. The assumption here is that all of your coding projects are under the same folder (like ~/repositories/
).
I tried to prefix the grep command with a command that cd
s into the project root, but this leaves the emacs working directory variable untouched, so while the grep is performed in the correct filesystem location, jumping to search results is broken, because the partial file paths of the grep matches are appended to the emacs working directory.
To summarize, I want to be in ~/repositories/my_project/folder1/file1.c
, invoke grep command which will search from ~/repositories/my_project/
, and have the jump to file functionality of the grep buffer work.
How can I achieve this?