According to the Emacs manual:
The Mx lgrep (local grep) and Mx rgrep (recursive grep) commands are more user-friendly versions of grep and grep-find, which query separately for the regular expression, search files, and the base directory to search.
For this problem, we do not need this "user-friendly" that interferes. We can use the regular grep elisp function, which is better suited for non-interactive use. Basically, this function takes as argument any grep command line that you should use to achieve the desired result. Maximum flexibility!
Here's what it would look like for your scenario:
(grep "grep --color -rn something ~/projects/")
Here's another, more complex use of grep options to match only complete words in Python files:
(grep "grep --include=\"*.py\" --color -rnw your_pattern files_root_dir")
source share