Endless Parentheses

Ramblings on productivity and technical subjects.

profile for Malabarba on Stack Exchange

Exclude Directories from Grep

I keep a couple of subdirectories inside my “.emacs.d/” for the purpose of organization, so rgrep'ing is tremendously useful for finding where a variable is being changed. By default, that will also search inside “elpa”/, which slows the search and pollutes the results page.

We can make grep more selective and, while we're at it, enable line truncation.

(eval-after-load 'grep
  '(progn
     (add-to-list 'grep-find-ignored-directories "tmp")
     (add-to-list 'grep-find-ignored-directories "node_modules")
     (add-to-list 'grep-find-ignored-directories ".bundle")
     (add-to-list 'grep-find-ignored-directories "auto")
     (add-to-list 'grep-find-ignored-directories "elpa")))
(setq wgrep-enable-key (kbd "C-c C-c"))
(add-hook 'grep-mode-hook (lambda () (toggle-truncate-lines 1)))

And don't forget to bind rgrep to your Launcher Keymap!

Tags: init.el, emacs,

comments powered by Disqus