# HG changeset patch # User Gerd Moellmann # Date 1000372313 0 # Node ID 75fdf7bea8369355b272dd44e5317f148d03bc69 # Parent 5a3dae2132b45d42ca2c216ce4feb8029504b096 (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. diff -r 5a3dae2132b4 -r 75fdf7bea836 lisp/progmodes/compile.el --- a/lisp/progmodes/compile.el Wed Sep 12 21:04:11 2001 +0000 +++ b/lisp/progmodes/compile.el Thu Sep 13 09:11:53 2001 +0000 @@ -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 ;; Maintainer: FSF @@ -65,6 +65,26 @@ (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 @@ "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 @@ 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 @@ (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 @@ "-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)