Subject: [clisp-list] inspector via browser under windows

From: Daniel Freudenthal <[email-masked]>
Date: Mon Mar 17 02:36:18 2003

This is a follow-up from an earlier post at comp.language.lisp, I'm having
problems getting the inspector via Netscape/Explorer to work under windows
(XP).

Joerg, thanks for that.

I sort of got netscape to work by changing the path and the inspector does
exactly what I want it to do. I am working on simulations that create large
trees of up to 100,000 nodes. I want to be able to inspect the root node,
and traverse the tree in the inspector window to look at the contents of
certain child nodes. The browser inspector allows me to do just that.

The following 'bugs' remain however. When using netscape, I get the proper
inspector window though netscape starts on the home page, and I have to copy
and paste the URL into it. A more serious problem however, is that when I
close Netscape (using either 'quit' as supplied on the page (URL), or
closing it completely), CLISP hangs in the inspector loop. That is, it
doesn't return me to the prompt. The only way I've figured out to 'recover'
from that, is by closing LISP completely. Hardly a recovery, but maybe I'm
overlooking something here. Using 'break' on the signals menu does't change
anything, nor does resetting the LISP connection, or typing (return) or
(break).

Explorer launches ok, is directed to the proper URL, but takes ages to load,
and gives me 'page cannot be displayed', even when I paste the URL.

I'm not sure if the other bit of code you supplied (see below) is supposed
to resolve these issues. I've tried running that, but I ran into a package
problem (got a 'package locked' message). I am not using packages in my
code, and don't know that much about using them.

On a more positive note, I would like to say that I am really pleased with
CLISP. It certainly beats Allegro which for my purposes is far too complex.
It is very easy too port code from Macintosh Common Lisp which I use at
work. It's a great program, especially considering it is free. One of my
colleagues who uses ACL at work is also considering changing to CLISP.

Thanks,

Daniel Freudenthal.

By the way, as a very minor issue, when attempting to load a lisp file from
the menu, on my system, it will switch to the prompt on the first attempt,
and only bring up a directory window at subsequent attempts. I don't know,
if this is supposed to happen, but personally, I would like the window to be
brought up the first time.

