diff options
author | Stefan Kangas <stefan@marxist.se> | 2021-12-07 19:46:21 +0100 |
---|---|---|
committer | Stefan Kangas <stefan@marxist.se> | 2021-12-07 19:52:56 +0100 |
commit | beed398eb5e49680b731aeacd553d357759043c1 (patch) | |
tree | 881a1a79de73a04407a04ed8c16dab5ce5ff0864 /lisp | |
parent | 9013e4ea194d0a41c9577cccef177e98dbe1268e (diff) | |
download | emacs-beed398eb5e49680b731aeacd553d357759043c1.tar.gz emacs-beed398eb5e49680b731aeacd553d357759043c1.tar.bz2 emacs-beed398eb5e49680b731aeacd553d357759043c1.zip |
browse-url: Refactor code to find executable
* lisp/net/browse-url.el (browse-url--find-executable): Extract from...
(browse-url-firefox-program, browse-url-chrome-program)
(browse-url-chromium-program): ...here.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/net/browse-url.el | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index e30c36ea4d5..d317256f06d 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -258,11 +258,13 @@ Defaults to the value of `browse-url-mozilla-arguments' at the time `browse-url' is loaded." :type '(repeat (string :tag "Argument"))) +(defun browse-url--find-executable (candidates default) + (while (and candidates (not (executable-find (car candidates)))) + (setq candidates (cdr candidates))) + (or (car candidates) default)) + (defcustom browse-url-firefox-program - (let ((candidates '("icecat" "iceweasel" "firefox"))) - (while (and candidates (not (executable-find (car candidates)))) - (setq candidates (cdr candidates))) - (or (car candidates) "firefox")) + (browse-url--find-executable '("icecat" "iceweasel") "firefox") "The name by which to invoke Firefox or a variant of it." :type 'string) @@ -280,10 +282,8 @@ Defaults to the value of `browse-url-firefox-arguments' at the time "it no longer has any effect." "24.5") (defcustom browse-url-chrome-program - (let ((candidates '("google-chrome-stable" "google-chrome"))) - (while (and candidates (not (executable-find (car candidates)))) - (setq candidates (cdr candidates))) - (or (car candidates) "chromium")) + (browse-url--find-executable '("google-chrome-stable" "google-chrome") + "chromium") "The name by which to invoke the Chrome browser." :type 'string :version "25.1") @@ -294,10 +294,7 @@ Defaults to the value of `browse-url-firefox-arguments' at the time :version "25.1") (defcustom browse-url-chromium-program - (let ((candidates '("chromium" "chromium-browser"))) - (while (and candidates (not (executable-find (car candidates)))) - (setq candidates (cdr candidates))) - (or (car candidates) "chromium")) + (browse-url--find-executable '("chromium" "chromium-browser") "chromium") "The name by which to invoke Chromium." :type 'string :version "24.1") |