0

My Emacs customizations reside in a few separate .org files, all in the directory ~/emacs-prelude/personal. I'm always searching these files to find and change settings.

How can I define a function search-my-emacs-configutation-files to search the full text of these files?

It seems like the most obvious way would be to do a helm-projectile-grep, but Projectile seems to think the "project" is the entire Emacs-Prelude directory (including all my packages) when in fact I want to search only the subdirectory Personal which has my customizations.

helm-cmd-t seemed promising but it seems like it searches only filenames.

helm-do-grep works, but it asks me for the directory each time. I'd like to be able to call this function using a single keystroke.

  • You can just use M-x grep, and customize option grep-template to hard-code your directory. – Drew Oct 25 '15 at 15:37
3

There are many ways to do what you need, here is one by using helm's helm-do-grep-1.

(defun search-my-emacs-configutation-files ()
  (helm-do-grep-1 '("~/emacs-prelude/personal/*.org")))

If you even have .org files under some sub-directories under ~/emacs-prelude/personal/:

(defun search-my-emacs-configutation-files ()
  (helm-do-grep-1 '("~/emacs-prelude/personal") :recurse nil '("*.org")))

From C-h f helm-do-grep-1:

(helm-do-grep-1 TARGETS &optional RECURSE ZGREP EXTS DEFAULT-INPUT INPUT)

The 1st argument TARGETS is a list of files (including directories).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.