diff options
author | Glenn Morris <rgm@gnu.org> | 2011-04-02 11:52:08 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2011-04-02 11:52:08 -0700 |
commit | f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9 (patch) | |
tree | 37cca1c536d91c767b203d2963fa1cee73d1f286 /lisp | |
parent | afa8e9f6064d3b9ae62bf240426393d4fabcc9ac (diff) | |
download | emacs-f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9.tar.gz |
Use find -exec with '+' for grep-find if supported.
* lisp/progmodes/grep.el (grep-find-use-xargs): Doc fix.
(grep-compute-defaults): Check for `-exec COMMAND +' support.
Set grep-find-use-xargs, grep-find-command, and grep-find-template
accordingly. Don't add the null-device if not needed.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/progmodes/grep.el | 37 |
2 files changed, 31 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ba9532ff0d8..006d0aa601d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2011-04-02 Glenn Morris <rgm@gnu.org> + * progmodes/grep.el (grep-find-use-xargs): Doc fix. + (grep-compute-defaults): Check for `-exec COMMAND +' support. + Set grep-find-use-xargs, grep-find-command, and grep-find-template + accordingly. Don't add the null-device if not needed. + * files.el (save-some-buffers): Doc fix. 2011-04-02 Eli Zaretskii <eliz@gnu.org> diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index a4c9b7fccba..58f2ee98f3c 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -440,10 +440,11 @@ This variable's value takes effect when `grep-compute-defaults' is called.") ;;;###autoload (defvar grep-find-use-xargs nil - "Non-nil means that `grep-find' uses the `xargs' utility by default. -If `exec', use `find -exec'. + "How to invoke find and grep. +If `exec', use `find -exec {} ;'. +If `exec-plus' use `find -exec {} +'. If `gnu', use `find -print0' and `xargs -0'. -Any other non-nil value means to use `find -print' and `xargs'. +Any other value means to use `find -print' and `xargs'. This variable's value takes effect when `grep-compute-defaults' is called.") @@ -561,6 +562,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." (unless grep-find-use-xargs (setq grep-find-use-xargs (cond + ((grep-probe find-program + `(nil nil nil ,null-device "-exec" "echo" + "{}" "+")) + 'exec-plus) ((and (grep-probe find-program `(nil nil nil ,null-device "-print0")) (grep-probe xargs-program `(nil nil nil "-0" "-e" "echo"))) @@ -575,13 +580,17 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." ;; forward slashes as directory separators. (format "%s . -type f -print0 | \"%s\" -0 -e %s" find-program xargs-program grep-command)) - ((eq grep-find-use-xargs 'exec) + ((memq grep-find-use-xargs '(exec exec-plus)) (let ((cmd0 (format "%s . -type f -exec %s" - find-program grep-command))) + find-program grep-command)) + (null (if grep-use-null-device + (format "%s " null-device) + ""))) (cons - (format "%s {} %s %s" - cmd0 null-device - (shell-quote-argument ";")) + (if (eq grep-find-use-xargs 'exec-plus) + (format "%s %s{} +" cmd0 null) + (format "%s {} %s%s" cmd0 null + (shell-quote-argument ";"))) (1+ (length cmd0))))) (t (format "%s . -type f -print | \"%s\" %s" @@ -589,14 +598,20 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." (unless grep-find-template (setq grep-find-template (let ((gcmd (format "%s <C> %s <R>" - grep-program grep-options))) + grep-program grep-options)) + (null (if grep-use-null-device + (format "%s " null-device) + ""))) (cond ((eq grep-find-use-xargs 'gnu) (format "%s . <X> -type f <F> -print0 | \"%s\" -0 -e %s" find-program xargs-program gcmd)) ((eq grep-find-use-xargs 'exec) - (format "%s . <X> -type f <F> -exec %s {} %s %s" - find-program gcmd null-device + (format "%s . <X> -type f <F> -exec %s {} %s%s" + find-program gcmd null (shell-quote-argument ";"))) + ((eq grep-find-use-xargs 'exec-plus) + (format "%s . <X> -type f <F> -exec %s %s{} +" + find-program gcmd null)) (t (format "%s . <X> -type f <F> -print | \"%s\" %s" find-program xargs-program gcmd)))))))) |