diff options
Diffstat (limited to 'scheme/chibi')
-rw-r--r-- | scheme/chibi/geiser/geiser.scm | 49 | ||||
-rw-r--r-- | scheme/chibi/geiser/geiser.sld | 9 |
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")) |