aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2023-11-30 19:39:16 +0200
committerJuri Linkov2023-11-30 19:39:16 +0200
commit5519ec4746ffdabfa949ea9d7e562feb2458f35c (patch)
tree26edc6c788ae74d5095be2e31b4efa7f0237194e
parentdcd755dabcf9ef95d6d0534c11c668f44c6f89c2 (diff)
downloademacs-5519ec4746ffdabfa949ea9d7e562feb2458f35c.tar.gz
emacs-5519ec4746ffdabfa949ea9d7e562feb2458f35c.zip
* 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.
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/dired-aux.el22
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.
505 505
506*** New user option 'shell-command-guess-functions'. 506*** New user option 'shell-command-guess-functions'.
507It defines how to populate a list of commands available 507It defines how to populate a list of commands available
508for 'M-!', 'M-&', '!', '&' based on marked files in Dired. 508for 'M-!', 'M-&', '!', '&' and the context menu "Open With"
509Possible backends are 'dired-guess-default', MIME types, 509based on marked files in Dired. Possible backends are
510XDG configuration. 510'dired-guess-default', MIME types, XDG configuration
511and a universal command such as "open" or "start"
512that delegates to the OS.
511 513
512** Ediff 514** Ediff
513 515
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."
1329 (choice (function-item shell-command-guess-dired) 1329 (choice (function-item shell-command-guess-dired)
1330 (function-item shell-command-guess-mailcap) 1330 (function-item shell-command-guess-mailcap)
1331 (function-item shell-command-guess-xdg) 1331 (function-item shell-command-guess-xdg)
1332 (function-item shell-command-guess-open)
1332 (function :tag "Custom function"))) 1333 (function :tag "Custom function")))
1333 :group 'dired 1334 :group 'dired
1334 :version "30.1") 1335 :version "30.1")
@@ -1380,6 +1381,27 @@ after adding own commands to the composite list."
1380 xdg-mime-apps))) 1381 xdg-mime-apps)))
1381 (append xdg-commands commands))) 1382 (append xdg-commands commands)))
1382 1383
1384(defcustom shell-command-guess-open
1385 (cond
1386 ((executable-find "xdg-open")
1387 "xdg-open")
1388 ((memq system-type '(gnu/linux darwin))
1389 "open")
1390 ((memq system-type '(windows-nt ms-dos))
1391 "start")
1392 ((eq system-type 'cygwin)
1393 "cygstart")
1394 ((executable-find "run-mailcap")
1395 "run-mailcap"))
1396 "A shell command to open a file externally."
1397 :type 'string
1398 :group 'dired
1399 :version "30.1")
1400
1401(defun shell-command-guess-open (commands _files)
1402 "Populate COMMANDS by the `open' command."
1403 (append (ensure-list shell-command-guess-open) commands))
1404
1383 1405
1384;;; Commands that delete or redisplay part of the dired buffer 1406;;; Commands that delete or redisplay part of the dired buffer
1385 1407