From 6608ed3f2581043fb78c9bd60d867d33ef846e93 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 29 Jun 2021 07:18:45 -0700 Subject: 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. --- stdlib/doc-lookup.tl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'stdlib/doc-lookup.tl') 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" -- cgit v1.2.3