diff --git a/repl.php b/repl.php index 42f6d9a..7d7655f 100644 --- a/repl.php +++ b/repl.php @@ -3,6 +3,12 @@ require('bootstrap.php'); list($lisp, $rootEnv) = ml_get_lisp(); +// Read history +$historyFile = $_SERVER['HOME'] . '/.madlisp_history'; +if (is_readable($historyFile)) { + readline_read_history($historyFile); +} + // Create new env for user definitions $userEnv = new MadLisp\Env('repl', $rootEnv); @@ -11,6 +17,11 @@ while (true) { try { $lisp->rep($input, $userEnv); + + if ($input) { + readline_add_history($input); + readline_write_history($historyFile); + } } catch (MadLisp\MadLispException $ex) { print('error: ' . $ex->getMessage()); } catch (TypeError $ex) {