diff options
author | Tassilo Horn <tsdh@gnu.org> | 2020-05-07 19:38:57 +0200 |
---|---|---|
committer | Tassilo Horn <tsdh@gnu.org> | 2020-05-07 19:44:10 +0200 |
commit | b2581eea1be1468a15927be00ba2f3f399af33a1 (patch) | |
tree | e7d34c5fdd203e63fc0b5a07726bd4b532354e61 /lisp/net/browse-url.el | |
parent | b0f9cbb3da6124c540b0a577e0928e85b362b277 (diff) | |
download | emacs-b2581eea1be1468a15927be00ba2f3f399af33a1.tar.gz |
Allow browsing an URL explicitly with an internal or external browser.
* lisp/net/browse-url.el (browse-url-with-browser-kind): New command.
Diffstat (limited to 'lisp/net/browse-url.el')
-rw-r--r-- | lisp/net/browse-url.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 6dc9f8961a8..d7b8521563a 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -929,6 +929,34 @@ Optional prefix argument ARG non-nil inverts the value of the option (error "No URL found")))) ;;;###autoload +(defun browse-url-with-browser-kind (kind url &optional arg) + "Browse URL with a browser of the given browser KIND. +KIND is either `internal' or `external'. + +When called interactively, the default browser kind is the +opposite of the browser kind of `browse-url-browser-function'." + (interactive + (let* ((url-arg (browse-url-interactive-arg "URL: ")) + ;; Default to the inverse kind of the default browser. + (default (if (eq (browse-url--browser-kind + browse-url-browser-function (car url-arg)) + 'internal) + 'external + 'internal)) + (k (completing-read + (format "Browser kind (default %s): " default) + '(internal external) + nil t nil nil + default))) + (cons k url-arg))) + (let ((function (browse-url-select-handler url kind))) + (unless function + (setq function (if (eq kind 'external) + #'browse-url-default-browser + #'eww))) + (funcall function url arg))) + +;;;###autoload (defun browse-url-at-mouse (event) "Ask a WWW browser to load a URL clicked with the mouse. The URL is the one around or before the position of the mouse click |