Subject: bug#13152: 24.2.90; [REGRESSION] dired-get-marked-files changed

From: Leo Liu <[email-masked]>
Date: Fri, 04 Jan 2013 11:49:59 +0800

On 2012-12-15 18:59 +0800, Juri Linkov wrote:
> I agree it shouldn't matter in which buffer FUNCTION is called.
> The problem is caused by the flawed design of dired-x where
> `dired-guess-default' doesn't propagate the value of `files'
> to the evaluated expressions in `dired-guess-shell-alist-default'.

Ideally, yes. But not common in elisp where stateful is the norm. We
just have to use the least surprise principle.

> Also note how `dired-guess-shell-alist-default' is forced to use the
> dynamically bound variable `file'.
>
> The proper fix would be to redesign `dired-guess-shell-alist-default'
> to funcall lambdas with one arg `files' instead of using `eval'.
>
> So instead of
>
>   (setq dired-guess-shell-alist-user
>         '(("." (let ((files (dired-get-marked-files t current-prefix-arg)))
>                  (let (dired-guess-shell-alist-user)
>                    (dired-guess-default files))))))
>
> Leo would be able to use
>
>   (setq dired-guess-shell-alist-user
>         '(("." (lambda (files)
>                  (let (dired-guess-shell-alist-user)
>                    (dired-guess-default files))))))
>
> This could help to move useful features from dired-x.el to dired-aux.el.

This seems like a good design. Cheers.

Leo