From: Robert Pluim Date: Tue, 25 Apr 2023 10:28:47 +0000 (+0200) Subject: Allow dired to invoke secondary browser X-Git-Tag: emacs-29.0.92~77 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08104c01504f73d1c2fa7df413cad4e988dd5119;p=emacs.git Allow dired to invoke secondary browser 'browse-url-of-dired-file' always invokes the primary browser, but sometimes it's handy to call a different browser, which is why 'browse-url-secondary-browser-function' exists. * lisp/net/browse-url.el (browse-url-of-dired-file): Call 'browse-url-secondary-browser-function' when invoked with a prefix argument. * etc/NEWS: Announce the change. --- diff --git a/etc/NEWS b/etc/NEWS index e33e40d9009..7785d734a6f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1692,6 +1692,13 @@ the following to your Init file: *** New command 'dired-do-eww'. This command visits the file on the current line with EWW. +--- +*** 'browse-url-of-dired-file' can now call the secondary browser. +When invoked with a prefix arg, this will now call +'browse-url-secondary-browser-function' instead of the default +browser. 'browse-url-of-dired-file' is bound to 'W' by default in +dired mode. + --- *** New user option 'dired-omit-lines'. This is used by 'dired-omit-mode', and now allows you to hide based on diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 0177d12f236..39513b8f602 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -825,10 +825,17 @@ If optional arg TEMP-FILE-NAME is non-nil, delete it instead." (&optional localp no-error-if-not-filep)) ;;;###autoload -(defun browse-url-of-dired-file () - "In Dired, ask a WWW browser to display the file named on this line." - (interactive) +(defun browse-url-of-dired-file (&optional secondary) + "In Dired, ask a WWW browser to display the file named on this line. +With prefix arg, use the secondary browser instead (e.g. EWW if +`browse-url-secondary-browser-function' is set to +`eww-browse-url'." + (interactive "P") (let ((tem (dired-get-filename t t)) + (browse-url-browser-function + (if secondary + browse-url-secondary-browser-function + browse-url-browser-function)) ;; Some URL handlers open files in Emacs. We want to always ;; open in a browser, so disable those. (browse-url-default-handlers nil))