Subject: bug#63744: 28.2; fix dired-guess-default

From: Eli Zaretskii <[email-masked]>
Date: Sun, 28 May 2023 09:27:34 +0300

> From: Leo Liu <[email-masked]>
> Date: Sun, 28 May 2023 10:40:16 +0800
> 
> On 2023-05-27 09:49 +0300, Eli Zaretskii wrote:
> [snipped 10 lines]
> > What is the semantics of a list of strings in this case?
> > shell-command takes a single string as its argument COMMAND, it
> > doesn't take a list of strings.
> 
> See the documentation of dired-guess-default.
> 
> ,----
> | Return a shell command, or a list of commands, appropriate for FILES.
> `----

That's not the same, but I get the intent.

> > I'd rather not proliferate an undocumented "feature" that is merely a
> > side effect of the particular implementation we had at some point,
> > without understanding what it gives us. 
> 
> I agree in principle.
> 
> > The alternative is for you to change your customization so that EXP
> > returns the car of the list it returned before, and that should be
> > both easy and backward-compatible, AFAIU.
> 
> Unfortunately many (or most) things in Emacs grow from a 50% solution.

Where are you when I'm trying to convince people on emacs-devel not to
install such 50% solutions?  If every marginally-useful change that
can "potentially" help someone is press-pushed into the code base,
with the main reason being "why not?", the result is what you observe.
But almost no one tries to see this in advance when half-baked changes
are brought up, so stuff gets in.  Help in reviewing extensions and
noticing such marginal solutions will be greatly appreciated.

But I digress.

> There is no alternative at the moment other than redefining
> dired-guess-default.

But your suggestion is also a change in that function, so what's the
difference?

> If you have a static list it can be expressed as an element in
> dired-guess-shell-alist-user as such:
> 
>    (RE "STR1" "STR2" ...)
> 
> If you have a dynamic list (for example a list from querying the OS) you
> are stuck. The patch makes this possible and in my view makes
> dired-guess-shell-alist-user more coherent. (RE "STR1" "STR2" ...) can
> be regarded as another syntax for
> 
>    (RE ("STR1" "STR2" ...))

Can't you generate the entire value of dired-guess-shell-alist-user
dynamically, including the RE part?

Anyway, you are requesting a new feature: that the elements of the
alist could be of the form (REGEXP (COMMAND1 COMMAND2 ...)).  I don't
see how this makes dired-guess-shell-alist-user more coherent, but I
have nothing against such an extension.  However, it's too late for
such extensions on the emacs-29 release branch, so it could only go to
master, for Emacs 30.  And it should be properly documented, of
course.