users might find less cryptic. See the Info node "(elisp) cond* Macro"
for details.
+---
+** New function 'shell-command-do-open'.
+This lets a Lisp program access the core functionality of the
+'dired-do-open' command. It opens a file or files using an external
+program, choosing the program according to the operating system's
+conventions.
+
\f
* Changes in Emacs 31.1 on Non-Free Operating Systems
(declare-function w32-shell-execute "w32fns.c")
;;;###autoload
-(defun dired-do-open (&optional arg)
- "Open all marked (or next ARG) files using an external program.
+(defun shell-command-do-open (files)
+ "Open each of FILES using an external program.
This \"opens\" the file(s) using the external command that is most
-appropriate for the file(s) according to the system conventions.
-If files are marked, run the command on each marked file. Otherwise,
-run it on the next ARG files, or on the file at mouse-click, or on the
-file at point. The appropriate command to \"open\" a file on each
-system is determined by `shell-command-guess-open'."
- (interactive "P" dired-mode)
- (let ((files (if (mouse-event-p last-nonmenu-event)
- (save-excursion
- (mouse-set-point last-nonmenu-event)
- (dired-get-marked-files nil arg))
- (dired-get-marked-files nil arg)))
- (command shell-command-guess-open))
+appropriate for the file(s) according to the system conventions."
+ (let ((command shell-command-guess-open))
(when (and (memq system-type '(windows-nt))
(equal command "start"))
(setq command "open"))
(call-process command nil 0 nil file))))
(error "Open not supported on this system"))))
+;;;###autoload
+(defun dired-do-open (&optional arg)
+ "Open all marked (or next ARG) files using an external program.
+This \"opens\" the file(s) using the external command that is most
+appropriate for the file(s) according to the system conventions.
+If files are marked, run the command on each marked file. Otherwise,
+run it on the next ARG files, or on the file at mouse-click, or on the
+file at point. The appropriate command to \"open\" a file on each
+system is determined by `shell-command-guess-open'."
+ (interactive "P" dired-mode)
+ (shell-command-do-open (if (mouse-event-p last-nonmenu-event)
+ (save-excursion
+ (mouse-set-point last-nonmenu-event)
+ (dired-get-marked-files nil arg))
+ (dired-get-marked-files nil arg))))
+
\f
;;; Commands that delete or redisplay part of the dired buffer