GNU bug report logs - #27236
25.1; grep: nonsensical default commands offered

Previous Next

Package: emacs;

Reported by: Yuri Khan <yuri.v.khan <at> gmail.com>

Date: Sun, 4 Jun 2017 17:24:02 UTC

Severity: minor

Found in version 25.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 27236 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuri Khan <yuri.v.khan <at> gmail.com>
Cc: 27236 <at> debbugs.gnu.org
Subject: Re: bug#27236: 25.1; grep: nonsensical default commands offered
Date: Tue, 17 May 2022 21:00:38 +0200
Yuri Khan <yuri.v.khan <at> gmail.com> writes:

> The call sequence is as follows:
>
> * ‘grep’ computes the initial command and the first default command.
> * ‘grep’ calls ‘read-shell-command’.
> * ‘read-shell-command’ calls ‘read-from-minibuffer’ with a setup hook
> that binds ‘minibuffer-default-add-function’ to
> ‘minibuffer-default-add-shell-commands’.
> * ‘minibuffer-default-add-shell-commands’ interprets the provided
> default command as a file name and consults
> ‘mailcap-file-default-commands’ for commands applicable to that file
> name.
> * The default command has no file extension, so
> ‘mailcap-file-default-commands’ assumes it is a text/plain file and
> returns a list of text editors and viewers.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Looking at this call chain, there doesn't seem to be any easy way to
defeat this behaviour -- in this case, we really don't want any of the
guesses from minibuffer-default-add-shell-commands/mailcap, I think?

So perhaps we should add a variable to inhibit this action?

On the other hand, the mailcap function is called with something that
"clearly" isn't a file, namely:

(mailcap-file-default-commands '("grep --color=auto -nH --null '' "))
=> ("/usr/bin/emacs -nw")

So perhaps we could introduce some logic to this mailcap function to
detect that we don't really have a file name here.

So I've now done the latter in Emacs 29.

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




This bug report was last modified 3 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.