diff options
| author | Richard M. Stallman | 2002-02-06 15:37:35 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-02-06 15:37:35 +0000 |
| commit | 238a5a50e51924b4e7a8c8df4072fe6e82f13787 (patch) | |
| tree | a1959fd8007379f1bcdaea61df502a73a4b5bca7 | |
| parent | 27bde5f0d3758ad50ae5ae2ff1053d671a48468b (diff) | |
| download | emacs-238a5a50e51924b4e7a8c8df4072fe6e82f13787.tar.gz emacs-238a5a50e51924b4e7a8c8df4072fe6e82f13787.zip | |
(grep-compute-defaults): Definition moved up.
| -rw-r--r-- | lisp/progmodes/compile.el | 112 |
1 files changed, 57 insertions, 55 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index ed0616aabd6..1bf72c0b62e 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el | |||
| @@ -66,6 +66,63 @@ will be parsed and highlighted as soon as you try to move to them." | |||
| 66 | (integer :tag "First N lines")) | 66 | (integer :tag "First N lines")) |
| 67 | :group 'compilation) | 67 | :group 'compilation) |
| 68 | 68 | ||
| 69 | ;;; This has to be here so it can be called | ||
| 70 | ;;; by the following defcustoms. | ||
| 71 | (defun grep-compute-defaults () | ||
| 72 | (unless (or (not grep-use-null-device) (eq grep-use-null-device t)) | ||
| 73 | (setq grep-use-null-device | ||
| 74 | (with-temp-buffer | ||
| 75 | (let ((hello-file (expand-file-name "HELLO" data-directory))) | ||
| 76 | (not | ||
| 77 | (and (equal (condition-case nil | ||
| 78 | (if grep-command | ||
| 79 | ;; `grep-command' is already set, so | ||
| 80 | ;; use that for testing. | ||
| 81 | (call-process-shell-command | ||
| 82 | grep-command nil t nil | ||
| 83 | "^English" hello-file) | ||
| 84 | ;; otherwise use `grep-program' | ||
| 85 | (call-process grep-program nil t nil | ||
| 86 | "-nH" "^English" hello-file)) | ||
| 87 | (error nil)) | ||
| 88 | 0) | ||
| 89 | (progn | ||
| 90 | (goto-char (point-min)) | ||
| 91 | (looking-at | ||
| 92 | (concat (regexp-quote hello-file) | ||
| 93 | ":[0-9]+:English"))))))))) | ||
| 94 | (unless grep-command | ||
| 95 | (setq grep-command | ||
| 96 | (let ((required-options (if grep-use-null-device "-n" "-nH"))) | ||
| 97 | (if (equal (condition-case nil ; in case "grep" isn't in exec-path | ||
| 98 | (call-process grep-program nil nil nil | ||
| 99 | "-e" "foo" null-device) | ||
| 100 | (error nil)) | ||
| 101 | 1) | ||
| 102 | (format "%s %s -e " grep-program required-options) | ||
| 103 | (format "%s %s " grep-program required-options))))) | ||
| 104 | (unless grep-find-use-xargs | ||
| 105 | (setq grep-find-use-xargs | ||
| 106 | (if (and | ||
| 107 | (equal (call-process "find" nil nil nil | ||
| 108 | null-device "-print0") | ||
| 109 | 0) | ||
| 110 | (equal (call-process "xargs" nil nil nil | ||
| 111 | "-0" "-e" "echo") | ||
| 112 | 0)) | ||
| 113 | 'gnu))) | ||
| 114 | (unless grep-find-command | ||
| 115 | (setq grep-find-command | ||
| 116 | (cond ((eq grep-find-use-xargs 'gnu) | ||
| 117 | (format "%s . -type f -print0 | xargs -0 -e %s" | ||
| 118 | find-program grep-command)) | ||
| 119 | (grep-find-use-xargs | ||
| 120 | (format "%s . -type f -print | xargs %s" | ||
| 121 | find-program grep-command)) | ||
| 122 | (t (cons (format "%s . -type f -exec %s {} %s \\;" | ||
| 123 | find-program grep-command null-device) | ||
| 124 | (+ 22 (length grep-command)))))))) | ||
| 125 | |||
| 69 | (defcustom grep-command nil | 126 | (defcustom grep-command nil |
| 70 | "The default grep command for \\[grep]. | 127 | "The default grep command for \\[grep]. |
| 71 | If the grep program used supports an option to always include file names | 128 | If the grep program used supports an option to always include file names |
| @@ -611,61 +668,6 @@ original use. Otherwise, it recompiles using `compile-command'." | |||
| 611 | (cons msg code))) | 668 | (cons msg code))) |
| 612 | (cons msg code))))) | 669 | (cons msg code))))) |
| 613 | 670 | ||
| 614 | (defun grep-compute-defaults () | ||
| 615 | (unless (or (not grep-use-null-device) (eq grep-use-null-device t)) | ||
| 616 | (setq grep-use-null-device | ||
| 617 | (with-temp-buffer | ||
| 618 | (let ((hello-file (expand-file-name "HELLO" data-directory))) | ||
| 619 | (not | ||
| 620 | (and (equal (condition-case nil | ||
| 621 | (if grep-command | ||
| 622 | ;; `grep-command' is already set, so | ||
| 623 | ;; use that for testing. | ||
| 624 | (call-process-shell-command | ||
| 625 | grep-command nil t nil | ||
| 626 | "^English" hello-file) | ||
| 627 | ;; otherwise use `grep-program' | ||
| 628 | (call-process grep-program nil t nil | ||
| 629 | "-nH" "^English" hello-file)) | ||
| 630 | (error nil)) | ||
| 631 | 0) | ||
| 632 | (progn | ||
| 633 | (goto-char (point-min)) | ||
| 634 | (looking-at | ||
| 635 | (concat (regexp-quote hello-file) | ||
| 636 | ":[0-9]+:English"))))))))) | ||
| 637 | (unless grep-command | ||
| 638 | (setq grep-command | ||
| 639 | (let ((required-options (if grep-use-null-device "-n" "-nH"))) | ||
| 640 | (if (equal (condition-case nil ; in case "grep" isn't in exec-path | ||
| 641 | (call-process grep-program nil nil nil | ||
| 642 | "-e" "foo" null-device) | ||
| 643 | (error nil)) | ||
| 644 | 1) | ||
| 645 | (format "%s %s -e " grep-program required-options) | ||
| 646 | (format "%s %s " grep-program required-options))))) | ||
| 647 | (unless grep-find-use-xargs | ||
| 648 | (setq grep-find-use-xargs | ||
| 649 | (if (and | ||
| 650 | (equal (call-process "find" nil nil nil | ||
| 651 | null-device "-print0") | ||
| 652 | 0) | ||
| 653 | (equal (call-process "xargs" nil nil nil | ||
| 654 | "-0" "-e" "echo") | ||
| 655 | 0)) | ||
| 656 | 'gnu))) | ||
| 657 | (unless grep-find-command | ||
| 658 | (setq grep-find-command | ||
| 659 | (cond ((eq grep-find-use-xargs 'gnu) | ||
| 660 | (format "%s . -type f -print0 | xargs -0 -e %s" | ||
| 661 | find-program grep-command)) | ||
| 662 | (grep-find-use-xargs | ||
| 663 | (format "%s . -type f -print | xargs %s" | ||
| 664 | find-program grep-command)) | ||
| 665 | (t (cons (format "%s . -type f -exec %s {} %s \\;" | ||
| 666 | find-program grep-command null-device) | ||
| 667 | (+ 22 (length grep-command)))))))) | ||
| 668 | |||
| 669 | ;;;###autoload | 671 | ;;;###autoload |
| 670 | (defun grep (command-args) | 672 | (defun grep (command-args) |
| 671 | "Run grep, with user-specified args, and collect output in a buffer. | 673 | "Run grep, with user-specified args, and collect output in a buffer. |