[slime-cvs] CVS slime

CVS User heller heller at common-lisp.net
Fri Jul 30 16:14:50 UTC 2010


Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv31474

Modified Files:
	ChangeLog slime.el swank.lisp 
Log Message:
Don't get confused by END-OF-FILE on unrelated streams.
Fixes bug "slime connection broken on trivial condition..."
Reported by Pascal J. Bourguignon.

* swank.lisp (end-of-repl-input): New condition.
(simple-repl, read-non-blocking): Use it.
* slime.el ([test] end-of-file): Test it.

--- /project/slime/cvsroot/slime/ChangeLog	2010/07/30 16:14:41	1.2116
+++ /project/slime/cvsroot/slime/ChangeLog	2010/07/30 16:14:50	1.2117
@@ -1,5 +1,15 @@
 2010-07-30  Helmut Eller  <heller at common-lisp.net>
 
+	Don't get confused by END-OF-FILE on unrelated streams.
+	Fixes bug "slime connection broken on trivial condition..."
+	Reported by Pascal J. Bourguignon.
+
+	* swank.lisp (end-of-repl-input): New condition.
+	(simple-repl, read-non-blocking): Use it.
+	* slime.el ([test] end-of-file): Test it.
+
+2010-07-30  Helmut Eller  <heller at common-lisp.net>
+
 	* swank.lisp (print-part-to-string): Bind *print-readably* to nil.
 	Useful when debugging broken printer methods.
 
--- /project/slime/cvsroot/slime/slime.el	2010/06/18 12:31:54	1.1329
+++ /project/slime/cvsroot/slime/slime.el	2010/07/30 16:14:50	1.1330
@@ -8082,7 +8082,24 @@
                         3)
   (slime-sync-to-top-level 5))
 
-
+(def-slime-test end-of-file 
+    (expr)
+    "Signalling END-OF-FILE should invoke the debugger."
+    '(((cl:read-from-string ""))
+      ((cl:error 'cl:end-of-file)))
+  (let ((value (slime-eval 
+                `(cl:let ((condition nil))
+                         (cl:with-simple-restart 
+                          (cl:continue "continue")
+                          (cl:let ((cl:*debugger-hook* 
+                                    (cl:lambda (c h)
+                                               (cl:setq condition c)
+                                               (cl:continue))))
+                                  ,expr))
+                         (cl:and (cl:typep condition 'cl:condition)
+                                 (cl:string (cl:type-of condition)))))))
+    (slime-test-expect "Debugger invoked" "END-OF-FILE" value)))
+                      
 (def-slime-test interrupt-at-toplevel
     ()
     "Let's see what happens if we send a user interrupt at toplevel."
--- /project/slime/cvsroot/slime/swank.lisp	2010/07/30 16:14:41	1.721
+++ /project/slime/cvsroot/slime/swank.lisp	2010/07/30 16:14:50	1.722
@@ -1383,12 +1383,16 @@
                      (simple-repl))))))))
     (close-connection connection nil (safe-backtrace))))
 
+;; this is signalled when our custom stream thinks the end-of-file is reached.
+;; (not when the end-of-file on the socket is reached)
+(define-condition end-of-repl-input (end-of-file) ())
+
 (defun simple-repl ()
   (loop
    (format t "~a> " (package-string-for-prompt *package*))
    (force-output)
    (let ((form (handler-case (read)
-                 (end-of-file () (return)))))
+                 (end-of-repl-input () (return)))))
      (let ((- form)
            (values (multiple-value-list (eval form))))
        (setq *** **  ** *  * (car values)
@@ -1423,9 +1427,12 @@
 
 (defun read-non-blocking (stream)
   (with-output-to-string (str)
-    (loop (let ((c (read-char-no-hang stream)))
-            (unless c (return))
-            (write-char c str)))))
+    (handler-case 
+        (loop (let ((c (read-char-no-hang stream)))
+                (unless c (return))
+                (write-char c str)))
+      (end-of-file () (error 'end-of-repl-input :stream stream)))))
+
 
 ;;;; IO to Emacs
 ;;;





More information about the slime-cvs mailing list