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

From: Juri Linkov <[email-masked]>
Date: Sat, 06 Jun 2015 01:17:52 +0300

> We'll still need that placeholder in grep-find-template (and probably in
> grep-template, for consistency).
>
> Regarding M-x grep, I would rather leave it alone for now, because
> otherwise, %s or not, that would call for renaming the variable
> grep-command, and grep-template is already taken.

There is also grep-find-command used by grep-find.

> Another option would be to perform the substitution with regexp in
> grep-default-command, and it's pretty hairy already.

Since there is a lot of %s-substitutions in grep-compute-defaults
that produce command lines depending on many customizations,
yet another option is to let-bind the variables grep-command,
grep-find-command, grep-template, grep-find-template in your function,
then call grep-compute-defaults with a new value of grep-highlight-matches,
and then get new command lines without the --color option from
these local bindings to run them and parse the output programmatically.

In case when users customize grep-highlight-matches interactively,
its defcustom should compute new command lines using grep-compute-defaults.