Change the default find-grep command in emacs

The text you changed does not look like executable code. Probably you just changed a doc string (actually, a bit of googling reveals that this is in the documentation string for grep-find-use-xargs). But Emacs is eminently customizable; all you have to do is to set the value of grep-find-template to something which is more suitable for you personally, in your own .emacs/init.el or similar.

(setq grep-find-template
      "find <D> <X> -type f <F> -exec grep <C> -nH -e <R> \\{\\} +")

See the manual for further documentation and, of course, the built-in documentation (ctrl-h v grep-find-template RET).

The actual source code is in http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/grep.el#n174 but you really, really, really do not want to edit the source code. The user-level customizability without code changes is one of the foundational designs of Emacs. Learn to use this facility.


You need to use the function grep-apply-setting to set the variable grep-find-command, and double up on the backslashes before the curly braces:

(grep-apply-setting 'grep-find-command "find . -type f -exec grep -nH -e  \\{\\} +")

(grep-apply-setting 'grep-find-command '("find . -type f -exec grep -nH -e  \\{\\} +" . 34))

Will place the cursor on just slightly after the -e

Tags:

Linux

Emacs

Fish