mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-14 16:50:58 +00:00
(grep-compute-defaults): Don't set
grep-command/grep-find-command when it is already non-nil. (grep-command): Make it a user option. (grep-find-command): Likewise.
This commit is contained in:
parent
108864855a
commit
bcdb34a4a3
@ -1,6 +1,6 @@
|
||||
;;; compile.el --- run compiler as inferior of Emacs, parse error messages
|
||||
|
||||
;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Roland McGrath <roland@gnu.org>
|
||||
;; Maintainer: FSF
|
||||
@ -65,6 +65,26 @@ will be parsed and highlighted as soon as you try to move to them."
|
||||
(integer :tag "First N lines"))
|
||||
:group 'compilation)
|
||||
|
||||
(defcustom grep-command nil
|
||||
"The default grep command for \\[grep].
|
||||
The default value of this variable is set up by `grep-compute-defaults';
|
||||
call that function before using this variable in your program."
|
||||
:type 'string
|
||||
:get '(lambda (symbol)
|
||||
(or grep-command
|
||||
(progn (grep-compute-defaults) grep-command)))
|
||||
:group 'compilation)
|
||||
|
||||
(defcustom grep-find-command nil
|
||||
"The default find command for \\[grep-find].
|
||||
The default value of this variable is set up by `grep-compute-defaults';
|
||||
call that function before using this variable in your program."
|
||||
:type 'string
|
||||
:get (lambda (symbol)
|
||||
(or grep-find-command
|
||||
(progn (grep-compute-defaults) grep-find-command)))
|
||||
:group 'compilation)
|
||||
|
||||
(defvar compilation-error-list nil
|
||||
"List of error message descriptors for visiting erring functions.
|
||||
Each error descriptor is a cons (or nil). Its car is a marker pointing to
|
||||
@ -417,13 +437,6 @@ Otherwise, it saves all modified buffers without asking."
|
||||
"The default grep program for `grep-command' and `grep-find-command'.
|
||||
This variable's value takes effect when `grep-compute-defaults' is called.")
|
||||
|
||||
;; Use -e if grep supports it,
|
||||
;; because that avoids lossage if the pattern starts with `-'.
|
||||
(defvar grep-command nil
|
||||
"The default grep command for \\[grep].
|
||||
The real default value of this variable is set up by `grep-compute-defaults';
|
||||
call that function before using this variable.")
|
||||
|
||||
(defvar grep-find-use-xargs nil
|
||||
"Whether \\[grep-find] uses the `xargs' utility by default.
|
||||
|
||||
@ -432,11 +445,6 @@ if not nil and not `gnu', it uses `find -print' and `xargs'.
|
||||
|
||||
This variable's value takes effect when `grep-compute-defaults' is called.")
|
||||
|
||||
(defvar grep-find-command nil
|
||||
"The default find command for \\[grep-find].
|
||||
The default value of this variable is set up by `grep-compute-defaults';
|
||||
call that function before using this variable.")
|
||||
|
||||
;;;###autoload
|
||||
(defcustom compilation-search-path '(nil)
|
||||
"*List of directories to search for source files named in error messages.
|
||||
@ -562,14 +570,15 @@ to a function that generates a unique name."
|
||||
(cons msg code)))))
|
||||
|
||||
(defun grep-compute-defaults ()
|
||||
(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-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
|
||||
@ -580,15 +589,16 @@ to a function that generates a unique name."
|
||||
"-0" "-e" "echo")
|
||||
0))
|
||||
'gnu)))
|
||||
(setq grep-find-command
|
||||
(cond ((eq grep-find-use-xargs 'gnu)
|
||||
(format "find . -type f -print0 | xargs -0 -e %s"
|
||||
grep-command))
|
||||
(grep-find-use-xargs
|
||||
(format "find . -type f -print | xargs %s" grep-command))
|
||||
(t (cons (format "find . -type f -exec %s {} %s \\;"
|
||||
grep-command null-device)
|
||||
(+ 22 (length grep-command)))))))
|
||||
(unless grep-find-command
|
||||
(setq grep-find-command
|
||||
(cond ((eq grep-find-use-xargs 'gnu)
|
||||
(format "find . -type f -print0 | xargs -0 -e %s"
|
||||
grep-command))
|
||||
(grep-find-use-xargs
|
||||
(format "find . -type f -print | xargs %s" grep-command))
|
||||
(t (cons (format "find . -type f -exec %s {} %s \\;"
|
||||
grep-command null-device)
|
||||
(+ 22 (length grep-command))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun grep (command-args)
|
||||
|
Loading…
Reference in New Issue
Block a user