[gambit-list] Attach Emacs to a web-repl?

Marc Feeley feeley at iro.umontreal.ca
Tue Oct 17 21:48:33 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 17-Oct-06, at 8:49 PM, Andrew Lentvorski wrote:

> Marc Feeley wrote:
>> On 17-Oct-06, at 7:30 PM, Andrew Lentvorski wrote:
>>> Is there any way to attach Emacs (or any other editor, for that  
>>> matter),
>>> to a web-repl?  Given that I can telnet directly to port 7000 and
>>> execute the repl, there ought to be some way.
>>>
>>> I took a quick look at cmuscheme.el, comint.el and ftelnet.el,  
>>> but my
>>> Emacs-fu is clearly not good enough.  I don't see anything obvious.
>> Depends what you mean by "attach".  One way is: C-U M-x telnet RET  
>> localhost RET 7000 RET .  If you want to be able to have several  
>> concurrent REPLs in the same Gambit process, then edit the  
>> procedure start-repl-server in web-repl.scm like this:
>
> I want to be able to use the gambit-mode in an emacs on machine A  
> running against a gambit on machine B.  That's what I mean by  
> "attach".
>
> This relates back to running gambit directly on embedded hardware.  
> Since the hardware doesn't really have a stdin/stdout, keyboard,  
> etc., I'd like to be able to control things from a separate machine.

Here's what you can do.  Apply this change to the make-ide-repl-ports  
procedure in web-repl.scm

(define (make-ide-repl-ports ide-repl-connection)
   (receive (in-rd-port in-wr-port) (open-string-pipe '(direction:  
input))
     (receive (out-wr-port out-rd-port) (open-string-pipe  
'(direction: output))
       (begin

         ; Hack... set the names of the ports for usage with gambit.el
         (##vector-set! in-rd-port 4 (lambda (port) '(stdin)))
         (##vector-set! out-wr-port 4 (lambda (port) '(stdout)))

         (ide-repl-pump ide-repl-connection out-rd-port in-wr-port)
         (values in-rd-port out-wr-port)))))

Then, after starting web-repl.scm, in your emacs type C-u M-x run- 
scheme RET (erase line) telnet localhost 7000 RET .

This way you will be running the telnet session with all the  
functionality of gambit.el .  One problem I have noticed is that you  
get a double echo of the expressions typed at the REPL.  I'm not sure  
if it is the telnet that is adding its own echo of the input.  I hope  
some emacs wizard better qualified than me can figure out what is the  
source of the problem.  Another problem is that you can't interrupt  
the execution with ctrl-C.  Telnet sends ctrl-C as the byte sequence # 
\xff #\xf4 #\xff #\xfd #\x06, so this sequence would have to be  
recognized by the process-input procedure in the ide-repl-pump  
procedure, followed by the call

(##thread-interrupt!
  primordial-thread ; or any thread you want to interrupt
  (lambda ()
    ((##current-user-interrupt-handler))
    (##void)))

so that the primordial thread handles the user-interrupt (it would be  
useless to call the user-interrupt-handler directly because this  
would interrupt the thread executing the ide-repl-pump).  I'll leave  
that as an exercise to the reader!

Marc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFNYfy//V9Zc2T/v4RAmvkAJwPIiRl8pJESHTl74kox9nFeA7eBQCfVfq6
Q3Vm/mu0cXJzDDaShlARERI=
=gSFf
-----END PGP SIGNATURE-----



More information about the Gambit-list mailing list