Subject: bug#20728: 25.0.50; grep and grep-find templates should have a place holder for the --color argument

From: Dmitry Gutov <[email-masked]>
Date: Mon, 29 Jun 2015 19:11:19 +0300

On 06/29/2015 06:26 PM, Eli Zaretskii wrote:

>> On the other hand, we might want to choose to set
>> `grep-highlight-matches' to `always' in grep-compute-defaults,
>> irrespective of the OS.
>
> Won't that bring back the problem in symref/grep.el again?

Why would it?

The replace (replace-regexp-in-string "--color=always" ...) call is 
still there. I didn't change that because CEDET supposedly needs to 
retain compatibility with previous Emacs versions.

But there is a similar function: xref-collect-matches.

Looking at it now, I forgot to apply a relevant fix to it (and this is 
an example of a Lisp code author doing the wrong thing because `auto' 
happened to make things right anyway, on my machine). So could you:

- Try M-x xref-find-regexp on a Windows machine (in an Elisp buffer, 
enter something like "xref-find-").
- Probably see it fail for the same reason as symref/grep.el did previously.
- Apply the patch below.
- Hopefully see it succeed and write back about that.

 > Assuming we can count on commands that live far away, like
 > symref/grep.el, to make a point of doing this, it will work, of
 > course.

The idea is to force their authors to do it (because the commands won't 
work otherwise).

Patch:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 50d52d0..bb2546f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -749,8 +749,10 @@ tools are used, and when."
    (require 'semantic/fw)
    (grep-compute-defaults)
    (defvar grep-find-template)
+  (defvar grep-highlight-matches)
    (let* ((grep-find-template (replace-regexp-in-string "-e " "-E "
 
grep-find-template t t))
+         (grep-highlight-matches nil)
           (command (rgrep-default-command (xref--regexp-to-extended regexp)
                                           "*.*" dir))
           (orig-buffers (buffer-list))