summaryrefslogtreecommitdiff
path: root/scheme
diff options
context:
space:
mode:
authorPeter <craven@gmx.net>2016-04-26 22:31:09 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2016-04-30 19:41:44 +0200
commitd9612b615af3cb55d98503a1a553a070f75149f2 (patch)
tree5c448da9ba189f83b6bfd6ca0cd2a64fecbaacd1 /scheme
parentfea631c41126998724f0af636ee5c90d980a7b34 (diff)
downloadgeiser-guile-d9612b615af3cb55d98503a1a553a070f75149f2.tar.gz
geiser-guile-d9612b615af3cb55d98503a1a553a070f75149f2.tar.bz2
Add preliminary support for Chibi Scheme
Diffstat (limited to 'scheme')
-rw-r--r--scheme/chibi/geiser/geiser.scm49
-rw-r--r--scheme/chibi/geiser/geiser.sld9
2 files changed, 58 insertions, 0 deletions
diff --git a/scheme/chibi/geiser/geiser.scm b/scheme/chibi/geiser/geiser.scm
new file mode 100644
index 0000000..a6b37f3
--- /dev/null
+++ b/scheme/chibi/geiser/geiser.scm
@@ -0,0 +1,49 @@
+(define (all-environment-exports environment prefix)
+ (if environment
+ (append (filter (lambda (identifier)
+ (if (string=? prefix "")
+ #t
+ (string-contains identifier prefix)))
+ (map symbol->string (env-exports environment)))
+ (all-environment-exports (env-parent environment) prefix))
+ '()))
+
+(define (geiser:completions prefix . rest)
+ rest
+ (sort (all-environment-exports (current-environment) prefix)
+ string-ci<?))
+
+(define (write-to-string form)
+ (let ((out (open-output-string)))
+ (write form out)
+ (get-output-string out)))
+
+(define (geiser:eval module form . rest)
+ rest
+ (let ((output (open-output-string))
+ (result (if module
+ (let ((mod (module-env (find-module module))))
+ (eval form mod))
+ (eval form))))
+ (write `((result ,(write-to-string result))
+ (output . ,(get-output-string output))))
+ (values)))
+
+(define (geiser:module-completions prefix . rest)
+ (let ((modules (map car (available-modules))))
+ (map write-to-string
+ (delete-duplicates
+ (filter (lambda (module)
+ (if (string=? "" prefix)
+ #t
+ (string-contains prefix (write-to-string module))))
+ modules)))))
+
+(define (geiser:autodoc ids . rest)
+ '())
+
+(define (geiser:no-values)
+ #f)
+
+(define (geiser:newline)
+ #f)
diff --git a/scheme/chibi/geiser/geiser.sld b/scheme/chibi/geiser/geiser.sld
new file mode 100644
index 0000000..a6e2704
--- /dev/null
+++ b/scheme/chibi/geiser/geiser.sld
@@ -0,0 +1,9 @@
+(define-library (geiser)
+ (export geiser:completions
+ geiser:eval
+ geiser:autodoc
+ geiser:module-completions
+ geiser:no-values
+ geiser:newline)
+ (import (scheme small) (chibi modules) (chibi) (meta) (chibi string) (srfi 1) (srfi 95))
+ (include "geiser.scm"))