-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathulispreadline.py
More file actions
33 lines (29 loc) · 816 Bytes
/
Copy pathulispreadline.py
File metadata and controls
33 lines (29 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
import logging
import readline as rl
PROMPT = "ulisp> "
history_loaded = False
def readline():
global prompt
global history_loaded
history_file = os.path.expanduser("~/.ulisp_history")
if not history_loaded:
history_loaded = True
try:
with open(history_file, "r") as hf:
for hist_line in hf.readlines():
rl.add_history(hist_line.rstrip("\r\n"))
except IOError:
print("No history file found. Creating at {}".format(history_file))
try:
line = input(PROMPT)
rl.add_history(line)
with open(history_file, "a") as hf:
hf.write(line + '\n')
except IOError:
pass
except EOFError:
# Ctrl + D handler
return None
return line