mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Using let-keywords* for repl parameters.
This commit is contained in:
parent
e37011f358
commit
ceaf4b760e
2 changed files with 28 additions and 39 deletions
|
@ -327,45 +327,34 @@
|
||||||
(set-port-fold-case! in (port-fold-case? in2))
|
(set-port-fold-case! in (port-fold-case? in2))
|
||||||
expr-list)))))
|
expr-list)))))
|
||||||
|
|
||||||
(define (keywords->repl o)
|
(define (keywords->repl ls)
|
||||||
(let* ((in (cond ((memq 'in: o) => cadr) (else (current-input-port))))
|
(let-keywords* ls
|
||||||
(out (cond ((memq 'out: o) => cadr) (else (current-output-port))))
|
((in in: (current-input-port))
|
||||||
(escape (cond ((memq 'escape: o) => cadr) (else #\@)))
|
(out out: (current-output-port))
|
||||||
(module (cond ((memq 'module: o) => cadr) (else #f)))
|
(escape escape: #\@)
|
||||||
|
(module module: #f)
|
||||||
(env
|
(env
|
||||||
(cond
|
environment:
|
||||||
((memq 'environment: o) =>
|
|
||||||
(lambda (x)
|
|
||||||
(if module
|
(if module
|
||||||
(error (string-append "The module: and environment: keyword "
|
|
||||||
"arguments should not both be given.")))
|
|
||||||
(cadr x)))
|
|
||||||
(module
|
|
||||||
(module-env
|
(module-env
|
||||||
(if (module? module) module (load-module module))))
|
(if (module? module) module (load-module module)))
|
||||||
(else (interaction-environment))))
|
(interaction-environment)))
|
||||||
(make-prompt
|
(make-prompt
|
||||||
(cond
|
make-prompt:
|
||||||
((memq 'make-prompt: o) => cadr)
|
|
||||||
(else
|
|
||||||
(lambda (module)
|
(lambda (module)
|
||||||
(string-append (if module (write-to-string module) "") "> ")))))
|
(string-append (if module (write-to-string module) "") "> ")))
|
||||||
(history-file
|
(history-file
|
||||||
(cond ((memq 'history-file: o) => cadr)
|
history-file:
|
||||||
(else (string-append (get-environment-variable "HOME")
|
(string-append (get-environment-variable "HOME")
|
||||||
"/.chibi-repl-history"))))
|
"/.chibi-repl-history"))
|
||||||
(history
|
(history
|
||||||
(cond ((memq 'history: o) => cadr)
|
history:
|
||||||
(else
|
|
||||||
(or (protect (exn (else #f))
|
(or (protect (exn (else #f))
|
||||||
(list->history
|
(list->history (call-with-input-file history-file read)))
|
||||||
(call-with-input-file history-file read)))
|
(make-history)))
|
||||||
(make-history)))))
|
(raw? raw?:
|
||||||
(raw? (cond ((memq 'raw?: o) => cadr)
|
(member (get-environment-variable "TERM") '("emacs" "dumb")))
|
||||||
(else (member (get-environment-variable "TERM")
|
(meta-env meta-env: (module-env (load-module '(meta)))))
|
||||||
'("emacs" "dumb")))))
|
|
||||||
(meta-env (cond ((memq 'meta: o) => cadr)
|
|
||||||
(else (module-env (load-module '(meta)))))))
|
|
||||||
(make-repl
|
(make-repl
|
||||||
in out escape module env meta-env make-prompt history-file history raw?)))
|
in out escape module env meta-env make-prompt history-file history raw?)))
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
(export repl)
|
(export repl)
|
||||||
(import (chibi) (only (meta) load-module)
|
(import (chibi) (only (meta) load-module)
|
||||||
(chibi ast) (chibi modules) (chibi doc)
|
(chibi ast) (chibi modules) (chibi doc)
|
||||||
(chibi string) (chibi io)
|
(chibi string) (chibi io) (chibi optional)
|
||||||
(chibi process) (chibi term edit-line)
|
(chibi process) (chibi term edit-line)
|
||||||
(srfi 1) (srfi 9) (srfi 18) (srfi 38) (srfi 95) (srfi 98))
|
(srfi 1) (srfi 9) (srfi 18) (srfi 38) (srfi 95) (srfi 98))
|
||||||
(include "repl.scm"))
|
(include "repl.scm"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue