aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-09-13 09:11:53 +0000
committerGerd Moellmann2001-09-13 09:11:53 +0000
commitbcdb34a4a3bb0af4a816a9ed771edb907a3ac965 (patch)
tree6250e5ca62820d2d6197c079a1a236db37a72794
parent108864855af26bace526f90dae725e5db6c65c48 (diff)
downloademacs-bcdb34a4a3bb0af4a816a9ed771edb907a3ac965.tar.gz
emacs-bcdb34a4a3bb0af4a816a9ed771edb907a3ac965.zip
(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.
-rw-r--r--lisp/progmodes/compile.el70
1 files changed, 40 insertions, 30 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 0e9f6f715a4..1d75a671d1a 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1,6 +1,6 @@
1;;; compile.el --- run compiler as inferior of Emacs, parse error messages 1;;; compile.el --- run compiler as inferior of Emacs, parse error messages
2 2
3;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. 3;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001 Free Software Foundation, Inc.
4 4
5;; Author: Roland McGrath <roland@gnu.org> 5;; Author: Roland McGrath <roland@gnu.org>
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -65,6 +65,26 @@ will be parsed and highlighted as soon as you try to move to them."
65 (integer :tag "First N lines")) 65 (integer :tag "First N lines"))
66 :group 'compilation) 66 :group 'compilation)
67 67
68(defcustom grep-command nil
69 "The default grep command for \\[grep].
70The default value of this variable is set up by `grep-compute-defaults';
71call that function before using this variable in your program."
72 :type 'string
73 :get '(lambda (symbol)
74 (or grep-command
75 (progn (grep-compute-defaults) grep-command)))
76 :group 'compilation)
77
78(defcustom grep-find-command nil
79 "The default find command for \\[grep-find].
80The default value of this variable is set up by `grep-compute-defaults';
81call that function before using this variable in your program."
82 :type 'string
83 :get (lambda (symbol)
84 (or grep-find-command
85 (progn (grep-compute-defaults) grep-find-command)))
86 :group 'compilation)
87
68(defvar compilation-error-list nil 88(defvar compilation-error-list nil
69 "List of error message descriptors for visiting erring functions. 89 "List of error message descriptors for visiting erring functions.
70Each error descriptor is a cons (or nil). Its car is a marker pointing to 90Each 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."
417 "The default grep program for `grep-command' and `grep-find-command'. 437 "The default grep program for `grep-command' and `grep-find-command'.
418This variable's value takes effect when `grep-compute-defaults' is called.") 438This variable's value takes effect when `grep-compute-defaults' is called.")
419 439
420;; Use -e if grep supports it,
421;; because that avoids lossage if the pattern starts with `-'.
422(defvar grep-command nil
423 "The default grep command for \\[grep].
424The real default value of this variable is set up by `grep-compute-defaults';
425call that function before using this variable.")
426
427(defvar grep-find-use-xargs nil 440(defvar grep-find-use-xargs nil
428 "Whether \\[grep-find] uses the `xargs' utility by default. 441 "Whether \\[grep-find] uses the `xargs' utility by default.
429 442
@@ -432,11 +445,6 @@ if not nil and not `gnu', it uses `find -print' and `xargs'.
432 445
433This variable's value takes effect when `grep-compute-defaults' is called.") 446This variable's value takes effect when `grep-compute-defaults' is called.")
434 447
435(defvar grep-find-command nil
436 "The default find command for \\[grep-find].
437The default value of this variable is set up by `grep-compute-defaults';
438call that function before using this variable.")
439
440;;;###autoload 448;;;###autoload
441(defcustom compilation-search-path '(nil) 449(defcustom compilation-search-path '(nil)
442 "*List of directories to search for source files named in error messages. 450 "*List of directories to search for source files named in error messages.
@@ -562,14 +570,15 @@ to a function that generates a unique name."
562 (cons msg code))))) 570 (cons msg code)))))
563 571
564(defun grep-compute-defaults () 572(defun grep-compute-defaults ()
565 (setq grep-command 573 (unless grep-command
566 (if (equal (condition-case nil ; in case "grep" isn't in exec-path 574 (setq grep-command
567 (call-process grep-program nil nil nil 575 (if (equal (condition-case nil ; in case "grep" isn't in exec-path
568 "-e" "foo" null-device) 576 (call-process grep-program nil nil nil
569 (error nil)) 577 "-e" "foo" null-device)
570 1) 578 (error nil))
571 (format "%s -n -e " grep-program) 579 1)
572 (format "%s -n " grep-program))) 580 (format "%s -n -e " grep-program)
581 (format "%s -n " grep-program))))
573 (unless grep-find-use-xargs 582 (unless grep-find-use-xargs
574 (setq grep-find-use-xargs 583 (setq grep-find-use-xargs
575 (if (and 584 (if (and
@@ -580,15 +589,16 @@ to a function that generates a unique name."
580 "-0" "-e" "echo") 589 "-0" "-e" "echo")
581 0)) 590 0))
582 'gnu))) 591 'gnu)))
583 (setq grep-find-command 592 (unless grep-find-command
584 (cond ((eq grep-find-use-xargs 'gnu) 593 (setq grep-find-command
585 (format "find . -type f -print0 | xargs -0 -e %s" 594 (cond ((eq grep-find-use-xargs 'gnu)
586 grep-command)) 595 (format "find . -type f -print0 | xargs -0 -e %s"
587 (grep-find-use-xargs 596 grep-command))
588 (format "find . -type f -print | xargs %s" grep-command)) 597 (grep-find-use-xargs
589 (t (cons (format "find . -type f -exec %s {} %s \\;" 598 (format "find . -type f -print | xargs %s" grep-command))
590 grep-command null-device) 599 (t (cons (format "find . -type f -exec %s {} %s \\;"
591 (+ 22 (length grep-command))))))) 600 grep-command null-device)
601 (+ 22 (length grep-command))))))))
592 602
593;;;###autoload 603;;;###autoload
594(defun grep (command-args) 604(defun grep (command-args)