5 (require (prefix-in readline: readline/readline))
9 (define history-loaded #f)
10 (define HISTORY-FILE (format "~a/.mal-history" (find-system-path 'home-dir)))
12 (define (load-history path)
14 ([exn:fail? (lambda (e) #t)])
16 (lambda (line) (readline:add-history line))
18 (port->string (open-input-file path))
21 (define (readline prompt)
22 (when (not history-loaded)
23 (set! history-loaded #t)
24 (load-history HISTORY-FILE))
25 (let ([line (readline:readline prompt)])
29 (readline:add-history line)
31 ([exn:fail? (lambda (e) #t)])
34 (lambda () (printf "~a~n" line))