Subject: bug#18132: Time for a smarter dired-guess-shell-alist-default? (dired-x.el)

From: Eli Zaretskii <[email-masked]>
Date: Thu, 07 Dec 2023 19:48:53 +0200

> From: Juri Linkov <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  "[email-masked]"
>  <[email-masked]>
> Date: Thu, 07 Dec 2023 19:33:53 +0200
> 
> More problems: XDG has much better support for media files
> than dired-guess-shell-alist-default that contains many
> old obsolete and random commands for media files.
> OTOH, dired-guess-shell-alist-default has much better support
> for non-media files than XDG and mailcap.
> 
> So currently there is no way to configure
> shell-command-guess-functions to use only best commands.
> 
> When shell-command-guess-functions is configured to
> '(shell-command-guess-xdg shell-command-guess-dired)
> then images are opened with "xloadimage" that doesn't exist.
> 
> But when shell-command-guess-functions is configured to
> '(shell-command-guess-dired shell-command-guess-xdg)
> then images are opened with the existing program like "display",
> but then patches can't be applied, because XDG provides
> for patch files such useless commands as "more" and "less".
> 
> All this can be fixed by this patch that removes old
> media commands from 'dired-guess-shell-alist-default'.
> Then removed commands will not override media commands
> from shell-command-guess-xdg.
> 
> 
> diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
> index 0998e76c410..de54968bdbe 100644
> --- a/lisp/dired-aux.el
> +++ b/lisp/dired-aux.el
> @@ -1216,28 +1216,28 @@ dired-guess-shell-alist-default
>                    " " dired-guess-shell-znew-switches))
>     '("\\.pod\\'" "perldoc" "pod2man * | nroff -man")
>  
> -   '("\\.dvi\\'" "xdvi" "dvips")	; preview and printing
> -   '("\\.au\\'" "play")			; play Sun audiofiles
> -   '("\\.mpe?g\\'\\|\\.avi\\'" "xine -p")
> -   '("\\.ogg\\'" "ogg123")
> -   '("\\.mp3\\'" "mpg123")
> -   '("\\.wav\\'" "play")
> +   ;; '("\\.dvi\\'" "xdvi" "dvips")	; preview and printing
> +   ;; '("\\.au\\'" "play")			; play Sun audiofiles
> +   ;; '("\\.mpe?g\\'\\|\\.avi\\'" "xine -p")
> +   ;; '("\\.ogg\\'" "ogg123")
> +   ;; '("\\.mp3\\'" "mpg123")
> +   ;; '("\\.wav\\'" "play")
>     '("\\.uu\\'" "uudecode")		; for uudecoded files
>     '("\\.hqx\\'" "mcvert")
>     '("\\.sh\\'" "sh")			; execute shell scripts
> -   '("\\.xbm\\'" "bitmap")		; view X11 bitmaps
> +   ;; '("\\.xbm\\'" "bitmap")		; view X11 bitmaps
>     '("\\.gp\\'" "gnuplot")
> -   '("\\.p[bgpn]m\\'" "xloadimage")
> -   '("\\.gif\\'" "xloadimage")		; view gif pictures
> -   '("\\.tif\\'" "xloadimage")
> -   '("\\.png\\'" "display")		; xloadimage 4.1 doesn't grok PNG
> -   '("\\.jpe?g\\'" "xloadimage")
> +   ;; '("\\.p[bgpn]m\\'" "xloadimage")
> +   ;; '("\\.gif\\'" "xloadimage")		; view gif pictures
> +   ;; '("\\.tif\\'" "xloadimage")
> +   ;; '("\\.png\\'" "display")		; xloadimage 4.1 doesn't grok PNG
> +   ;; '("\\.jpe?g\\'" "xloadimage")
>     '("\\.fig\\'" "xfig")		; edit fig pictures
>     '("\\.out\\'" "xgraph")		; for plotting purposes.
>     '("\\.tex\\'" "latex" "tex")
>     '("\\.texi\\(nfo\\)?\\'" "makeinfo" "texi2dvi")
> -   '("\\.pdf\\'" "xpdf")
> -   '("\\.doc\\'" "antiword" "strings")
> +   ;; '("\\.pdf\\'" "xpdf")
> +   ;; '("\\.doc\\'" "antiword" "strings")
>     '("\\.rpm\\'" "rpm -qilp" "rpm -ivh")
>     '("\\.dia\\'" "dia")
>     '("\\.mgp\\'" "mgp")

Thanks.  However, to justify such significant changes in this
database, we need much more details: we need to know, for each guess
you want to disable or delete, when and on what platform(s) is or was
it true, when and why and on what platform(s) it stopped being true,
and what replacement(s) are available on modern platforms for those
commands that are no longer useful guesses.

And if the guesses you are removing are supposed to be guessed better
by XDG, then we should do that in a way that still supports systems
without XDG.

We cannot make such changes based only on your personal experience on
the system which you use, because we don't want to break other users'
setups.  So we must have these details to make this kind of decisions.