Make emacs grep/grep-find ignore .svn directories
Emacs grep and grep-find command used to work great for me until I started working with SVN and all those .svn directories started popping up in my emacs grep searches…
So how can we make the emacs grep-find
command ignore all the .svn directories?
Being mostly a “git” guy, and having been recently introduced to SVN I found myself amazed — at frist, and then subsequently quite annoyed — by the fact that SVN sprinkles the entire project with countless .svn directories.
After trying numerous find, grep and xargs combinations which worked great in the shell and DID NOT work in emacs I finally decided that for SVN projects I will give up the grep-find command altogether in favour of the emacs grep
command, with the following parameters:
grep -nH -r --exclude-dir='svn' --include='*.h' --include='*.cpp' --include='*.c' -e SrchStr *
Note that this is actually an improvement on grep-find in that it only searches cpp, c and h files π If you want to include all files then remove the 3 –include switches in the above emacs grep command.
Save it in your .emacs file to make it permanent:
(setq grep-command "grep -nH -r --exclude-dir='svn' --include='*.h' --include='*.cpp' --include='*.c' -e SrchStr *")
This way whenever you type “M-x grep” in emacs the above command line will appear. Just replace SrchStr by whatever you’re searching for and off you go π
A little later today I also found a solution using grep-find to ignore the .svn directories:
(setq grep-find-command
"find . -type f '!' -wholename '*/.svn/*' -print0 | xargs -0 -e grep -nH -e ")
.. which is also quite cool, so posting it here as well. Obviously Ben is a lot more experienced (and patient?) with emacs and Elisp than I am… π
-
Categories
- Android Development
- Bash
- C programming
- dpkg/apt-get
- drupal
- Emacs
- Git
- Java
- Linux administration
- Linux device drivers
- Linux Gaming
- Linux kernel
- Linux Networking
- Linux on Windows
- Linux printing
- Linux sound and ALSA
- Package Managers
- Programming
- RPM
- Shell and environment
- Tips and tricks
- Uncategorized
- VirtualBox
- Virtualization
- web development
- wine
- WMaker
- Wordpress Tips
- X Window System
- XFCE
-
Articles
- August 2020
- August 2019
- May 2019
- July 2017
- February 2017
- January 2017
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- April 2016
- March 2016
- December 2015
- November 2015
- September 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- October 2014
- February 2014
- January 2014
- November 2013
- October 2013
- June 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
-
Meta
Cloud
audio bash boot compile C programming cups drupal emacs etc Fedora git grep how to httpd init kernel libc linux linux partition localtime login make mount mp3 mysql networking oracle package managers password phpMyAdmin programming rpm shell sql vbox version control system virtual box vm web server wordpress www xargs xfce xwin yum