diff options
| author | Daniel Mendler | 2024-12-12 12:15:10 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2024-12-21 11:31:35 +0200 |
| commit | 0f645b92ed3e82f149de468df7ebe0eda5104aca (patch) | |
| tree | 592c94f0a0ab898e43150ea238aaa4fa29c56e1c | |
| parent | 40145ba971942eb8b2b9db1e28b513b1f3fdda6f (diff) | |
| download | emacs-0f645b92ed3e82f149de468df7ebe0eda5104aca.tar.gz emacs-0f645b92ed3e82f149de468df7ebe0eda5104aca.zip | |
browse-url-with-browser-kind: Improve browser function selection
In order to find an appropriate browser function for the given
kind, first the browser handler lists are consulted. If no
handler is found, the `browse-url-browser-function',
`browse-url-secondary-browser-function`,
`browse-url-default-browser' and `eww' are tried in that order
until a browser function with a matching kind is found. This
way the user customization of `browse-url-browser-function' and
`browse-url-secondary-browser-function` is respected by
`browse-url-with-browser-kind'.
* lisp/net/browse-url.el (browse-url-with-browser-kind): Try the
browser functions in the aforementioned order. (Bug#74820)
| -rw-r--r-- | lisp/net/browse-url.el | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index eea7dac2f97..ab6f8f8aff3 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el | |||
| @@ -974,7 +974,13 @@ Optional prefix argument ARG non-nil inverts the value of the option | |||
| 974 | ;;;###autoload | 974 | ;;;###autoload |
| 975 | (defun browse-url-with-browser-kind (kind url &optional arg) | 975 | (defun browse-url-with-browser-kind (kind url &optional arg) |
| 976 | "Browse URL with a browser of the given browser KIND. | 976 | "Browse URL with a browser of the given browser KIND. |
| 977 | KIND is either `internal' or `external'. | 977 | |
| 978 | KIND is either `internal' or `external'. In order to find an | ||
| 979 | appropriate browser for the given KIND, first the `browse-url-handlers' | ||
| 980 | and `browse-url-default-handlers' lists are consulted. If no handler is | ||
| 981 | found, the functions `browse-url-browser-function', | ||
| 982 | `browse-url-secondary-browser-function', `browse-url-default-browser' | ||
| 983 | and `eww' are tried in that order. | ||
| 978 | 984 | ||
| 979 | When called interactively, the default browser kind is the | 985 | When called interactively, the default browser kind is the |
| 980 | opposite of the browser kind of `browse-url-browser-function'." | 986 | opposite of the browser kind of `browse-url-browser-function'." |
| @@ -994,9 +1000,14 @@ opposite of the browser kind of `browse-url-browser-function'." | |||
| 994 | (cons k url-arg))) | 1000 | (cons k url-arg))) |
| 995 | (let ((function (browse-url-select-handler url kind))) | 1001 | (let ((function (browse-url-select-handler url kind))) |
| 996 | (unless function | 1002 | (unless function |
| 997 | (setq function (if (eq kind 'external) | 1003 | (setq function |
| 998 | #'browse-url-default-browser | 1004 | (seq-find |
| 999 | #'eww))) | 1005 | (lambda (fun) |
| 1006 | (eq kind (browse-url--browser-kind fun url))) | ||
| 1007 | (list browse-url-browser-function | ||
| 1008 | browse-url-secondary-browser-function | ||
| 1009 | #'browse-url-default-browser | ||
| 1010 | #'eww)))) | ||
| 1000 | (funcall function url arg))) | 1011 | (funcall function url arg))) |
| 1001 | 1012 | ||
| 1002 | ;;;###autoload | 1013 | ;;;###autoload |