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.
This commit is contained in:
Robert Pluim 2023-04-25 12:28:47 +02:00
parent a3063f0bc8
commit 08104c0150
2 changed files with 17 additions and 3 deletions

View file

@ -1692,6 +1692,13 @@ the following to your Init file:
*** New command 'dired-do-eww'. *** New command 'dired-do-eww'.
This command visits the file on the current line with 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'. *** New user option 'dired-omit-lines'.
This is used by 'dired-omit-mode', and now allows you to hide based on This is used by 'dired-omit-mode', and now allows you to hide based on

View file

@ -825,10 +825,17 @@ If optional arg TEMP-FILE-NAME is non-nil, delete it instead."
(&optional localp no-error-if-not-filep)) (&optional localp no-error-if-not-filep))
;;;###autoload ;;;###autoload
(defun browse-url-of-dired-file () (defun browse-url-of-dired-file (&optional secondary)
"In Dired, ask a WWW browser to display the file named on this line." "In Dired, ask a WWW browser to display the file named on this line.
(interactive) 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)) (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 ;; Some URL handlers open files in Emacs. We want to always
;; open in a browser, so disable those. ;; open in a browser, so disable those.
(browse-url-default-handlers nil)) (browse-url-default-handlers nil))