I am running the command helm-do-grep
and I notice that the search is not recursive, i.e. it searches only in the directory I specify and not in subdirectories. How do I direct helm-grep
to automatically search recursively?
Asked
Active
Viewed 1,519 times
1

incandescentman
- 4,111
- 16
- 53
1 Answers
1
helm
does offer a non-recursive and a recursive command, by default it's using the non-recursive one when invoking M-x helm-do-grep
unless it has been called with a prefix argument. The values for the non-recursive and recursive command are stored in the helm-grep-default-command
and helm-grep-default-recurse-command
variables.
The easiest way of achieving recursion by default would be setting the former variable to the value of the latter.
(eval-after-load 'helm-grep
'(setq helm-grep-default-command helm-grep-default-recurse-command))
Caution: The solution above might have unintended consequences, such as using grep
on the buffers list to recurse on every listed file.

wasamasa
- 21,803
- 1
- 65
- 97
-
What's helm's recursive command? (I see helm-do-zgrep...) Would calling helm's recursive command be a safer way to invoke grep recursively than the above? – incandescentman Jan 19 '15 at 03:35
-
You can inspect it with `F1 v helm-grep-default-recurse-command`. – wasamasa Jan 19 '15 at 08:42
-
I get `grep -a -d recurse %e -n%cH -e %p %f`. What's the correct string for recursive searching? – incandescentman Jan 19 '15 at 21:10
-
Well, you set `helm-grep-default-command` to this value by `(setq helm-grep-default-command "grep -a -d recurse %e -n%cH -e %p %f")`. – wasamasa Jan 19 '15 at 23:06
-
But what's the new value for recursive search? – incandescentman Jan 20 '15 at 07:17
-
Doesn't matter, just leave it that way. – wasamasa Jan 20 '15 at 09:29
-
Evaluating the code in the answer makes it so that `helm-do-grep` doesn't run a search at all. – incandescentman Feb 20 '15 at 05:53
-
I find that hard to believe as I cannot reproduce that with a recent installation of `helm` and `emacs -Q`. – wasamasa Feb 20 '15 at 09:03