Subject: bug#27239: 25.1; grep: current symbol substitutes part of grep-command

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 12 Dec 2020 13:54:36 +0100

Yuri Khan <[email-masked]> writes:

> $ emacs -Q
>
> (setq grep-command "git --no-pager grep --no-index -Hn -E -e ") C-x C-e
> (setq grep-use-null-device nil) C-x C-e
>
> M-x grep RET
>
> ⇒ Run grep (like this): git --no-pager grep --no-index -Hn -E -e
>
> <down>
>
> ⇒ Run grep (like this): git --no-pager '' --no-index -Hn -E -e
>
> Observed behavior: ‘grep’ takes the last command from the history and
> replaces the first argument that does not start with a hyphen-minus with
> the current symbol. This is not documented anywhere.

(This bug report unfortunately didn't get any response at the time.)

This behaviour is still present in Emacs 28.

> Expected behavior: It would probably make sense to just generate the new
> command by concatenating ‘grep-command’ and the current symbol, without
> any heuristics to remove the search pattern from the previous command.

Yes, I think so, too.  Anybody have an opinion here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no