summaryrefslogtreecommitdiff
path: root/scheme/gambit/geiser/gambit.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/gambit/geiser/gambit.scm')
-rw-r--r--scheme/gambit/geiser/gambit.scm61
1 files changed, 36 insertions, 25 deletions
diff --git a/scheme/gambit/geiser/gambit.scm b/scheme/gambit/geiser/gambit.scm
index b63faa7..a33f7cc 100644
--- a/scheme/gambit/geiser/gambit.scm
+++ b/scheme/gambit/geiser/gambit.scm
@@ -1,12 +1,23 @@
;;;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-macro (geiser:capture-output x . xs)
+ (let ((out (gensym))
+ (result (gensym)))
+ `(let* ((,out (open-output-string))
+ (,result (parameterize ((current-output-port ,out))
+ ,(cons 'begin (cons x xs)))))
+ (write `((result ,(object->string ,result))
+ (out ,(get-output-string ,out))))
+ (newline))))
+
+(define (geiser:load-file filename)
+ (geiser:capture-output (load filename)))
+
+(define (geiser:eval2 module form) ;; module is not yet supported in gambit
+ (geiser:capture-output (eval form)))
+
+(define-macro (geiser:eval module form . rest)
+ `(geiser:eval2 ,module ,(quote form)))
(define (geiser:newline)
(newline))
@@ -16,21 +27,21 @@
;; 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)))
+;;(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)))