66 |
(integer :tag "First N lines")) |
(integer :tag "First N lines")) |
67 |
:group 'compilation) |
:group 'compilation) |
68 |
|
|
69 |
|
(defun grep-compute-defaults () |
70 |
|
(unless grep-command |
71 |
|
(setq grep-command |
72 |
|
(if (equal (condition-case nil ; in case "grep" isn't in exec-path |
73 |
|
(call-process grep-program nil nil nil |
74 |
|
"-e" "foo" null-device) |
75 |
|
(error nil)) |
76 |
|
1) |
77 |
|
(format "%s -n -e " grep-program) |
78 |
|
(format "%s -n " grep-program)))) |
79 |
|
(unless grep-find-use-xargs |
80 |
|
(setq grep-find-use-xargs |
81 |
|
(if (and |
82 |
|
(equal (call-process "find" nil nil nil |
83 |
|
null-device "-print0") |
84 |
|
0) |
85 |
|
(equal (call-process "xargs" nil nil nil |
86 |
|
"-0" "-e" "echo") |
87 |
|
0)) |
88 |
|
'gnu))) |
89 |
|
(unless grep-find-command |
90 |
|
(setq grep-find-command |
91 |
|
(cond ((eq grep-find-use-xargs 'gnu) |
92 |
|
(format "%s . -type f -print0 | xargs -0 -e %s" |
93 |
|
find-program grep-command)) |
94 |
|
(grep-find-use-xargs |
95 |
|
(format "%s . -type f -print | xargs %s" |
96 |
|
find-program grep-command)) |
97 |
|
(t (cons (format "%s . -type f -exec %s {} %s \\;" |
98 |
|
find-program grep-command null-device) |
99 |
|
(+ 22 (length grep-command)))))))) |
100 |
|
|
101 |
(defcustom grep-command nil |
(defcustom grep-command nil |
102 |
"The default grep command for \\[grep]. |
"The default grep command for \\[grep]. |
103 |
The default value of this variable is set up by `grep-compute-defaults'; |
The default value of this variable is set up by `grep-compute-defaults'; |
611 |
(cons msg code))) |
(cons msg code))) |
612 |
(cons msg code))))) |
(cons msg code))))) |
613 |
|
|
|
(defun grep-compute-defaults () |
|
|
(unless grep-command |
|
|
(setq grep-command |
|
|
(if (equal (condition-case nil ; in case "grep" isn't in exec-path |
|
|
(call-process grep-program nil nil nil |
|
|
"-e" "foo" null-device) |
|
|
(error nil)) |
|
|
1) |
|
|
(format "%s -n -e " grep-program) |
|
|
(format "%s -n " grep-program)))) |
|
|
(unless grep-find-use-xargs |
|
|
(setq grep-find-use-xargs |
|
|
(if (and |
|
|
(equal (call-process "find" nil nil nil |
|
|
null-device "-print0") |
|
|
0) |
|
|
(equal (call-process "xargs" nil nil nil |
|
|
"-0" "-e" "echo") |
|
|
0)) |
|
|
'gnu))) |
|
|
(unless grep-find-command |
|
|
(setq grep-find-command |
|
|
(cond ((eq grep-find-use-xargs 'gnu) |
|
|
(format "%s . -type f -print0 | xargs -0 -e %s" |
|
|
find-program grep-command)) |
|
|
(grep-find-use-xargs |
|
|
(format "%s . -type f -print | xargs %s" |
|
|
find-program grep-command)) |
|
|
(t (cons (format "%s . -type f -exec %s {} %s \\;" |
|
|
find-program grep-command null-device) |
|
|
(+ 22 (length grep-command)))))))) |
|
|
|
|
614 |
;;;###autoload |
;;;###autoload |
615 |
(defun grep (command-args) |
(defun grep (command-args) |
616 |
"Run grep, with user-specified args, and collect output in a buffer. |
"Run grep, with user-specified args, and collect output in a buffer. |