emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 08104c01504: Allow dired to invoke secondary browser


From: Robert Pluim
Subject: emacs-29 08104c01504: Allow dired to invoke secondary browser
Date: Mon, 29 May 2023 08:54:50 -0400 (EDT)

branch: emacs-29
commit 08104c01504f73d1c2fa7df413cad4e988dd5119
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    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.
---
 etc/NEWS               |  7 +++++++
 lisp/net/browse-url.el | 13 ++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]