unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 63744@debbugs.gnu.org, Leo Liu <sdl.web@gmail.com>
Subject: bug#63744: 28.2; fix dired-guess-default
Date: Mon, 29 May 2023 03:23:46 +0200	[thread overview]
Message-ID: <87fs7g53rx.fsf@web.de> (raw)
In-Reply-To: <83jzwthsx5.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 28 May 2023 09:27:34 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

> > 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?

I think he means: the user should not have to do this.

> > 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?

It's a real difference, actually a real win.  Please don't only have
constant lists in mind.

"Dynamically" means that dired can inspect the matched file (the file
name is provided via the variable 'file' bound when evaluating the
expression).  This means the EXPR can look at the properties of the
file, it's type and modes etc, which allows a more fine grained user
customization.  With such a change one can have entries looking like

  (RE (if COND (GET-DEFAULTS-FOR-COND) (GET-OTHER-DEFAULTS)))

which would currently be have to be specified as several entries like

  (RE (when COND DEFAULT-FOR-COND-1))
  (RE (when COND DEFAULT-FOR-COND-2))
    ...
  (RE (when COND DEFAULT-FOR-COND-n))
  (RE (when (not COND) OTHER-DEFAULT-1))
  ...
  (RE (when (not COND) OTHER-DEFAULT-m))

and, much worse, testing the CONDITION would have to be performed many
times.

Other things are currently impossible, for example, taking the current
screen setup into account (which can change within an Emacs session).

@Leo:

> 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.

`dired-guess-default' lives in "dired-aux" now.

>  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))))))

I think we should avoid `nconc'ing: if a user does specify literal lists.
the config will be destructively altered (right?).  I think we better
use (apply #'append (mapcar ...)) or something like that.


Michael.





  reply	other threads:[~2023-05-29  1:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27  4:10 bug#63744: 28.2; fix dired-guess-default Leo Liu
2023-05-27  6:49 ` Eli Zaretskii
2023-05-28  2:40   ` Leo Liu
2023-05-28  6:27     ` Eli Zaretskii
2023-05-29  1:23       ` Michael Heerdegen [this message]
2023-05-29  3:49         ` Leo Liu
2023-05-29 12:38           ` Eli Zaretskii
2023-05-30  0:04             ` Michael Heerdegen
2023-05-29 12:07         ` Eli Zaretskii
2023-05-29 18:20           ` Leo Liu
2023-05-29 18:27             ` Eli Zaretskii
2023-05-30  0:24               ` Michael Heerdegen
2023-05-30  2:36                 ` Eli Zaretskii
2023-06-02  0:14       ` Michael Heerdegen
2023-06-02  4:28         ` Leo Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fs7g53rx.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=63744@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).