summaryrefslogtreecommitdiff
path: root/scheme/gambit/geiser/gambit.scm
blob: b63faa75f151304ccbeb2ca2b66b62f942d460b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;;gambit.scm gambit geiser interaction

(define (geiser-load-file file)
  (let* ((file (if (symbol? file) (symbol->string file) file))
         (found-file (geiser-find-file file)))
    (call-with-result
     (lambda ()
       (when found-file
         (load found-file))))))

(define (geiser:newline)
  (newline))

(define (geiser:no-values)
  (values))

;; Spawn a server for remote repl access TODO make it works with remote repl

(define (geiser-start-server . rest)
  (let* ((listener (tcp-listen 0))
         (port (tcp-listener-port listener)))
    (define (remote-repl)
        (receive (in out) (tcp-accept listener)
          (current-input-port in)
          (current-output-port out)
          (current-error-port out)
          
          (repl)))
    
    (thread-start! (make-thread remote-repl))
    
    (write-to-log `(geiser-start-server . ,rest))
    (write-to-log `(port ,port))

    (write `(port ,port))
    (newline)))