开发者

Opening an HTML page in a browser from Common Lisp

My Common Lisp program writes out an开发者_如何学JAVA HTML file. I then want to launch this file in the user's default browser.

Is there a way of doing this in Common Lisp? Moreover, is there an OS-independent way of doing this?


This depends on the Common Lisp implementation and possibly the platform it runs on (Windows, Mac, Linux, ...).

LispWorks provides the function SYS:OPEN-URL. See http://www.lispworks.com/documentation/lw60/LW/html/lw-1369.htm#pgfId-1219832

(sys:open-url "http://www.foo.com/")

One certainly can also use a file URL.


No. That would be a pretty useful thing to do, so if you write code to do it portably, share!


There is no standard way to do it, but there is a reasonably portable library that can execute shell commands.


This project is the answer https://github.com/eudoxia0/trivial-open-browser.

TLDR;

You can use uiop:run-program for that. Argument will depend on the system that is running, e.g. on MacOS it is "open http://www.example.com/" (see https://github.com/eudoxia0/trivial-open-browser/blob/master/src/trivial-open-browser.lisp)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