(libload "./readline") (defvar history-file (concat-fname (getenv "HOME") "/.mal_history")) (de blankp (line) (regex-match "[ \t\n]*" line)) (de load-history () (let ((fd (open-read history-file))) (when fd (each ((line (read-lines fd))) (when (not (blankp line)) (add-history line)))))) (de add-to-history (line) (add-history line) (writing (open-append history-file) (printf "%s\n" line))) (de repl (prompt) (load-history) (let ((input nil)) (while (setq input (readline prompt)) (when (not (blankp input)) (printf "%s\n" input) (add-to-history input))) (printf "\n"))) (repl "> ")