diff options
author | mathieu2em <math.per@hotmail.com> | 2019-07-08 17:01:28 -0400 |
---|---|---|
committer | mathieu2em <math.per@hotmail.com> | 2019-08-20 15:31:38 -0400 |
commit | b7390195ae692f6f5cbf87c5c7c62afcd5966494 (patch) | |
tree | c5a004b58c71aa99478662139020922f1f34bd66 /scheme/gambit/geiser | |
parent | 9ea52349fbdb06ffa3f51d817dd49afa62b644c4 (diff) | |
download | geiser-guile-b7390195ae692f6f5cbf87c5c7c62afcd5966494.tar.gz geiser-guile-b7390195ae692f6f5cbf87c5c7c62afcd5966494.tar.bz2 |
marshall eval and load-file
Diffstat (limited to 'scheme/gambit/geiser')
-rw-r--r-- | scheme/gambit/geiser/gambit.scm | 61 |
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))) |