summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-29 07:18:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-29 07:18:45 -0700
commit6608ed3f2581043fb78c9bd60d867d33ef846e93 (patch)
treeb48841b105807a36ae65e471809a58232709e495 /stdlib
parentc0fd923158dd56e4c8c19a7f60c64c39c7c8a1d4 (diff)
downloadtxr-6608ed3f2581043fb78c9bd60d867d33ef846e93.tar.gz
txr-6608ed3f2581043fb78c9bd60d867d33ef846e93.tar.bz2
txr-6608ed3f2581043fb78c9bd60d867d33ef846e93.zip
doc-lookup: use BROWSER variable; provide fallback.
* stdlib/doc-lookup.tl (open-url): On non-Windows platforms, search for a program specified by the BROWSER variable, then by the URL-opening utility, and finally thorugh a fallback list of browsers. * txr.1: Documentation updated.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/doc-lookup.tl16
1 files changed, 13 insertions, 3 deletions
diff --git a/stdlib/doc-lookup.tl b/stdlib/doc-lookup.tl
index 1d02049e..110d37d4 100644
--- a/stdlib/doc-lookup.tl
+++ b/stdlib/doc-lookup.tl
@@ -28,11 +28,21 @@
(caseql os-symbol
((:linux :macos :solaris :solaris10 :android)
(defun open-url (url)
- (detached-run (caseql os-symbol
+ (let ((opener (caseql os-symbol
((:linux :solaris :android) "xdg-open")
(:solaris10 "/usr/dt/bin/sdtwebclient")
- (:macos "open"))
- (list url))))
+ (:macos "open")))
+ (fallback '#"firefox iceweasel seamonkey mozilla \
+ epiphany konqueror chromium chromium-browser \
+ google-chrome"))
+ (let ((prog (or (getenv "BROWSER")
+ (if (abs-path-p opener)
+ opener
+ (path-search opener))
+ [find-true path-search fallback])))
+ (if prog
+ (detached-run prog (list url))
+ (error "~s: no URL-opening method available" 'open-url))))))
((:cygwin :cygnal)
(with-dyn-lib "shell32.dll"
(deffi shell-execute "ShellExecuteW"