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.
Change the default cursor position of find-grep command in emacs
Change the code in your init.el
to the following:
(grep-apply-setting 'grep-find-command '("find . -type d \\( -name '.git' \\) -prune -o -type f -exec grep -nH -e \\{\\} +" . 72))
Default string for grep-find in emacs
The grep
package computes a bunch of defaults up front (but not necessarily on package load). So you'll want to get that to happen, and then redefine the find command. Something like:
(grep-compute-defaults)
(setq grep-find-command "find . ! -name \"*~\" ! -name \"#*#\" -type f -print0 | xargs -0 -e grep -nH -e ")
EMACS find-grep command switching windows
See the functions next-error
and previous-error
. They leave the grep buffer, but they work from anywhere, so, for example, if you bind next-error
to a convenient a key then you can keep pressing it and it will iterate over the grep buffer.
How to get emacs grep to search based on project root?
This does not answer directly your grep
question but especially when working with projects, I always find projectile to be a great tool.
Projectile, amongst other things, provides a grep
, ack
and ag
search on a project level which is probably what you are looking for.
E.g.
C-c p s g
runs grep
on the files in the project.
Related Topics
Can Linux Flock(Fd, Lock_Ex|Lock_Nb) Fail Spuriously
How to Execute The Vim Commands Through Shell Script
Linking a Static Library into a Shared Library
What Is The Correct Way to Define a Netfilter Hook Function
Prevent Fork() from Copying Sockets
Opening Sockets to The Xserver Directly
Running R in Batch Mode on Linux: Output Issues
Sdl Configuration in Eclipse Ide
Qxcbconnection: Could Not Connect to Display Aborted, When Installing Qt on Linux
Linux Patch Ignoring Line Numbers
Naming Convention for Posix Flags
When Does a Process Handle a Signal
Recording from Alsa - Understanding Memory Mapping
Programmatically Disable Hardware Prefetching on Amd Systems
Simplest Way to Build Dotnet Sdk Project Requiring Net461 on Macos