1

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?

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.

|improve this answer|||||
  • 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 3:35
  • You can inspect it with F1 v helm-grep-default-recurse-command. – wasamasa Jan 19 '15 at 8: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 7:17

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.