diff options
| author | Glenn Morris | 2011-04-02 11:52:08 -0700 |
|---|---|---|
| committer | Glenn Morris | 2011-04-02 11:52:08 -0700 |
| commit | f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9 (patch) | |
| tree | 37cca1c536d91c767b203d2963fa1cee73d1f286 | |
| parent | afa8e9f6064d3b9ae62bf240426393d4fabcc9ac (diff) | |
| download | emacs-f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9.tar.gz emacs-f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9.zip | |
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.
| -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 @@ | |||
| 1 | 2011-04-02 Glenn Morris <rgm@gnu.org> | 1 | 2011-04-02 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * progmodes/grep.el (grep-find-use-xargs): Doc fix. | ||
| 4 | (grep-compute-defaults): Check for `-exec COMMAND +' support. | ||
| 5 | Set grep-find-use-xargs, grep-find-command, and grep-find-template | ||
| 6 | accordingly. Don't add the null-device if not needed. | ||
| 7 | |||
| 3 | * files.el (save-some-buffers): Doc fix. | 8 | * files.el (save-some-buffers): Doc fix. |
| 4 | 9 | ||
| 5 | 2011-04-02 Eli Zaretskii <eliz@gnu.org> | 10 | 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.") | |||
| 440 | 440 | ||
| 441 | ;;;###autoload | 441 | ;;;###autoload |
| 442 | (defvar grep-find-use-xargs nil | 442 | (defvar grep-find-use-xargs nil |
| 443 | "Non-nil means that `grep-find' uses the `xargs' utility by default. | 443 | "How to invoke find and grep. |
| 444 | If `exec', use `find -exec'. | 444 | If `exec', use `find -exec {} ;'. |
| 445 | If `exec-plus' use `find -exec {} +'. | ||
| 445 | If `gnu', use `find -print0' and `xargs -0'. | 446 | If `gnu', use `find -print0' and `xargs -0'. |
| 446 | Any other non-nil value means to use `find -print' and `xargs'. | 447 | Any other value means to use `find -print' and `xargs'. |
| 447 | 448 | ||
| 448 | This variable's value takes effect when `grep-compute-defaults' is called.") | 449 | This variable's value takes effect when `grep-compute-defaults' is called.") |
| 449 | 450 | ||
| @@ -561,6 +562,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." | |||
| 561 | (unless grep-find-use-xargs | 562 | (unless grep-find-use-xargs |
| 562 | (setq grep-find-use-xargs | 563 | (setq grep-find-use-xargs |
| 563 | (cond | 564 | (cond |
| 565 | ((grep-probe find-program | ||
| 566 | `(nil nil nil ,null-device "-exec" "echo" | ||
| 567 | "{}" "+")) | ||
| 568 | 'exec-plus) | ||
| 564 | ((and | 569 | ((and |
| 565 | (grep-probe find-program `(nil nil nil ,null-device "-print0")) | 570 | (grep-probe find-program `(nil nil nil ,null-device "-print0")) |
| 566 | (grep-probe xargs-program `(nil nil nil "-0" "-e" "echo"))) | 571 | (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'." | |||
| 575 | ;; forward slashes as directory separators. | 580 | ;; forward slashes as directory separators. |
| 576 | (format "%s . -type f -print0 | \"%s\" -0 -e %s" | 581 | (format "%s . -type f -print0 | \"%s\" -0 -e %s" |
| 577 | find-program xargs-program grep-command)) | 582 | find-program xargs-program grep-command)) |
| 578 | ((eq grep-find-use-xargs 'exec) | 583 | ((memq grep-find-use-xargs '(exec exec-plus)) |
| 579 | (let ((cmd0 (format "%s . -type f -exec %s" | 584 | (let ((cmd0 (format "%s . -type f -exec %s" |
| 580 | find-program grep-command))) | 585 | find-program grep-command)) |
| 586 | (null (if grep-use-null-device | ||
| 587 | (format "%s " null-device) | ||
| 588 | ""))) | ||
| 581 | (cons | 589 | (cons |
| 582 | (format "%s {} %s %s" | 590 | (if (eq grep-find-use-xargs 'exec-plus) |
| 583 | cmd0 null-device | 591 | (format "%s %s{} +" cmd0 null) |
| 584 | (shell-quote-argument ";")) | 592 | (format "%s {} %s%s" cmd0 null |
| 593 | (shell-quote-argument ";"))) | ||
| 585 | (1+ (length cmd0))))) | 594 | (1+ (length cmd0))))) |
| 586 | (t | 595 | (t |
| 587 | (format "%s . -type f -print | \"%s\" %s" | 596 | (format "%s . -type f -print | \"%s\" %s" |
| @@ -589,14 +598,20 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." | |||
| 589 | (unless grep-find-template | 598 | (unless grep-find-template |
| 590 | (setq grep-find-template | 599 | (setq grep-find-template |
| 591 | (let ((gcmd (format "%s <C> %s <R>" | 600 | (let ((gcmd (format "%s <C> %s <R>" |
| 592 | grep-program grep-options))) | 601 | grep-program grep-options)) |
| 602 | (null (if grep-use-null-device | ||
| 603 | (format "%s " null-device) | ||
| 604 | ""))) | ||
| 593 | (cond ((eq grep-find-use-xargs 'gnu) | 605 | (cond ((eq grep-find-use-xargs 'gnu) |
| 594 | (format "%s . <X> -type f <F> -print0 | \"%s\" -0 -e %s" | 606 | (format "%s . <X> -type f <F> -print0 | \"%s\" -0 -e %s" |
| 595 | find-program xargs-program gcmd)) | 607 | find-program xargs-program gcmd)) |
| 596 | ((eq grep-find-use-xargs 'exec) | 608 | ((eq grep-find-use-xargs 'exec) |
| 597 | (format "%s . <X> -type f <F> -exec %s {} %s %s" | 609 | (format "%s . <X> -type f <F> -exec %s {} %s%s" |
| 598 | find-program gcmd null-device | 610 | find-program gcmd null |
| 599 | (shell-quote-argument ";"))) | 611 | (shell-quote-argument ";"))) |
| 612 | ((eq grep-find-use-xargs 'exec-plus) | ||
| 613 | (format "%s . <X> -type f <F> -exec %s %s{} +" | ||
| 614 | find-program gcmd null)) | ||
| 600 | (t | 615 | (t |
| 601 | (format "%s . <X> -type f <F> -print | \"%s\" %s" | 616 | (format "%s . <X> -type f <F> -print | \"%s\" %s" |
| 602 | find-program xargs-program gcmd)))))))) | 617 | find-program xargs-program gcmd)))))))) |