(unless grep-find-use-xargs
(setq grep-find-use-xargs
(cond
- ((grep-probe find-program
- `(nil nil nil ,(null-device) "-exec" "echo"
- "{}" "+"))
- 'exec-plus)
+ ;; For performance, we want:
+ ;; A. Run grep on batches of files (instead of one grep per file)
+ ;; B. If the directory is large and we need multiple batches,
+ ;; run find in parallel with a running grep.
+ ;; "find | xargs grep" gives both A and B
((and
+ (not (eq system-type 'windows-nt))
(grep-probe
find-program `(nil nil nil ,(null-device) "-print0"))
(grep-probe xargs-program '(nil nil nil "-0" "echo")))
'gnu)
+ ;; "find -exec {} +" gives A but not B
+ ((grep-probe find-program
+ `(nil nil nil ,(null-device) "-exec" "echo"
+ "{}" "+"))
+ 'exec-plus)
+ ;; "find -exec {} ;" gives neither A nor B.
(t
'exec))))
(unless grep-find-command