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

From: Howard Melman <[email-masked]>
Date: Sun, 24 Oct 2021 12:35:23 -0400

Juri Linkov <[email-masked]> writes:

>> Such a command emulates what double clicking on an icon does
>> which most of the time is what a user wants (because it's
>> configured it do what their most common app need is).
>
> Such a command is long overdue.  I used the following command
> for a long time, and forgot it's not in dired-x.  I don't suggest
> to use this implementation, but something like this.  

FWIW, my version is quite different:

#+begin_src emacs-lisp
;;; open a file as if double clicking on its icon
(declare-function w32-shell-execute "w32fns.c")
(defun hrm-open-file (file)
  "Open FILE as the system would."
  (interactive "fFile: ")
  (cond ((memq system-type '(darwin))
         (call-process-shell-command (concat "open " (shell-quote-argument file))))
        ((memq system-type '(windows-nt))
         (w32-shell-execute "open" (convert-standard-filename file)))
        ((memq system-type '(gnu/linux))
         (call-process-shell-command (concat "xdg-open " (shell-quote-argument file))))
        (t
         (error "Open not supported on this system"))))

(defun dired-do-open (&optional arg)
  "Open the marked (or next ARG) files as the system would."
  (interactive "P")
  (mapc #'hrm-open-file (dired-get-marked-files nil arg)))
#+end_src

-- 

Howard