> (in-package "SYSTEM")
> (defun browse-url (url &key (browser *browser*) (out *standard-output*))
>   "Run the browser (a keyword in `*browsers*' or a list) on the URL."
>   (let* ((command
>           (etypecase browser
>             (list browser)
>             (symbol (or (cdr (assoc browser *browsers* :test #'eq))
>                         (error "unknown browser: `~s' (must be a key in `~s')"
>                                browser '*browsers*)))))
>          (args (mapcar (lambda (arg) (format nil arg url)) (cdr command))))
>     (cond (command
>            (when out
>              (format out "~&;; running [~s~{ ~s~}]..." (car command) args)
>              (force-output (if (eq out t) *standard-output* out)))
>            (run-program (car command) :arguments args
> :wait #+unix nil #-unix t)
>            (when out
>              (format out "done~%")))
>           ((format t "~s: no browser specified; please point your browser
at~%~
> --> <URL:~a>~%" 'browse-url url)))))

---

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Mon Mar 17 04:57:50 2003

Hi,

here is my attempt at solving *some* of the issues.

Daniel Freudenthal wrote:
>I'm having problems getting the inspector via Netscape/Explorer
>to work under windows (XP).
I don't have that here. It may behave very differently from 2000.

What version of CLISP are you using?

>I sort of got netscape to work by changing the path and the 
>inspector does exactly what I want it to do.
Sounds good.

>inspector window though netscape starts on the home page, and 
>I have to copy and paste the URL into it.

>A more serious problem however, is that when I
>closing it completely), CLISP hangs in the inspector loop.

That should not happen using the "quit" URL. That's a bug.
;;; If you encounter a bug in this file, please set sys::*inspect-debug*
;;; to 5 and report all output with a detailed description of what you did
;;; to <clisp-list> (see http://clisp.cons.org about CLISP mailing lists),
;;; as you do with any other CLISP bugs.
(setq sys::*inspect-debug* 5)
send output here.

OTOH, it's normal to hang when just closing the browser. The reason is that you could have N browsers open, inspecting various Lisp objects. Closing one of those must not be related to "I'm finished with the inspector HTTP server". You have to tell CLISP this fact, i.e. use the "quit" URL.

>doesn't return me to the prompt. The only way I've figured out 
>to 'recover' from that, is by closing LISP completely.
Ctrl-C should work in all cases - at least using CLISP >2.28

Looks like another bug. MS-Windows-XP seems rather different??

[69]> (inspect (list-all-packages) :frontend :http)
EXT:BROWSE-URL: no browser specified; please point your browser at
--> <URL:http://foo.telekom.de:4601/0/:s>
*** - Winsock error 10060 (ETIMEDOUT): Connection timed out
1. Break INSPECT-TMP-PACKAGE-834[70]> :a
[71]> 

BTW, this is IMHO a weird error about time-outs message just from using ctrl-C.

>Using 'break' on the signals menu does't change
How are you running CLISP? What menu is that?

>By the way, as a very minor issue, when attempting to load a 
>lisp file from the menu, on my system, it will switch to the prompt on the 
>first attempt,
Again, what menu is this?

>code, and don't know that much about using them.

Sorry for the missing instructions. Please use:

[55]> (in-package "SYSTEM")
SYS[58]> (setf (package-lock "SYSTEM") nil)
SYS[59]> (defun browse-url (url &key (browser *browser*) (out *standard-output*))
[...what I posted]

** - Continuable Error
DEFUN/DEFMACRO(BROWSE-URL): #<PACKAGE EXT> is locked
If you continue (by typing 'continue'): Ignore the lock and proceed
1. Break SYS[62]> continue
BROWSE-URL
SYS[63]> (setf (package-lock "SYSTEM") t)
T
SYS[64]> (in-package "USER")

Now, try out:
[74]> (inspect (list-all-packages) :frontend :http :browser :netscape)

;; running ["netscape" "http://127.0.0.1:4608/0/:s"]...
*** - Win32 error 2 (ERROR_FILE_NOT_FOUND): The system cannot find the file specified.
1. Break INSPECT-TMP-PACKAGE-836[75]> :a
[76]>

Oops, that problem with non-absolute pathnames in custom:*browsers* (e.g. "netscape.exe" does not work). Try:
[77]> (setq custom:*browsers*
      '(;; Sadly, location of iexplore.exe depends on MS-Windows-95/98/NT/2000/xy/z
        #+win32(:IE "C:\\PROGRA~1\\Internet Explorer\\IEXPLORE.EXE" "~a")
        ;; PROGRA~1 works with "Program Files", "Programme" and hopefully more
        ;; Netscape will detach (run asynchronously) by itself, IE does not.
        #+win32(:netscape "C:\\PROGRA~1\\Netscape\\Communicator\\Program\\netscape.exe" "-browser" "~a")
        #+win32(:emacs-w3 "C:\\PROGRA~1\\emacs-20.7\\gnuserv\\gnudoit.exe" "-q" "(w3-fetch \"~a\")")
        ;; gnuclient/gnudoit are semi-aynchronous
        #+win32(:emacs "C:\\PROGRA~1\\emacs-20.7\\gnuserv\\gnuclient.exe" "~a")
        ))

((:IE "C:\\PROGRA~1\\Internet Explorer\\IEXPLORE.EXE" "~a")
 (:NETSCAPE "C:\\PROGRA~1\\Netscape\\Communicator\\Program\\netscape.exe"
  "-browser" "~a")
 (:EMACS-W3 "C:\\PROGRA~1\\emacs-20.7\\gnuserv\\gnudoit.exe" "-q"
  "(w3-fetch \"~a\")")
 (:EMACS "C:\\PROGRA~1\\emacs-20.7\\gnuserv\\gnuclient.exe" "~a"))

[78]> (inspect (list-all-packages) :frontend :http :browser :netscape)
;; running ["C:\\PROGRA~1\\Netscape\\Communicator\\Program\\netscape.exe" "-browser" "http://127.0.0.1:4609/0/:s"]...

Now netscape works - at least for me.
You may need to visit your proxy configuration. I.e., I had to add 127.0.0.1 to the comma-separated list of hosts not to be looked up via proxy before this actually worked.

Now, let's look at MS-IE. [MS-IE waits forever...] Oh well, you cannot use
(inspect ... :browser :ie) for the reasons I explained in cll. CLISP waits for MS-IE to terminate (or detach) in order to start the web-server. MS-IE does not do this and waits for CLISP: it's a dead-lock.
As I said in cll, you'll have to copy&paste the URL with MS-IE and use :browser nil.

Maybe there's also a -detach option to MS-IE. I don't know. More generally, some MS-Windows guru will have to add code to CLISP so that it can asynchronously start processes. That's what's needed here.

[trying out things] Oops, now I maybe see one of your problems: CLISP has started MS-IE, and I cannot ctrl-C CLISP anymore while it's waiting for the program to terminate. I must quit MS-IE first. Then only will CLISP display:
*** - Ctrl-C: User break
1. Break INSPECT-TMP-PACKAGE-839[85]> :a

OTOH, using MS-IE with copy&paste URLs works for me:
[86]> (inspect (list-all-packages) :frontend :http)
EXT:BROWSE-URL: no browser specified; please point your browser at
--> <URL:http://foo.bar.telekom.de:4627/0/:s>
[navigate in MS-IE, then use "quit" URL.]

Maybe MS-IE is unable to resolve the FQDN URL - a proxy settings problem?
Please try out:
http://127.0.0.1:4627/0/:s
http://localhost:4627/0/:s
instead of
http://foo.bar.telekom.de:4627/0/:s which CLISP tells you
- replacing 4627 with what your CLISP tells you, then report here.

Regards,
	Jorg Hohle.