[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5519ec4746f: * lisp/dired-aux.el (shell-command-guess-open): New
From: |
Juri Linkov |
Subject: |
master 5519ec4746f: * lisp/dired-aux.el (shell-command-guess-open): New defcustom (bug#18132). |
Date: |
Thu, 30 Nov 2023 12:40:03 -0500 (EST) |
branch: master
commit 5519ec4746ffdabfa949ea9d7e562feb2458f35c
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/dired-aux.el (shell-command-guess-open): New defcustom (bug#18132).
(shell-command-guess-open): New function.
(shell-command-guess-functions): Add 'shell-command-guess-open' to choice.
---
etc/NEWS | 8 +++++---
lisp/dired-aux.el | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 6661ac70e1b..db8a47fd739 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -505,9 +505,11 @@ default is nil.
*** 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
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 47e97c96ce1..94ca5ddbcc3 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1329,6 +1329,7 @@ such as added new commands."
(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")
@@ -1380,6 +1381,27 @@ after adding own commands to the composite list."
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))
+
;;; Commands that delete or redisplay part of the dired buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5519ec4746f: * lisp/dired-aux.el (shell-command-guess-open): New defcustom (bug#18132).,
Juri Linkov <=