mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
save history for readline
This commit is contained in:
parent
75861bf1c7
commit
01d429324e
11
repl.php
11
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user