X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-aclrepl%2Frepl.lisp;h=9744e68f37853c0736fa11911a1d4d6257c7f31a;hb=8a8a8922802460741d6f8f6c11d71b1f414cf3a7;hp=6b2431b698f9c5542e78af95fc3eadecd3d968ae;hpb=7f2582276602d131d26a384a3028f5e6d2847e7c;p=sbcl.git diff --git a/contrib/sb-aclrepl/repl.lisp b/contrib/sb-aclrepl/repl.lisp index 6b2431b..9744e68 100644 --- a/contrib/sb-aclrepl/repl.lisp +++ b/contrib/sb-aclrepl/repl.lisp @@ -52,11 +52,6 @@ (declaim (type list *history*)) -(eval-when (:compile-toplevel :load-toplevel :execute) - (export '(*prompt* *exit-on-eof* *max-history* - *use-short-package-name* *command-char* - alias))) - (defvar *eof-marker* :eof) (defvar *eof-cmd* (make-user-cmd :func :eof)) (defvar *null-cmd* (make-user-cmd :func :null-cmd)) @@ -64,18 +59,6 @@ (defparameter *cmd-table-hash* (make-hash-table :size 30 :test #'equal)) -;; Set up binding for multithreading - -(let ((*prompt* #.*default-prompt*) - (*use-short-package-name* t) - (*dir-stack* nil) - (*command-char* #\:) - (*max-history* 100) - (*exit-on-eof* t) - (*history* nil) - (*cmd-number* 1) - ) - (defun prompt-package-name () (if *use-short-package-name* (car (sort (append @@ -639,8 +622,7 @@ (values)) (defun reset-cmd () - ;; The last restart goes to the toplevel - (invoke-restart-interactively (car (last (compute-restarts))))) + (invoke-restart-interactively (find-restart 'sb-impl::toplevel))) (defun dirs-cmd () (dolist (dir *dir-stack*) @@ -778,29 +760,23 @@ (and (characterp x) (or (char= x #\space) (char= x #\tab) + (char= x #\page) (char= x #\newline) (char= x #\return)))) (defun whitespace-char-not-newline-p (x) (and (whitespace-char-p x) (not (char= x #\newline)))) - ;;;; linking into SBCL hooks - (defun repl-prompt-fun (stream) (let ((break-level (when (plusp *break-level*) *break-level*)) (frame-number (when (and (plusp *break-level*) sb-debug::*current-frame*) (sb-di::frame-number sb-debug::*current-frame*)))) - #+sb-thread - (let ((lock sb-thread::*session-lock*)) - (sb-thread::get-foreground) - (let ((stopped-threads (sb-thread::waitqueue-data lock))) - (when stopped-threads - (format stream "~{~&Thread ~A suspended~}~%" stopped-threads)))) + (sb-thread::get-foreground) (fresh-line stream) (if (functionp *prompt*) (write-string (funcall *prompt* @@ -835,7 +811,7 @@ ((eq (user-cmd-func user-cmd) :cmd-error) (format *output* "Unknown top-level command: ~s.~%" (user-cmd-input user-cmd)) - (format *output* "Type `:help' for the list of commands.~%") + (format *output* "Type `~Ahelp' for the list of commands.~%" *command-char*) t) ((eq (user-cmd-func user-cmd) :history-error) (format *output* "Input numbered ~d is not on the history list~%" @@ -866,5 +842,23 @@ (setf sb-int:*repl-prompt-fun* #'repl-prompt-fun sb-int:*repl-read-form-fun* #'repl-read-form-fun) -) ;; close special variables bindings - +(defmacro with-new-repl-state ((&rest vars) &body forms) + (let ((gvars (mapcar (lambda (var) (gensym (symbol-name var))) vars))) + `(let (,@(mapcar (lambda (var gvar) `(,gvar ,var)) vars gvars)) + (lambda (noprint) + (let ((*noprint* noprint)) + (let (,@(mapcar (lambda (var gvar) `(,var ,gvar)) vars gvars)) + (unwind-protect + (progn ,@forms) + ,@(mapcar (lambda (var gvar) `(setf ,gvar ,var)) + vars gvars)))))))) + +(defun make-repl-fun () + (with-new-repl-state (*break-level* *inspect-break* *continuable-break* + *dir-stack* *command-char* *prompt* + *use-short-package-name* *max-history* *exit-on-eof* + *history* *cmd-number*) + (repl :noprint noprint :break-level 0))) + +(when (boundp 'sb-impl::*repl-fun-generator*) + (setq sb-impl::*repl-fun-generator* #'make-repl-fun))