*** New user option 'shell-command-guess-functions'.
It defines how to populate a list of commands available
-for 'M-!', 'M-&', '!', '&' based on marked files in Dired.
-Possible backends are 'dired-guess-default', MIME types,
-XDG configuration.
+for 'M-!', 'M-&', '!', '&' and the context menu "Open With"
+based on marked files in Dired. Possible backends are
+'dired-guess-default', MIME types, XDG configuration
+and a universal command such as "open" or "start"
+that delegates to the OS.
** Ediff
(choice (function-item shell-command-guess-dired)
(function-item shell-command-guess-mailcap)
(function-item shell-command-guess-xdg)
+ (function-item shell-command-guess-open)
(function :tag "Custom function")))
:group 'dired
:version "30.1")
xdg-mime-apps)))
(append xdg-commands commands)))
+(defcustom shell-command-guess-open
+ (cond
+ ((executable-find "xdg-open")
+ "xdg-open")
+ ((memq system-type '(gnu/linux darwin))
+ "open")
+ ((memq system-type '(windows-nt ms-dos))
+ "start")
+ ((eq system-type 'cygwin)
+ "cygstart")
+ ((executable-find "run-mailcap")
+ "run-mailcap"))
+ "A shell command to open a file externally."
+ :type 'string
+ :group 'dired
+ :version "30.1")
+
+(defun shell-command-guess-open (commands _files)
+ "Populate COMMANDS by the `open' command."
+ (append (ensure-list shell-command-guess-open) commands))
+
\f
;;; Commands that delete or redisplay part of the dired buffer