X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Fsb-aclrepl%2Frepl.lisp;h=0b16d891709f6fcb0ea700d1f2a9d32144f2f6c3;hb=f8893c7c658bf9d9e0757c63e47af2fdea810f04;hp=7ae4fa195707251cacb901aebe0a1fd6a27d4d00;hpb=c486d57a174a2c9290d5db6ab803ec8c41ecc588;p=sbcl.git diff --git a/contrib/sb-aclrepl/repl.lisp b/contrib/sb-aclrepl/repl.lisp index 7ae4fa1..0b16d89 100644 --- a/contrib/sb-aclrepl/repl.lisp +++ b/contrib/sb-aclrepl/repl.lisp @@ -86,21 +86,24 @@ (defun read-cmd (input-stream) ;; Reads a command from the user and returns a user-cmd object - (let ((next-char (peek-char-non-whitespace input-stream))) - (cond - ((eql *command-char* next-char) - (dispatch-command-line input-stream)) - ((eql #\newline next-char) - (read-char input-stream) - *null-cmd*) - ((eql :eof next-char) - *eof-cmd*) - (t - (let* ((eof (cons nil *eof-marker*)) - (form (read input-stream nil eof))) - (if (eq form eof) - *eof-cmd* - (make-user-cmd :input form :func nil :hnum *cmd-number*))))))) + (let* ((next-char (peek-char-non-whitespace input-stream)) + (cmd (cond + ((eql *command-char* next-char) + (dispatch-command-line input-stream)) + ((eql #\newline next-char) + (read-char input-stream) + *null-cmd*) + ((eql :eof next-char) + *eof-cmd*) + (t + (let* ((eof (cons nil *eof-marker*)) + (form (read input-stream nil eof))) + (if (eq form eof) + *eof-cmd* + (make-user-cmd :input form :func nil :hnum *cmd-number*))))))) + (if (and (eq cmd *eof-cmd*) (typep input-stream 'string-stream)) + (throw 'repl-catcher cmd) + cmd))) (defun dispatch-command-line (input-stream) "Processes an input line that starts with *command-char*" @@ -144,7 +147,7 @@ (maybe-return-history-cmd cmd cmd-args-string))) (defun maybe-return-history-cmd (cmd cmd-args-string) - (format *output* "~&~A" (user-cmd-input cmd)) + (format *output* "~A~%" (user-cmd-input cmd)) (let ((dont-redo (when (and (stringp cmd-args-string) (plusp (length cmd-args-string)) @@ -156,8 +159,8 @@ (when (string-equal line "N") t)) (when line - (format *output* "~&Type \"y\" for yes or \"n\" for no.")) - (format *output* "~&redo? [y] ") + (format *output* "Type \"y\" for yes or \"n\" for no.~%")) + (format *output* "redo? [y] ") (force-output *output*))))) (if dont-redo *null-cmd* @@ -180,7 +183,7 @@ (defun process-history-search (pattern cmd-args-string) (let ((cmd (find-history-matching-pattern pattern))) (unless cmd - (format *output* "No match on history list with pattern ~S" pattern) + (format *output* "No match on history list with pattern ~S~%" pattern) (return-from process-history-search *null-cmd*)) (maybe-return-history-cmd cmd cmd-args-string))) @@ -411,6 +414,7 @@ (defun apropos-cmd (string) (apropos (string-upcase string)) + (fresh-line *output*) (values)) (let ((last-files-loaded nil)) @@ -487,7 +491,7 @@ (defun pushd-cmd (string-arg) (push string-arg *dir-stack*) - (cd-cmd *output* string-arg) + (cd-cmd string-arg) (values)) (defun popd-cmd () @@ -797,6 +801,7 @@ (let ((stopped-threads (sb-thread::waitqueue-data lock))) (when stopped-threads (format stream "~{~&Thread ~A suspended~}~%" stopped-threads)))) + (fresh-line stream) (if (functionp *prompt*) (write-string (funcall *prompt* break-level @@ -815,7 +820,7 @@ (error () (format stream "~&Prompt error> ")) (:no-error (prompt) - (format stream "~&~A" prompt)))))) + (format stream "~A" prompt)))))) (defun process-cmd (user-cmd) ;; Processes a user command. Returns t if the user-cmd was a top-level @@ -839,7 +844,7 @@ ((functionp (user-cmd-func user-cmd)) (add-to-history user-cmd) (apply (user-cmd-func user-cmd) (user-cmd-args user-cmd)) - (fresh-line) + ;;(fresh-line) t) (t (add-to-history user-cmd)