Subject: 28.2; fix dired-guess-default

From: Leo Liu <[email-masked]>
Date: Sat, 27 May 2023 12:10:15 +0800

I have this customisation

(setq dired-guess-shell-alist-user '(("." EXP)))

where EXP evaluates to a list of strings. It has been working for ~10
years until Emacs 28.

After some digging it turns out there is a rewrite of
`dired-guess-default' which is not compatible. Previously returning a
list of strings from EXP accidentally worked.

  (eval (car cmds) `((file . ,file)))  ; single command

but if it evaluates to a list of strings it is perfectly fine as per the
documentation of dired-guess-default. I propose the following patch for
remedy.

>From 16fbf6eb7e054d715326801647af579715f2911f Mon Sep 17 00:00:00 2001
From: Leo Liu <[email-masked]>
Date: Sat, 27 May 2023 12:03:08 +0800
Subject: [PATCH] Fix dired-guess-default

* lisp/dired-x.el (dired-guess-shell-alist-user): Document COMMAND can
also return a list of strings.
(dired-guess-default): Handle list of strings from eval COMMAND.
---
 lisp/dired-x.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index bc85da2c..0420a86c 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -950,9 +950,9 @@ If several files are to be processed, REGEXP has to match all the
 files.
 
 Each COMMAND can either be a string or a Lisp expression that evaluates
-to a string.  If this expression needs to consult the name of the file for
-which the shell commands are being requested, it can access that file name
-as the variable `file'.
+to a string or list of strings.  If this expression needs to consult
+the name of the file for which the shell commands are being requested,
+it can access that file name as the variable `file'.
 
 If several COMMANDs are given, the first one will be the default
 and the rest will be added temporarily to the history and can be retrieved
@@ -975,9 +975,9 @@ See `dired-guess-shell-alist-user'."
   (let* ((case-fold-search dired-guess-shell-case-fold-search)
          (programs
           (delete-dups
-           (mapcar
+           (mapcan
             (lambda (command)
-              (eval command `((file . ,(car files)))))
+              (ensure-list (eval command `((file . ,(car files))))))
             (seq-reduce
              #'append
              (mapcar #'cdr
-- 
2.32.0 (Apple Git-132)