From: Juri Linkov Date: Tue, 18 Nov 2014 22:05:09 +0000 (+0200) Subject: * lisp/progmodes/grep.el (grep-compute-defaults): Compute grep-highlight-matches... X-Git-Tag: emacs-25.0.90~2635^2~420 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=239aa11e1eeb1aa7a1247c40cfac2fe43b715e25;p=emacs.git * lisp/progmodes/grep.el (grep-compute-defaults): Compute grep-highlight-matches before its use. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ba01694c5dd..7763d257224 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-11-18 Juri Linkov + + * progmodes/grep.el (grep-compute-defaults): + Compute grep-highlight-matches before its use. + 2014-11-18 Juri Linkov * replace.el (query-replace-from-to-separator): Turn defvar into diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index fd48adc70c6..b0d4b5ac377 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -556,6 +556,18 @@ This function is called from `compilation-filter-hook'." (looking-at (concat (regexp-quote hello-file) ":[0-9]+:English"))))))))) + + (when (eq grep-highlight-matches 'auto-detect) + (setq grep-highlight-matches + (with-temp-buffer + (and (grep-probe grep-program '(nil t nil "--help")) + (progn + (goto-char (point-min)) + (search-forward "--color" nil t)) + ;; Windows and DOS pipes fail `isatty' detection in Grep. + (if (memq system-type '(windows-nt ms-dos)) + 'always 'auto))))) + (unless (and grep-command grep-find-command grep-template grep-find-template) (let ((grep-options @@ -632,16 +644,6 @@ This function is called from `compilation-filter-hook'." (t (format "%s . -type f -print | \"%s\" %s" find-program xargs-program gcmd)))))))) - (when (eq grep-highlight-matches 'auto-detect) - (setq grep-highlight-matches - (with-temp-buffer - (and (grep-probe grep-program '(nil t nil "--help")) - (progn - (goto-char (point-min)) - (search-forward "--color" nil t)) - ;; Windows and DOS pipes fail `isatty' detection in Grep. - (if (memq system-type '(windows-nt ms-dos)) - 'always 'auto))))) ;; Save defaults for this host. (setq grep-host-defaults-alist