- (defun readline (&key (prompt "") (history t))
- "Read a line from current TTY with line-editing."
- (with-cstring (c-prompt prompt)
- (let ((str (string-trim
- *whitespace*
- (convert-from-cstring (libreadline::readline c-prompt)))))
- (when (and history (not (string= "" str)))
- (add-history str))))))
+(defun readline (&key (prompt "") (history t))
+ "Read a line from current TTY with line-editing."
+ (with-cstring (c-prompt prompt)
+ (let ((str (string-trim *whitespace*
+ (convert-and-free-foreign-string (c-readline c-prompt)))))
+ (when (and history (not (string= "" str)))
+ (add-history str))
+ str)))
+
+(defun readexpr (&key (primary-prompt "=> ") (secondary-prompt "| ") (history t))
+ "Read an expression from current TTY with line-editing."
+ (let (expr)
+ (do* ((str (readline :prompt primary-prompt :history history)
+ (readline :prompt secondary-prompt :history history))
+ (input str (concatenate 'string input " " str)))
+ ((ignore-end-of-file
+ (setq expr (with-input-from-string (in input)
+ (read in nil nil))))
+ expr))))
+
+
+