[slime-cvs] CVS slime

mkoeppe mkoeppe at common-lisp.net
Sun Dec 31 12:28:28 UTC 2006


Update of /project/slime/cvsroot/slime
In directory clnet:/tmp/cvs-serv1378

Modified Files:
	swank.lisp 
Log Message:
(connection): New slot repl-results (a stream).
(make-output-function-for-target): New.
(open-streams): Use it here to also create a stream for REPL results.
(initialize-streams-for-connection): Store the stream.


--- /project/slime/cvsroot/slime/swank.lisp	2006/12/29 16:10:26	1.444
+++ /project/slime/cvsroot/slime/swank.lisp	2006/12/31 12:28:28	1.445
@@ -198,6 +198,8 @@
   (user-input       nil :type (or stream null))
   (user-output      nil :type (or stream null))
   (user-io          nil :type (or stream null))
+  ;; A stream where we send REPL results.
+  (repl-results     nil :type (or stream null))
   ;; In multithreaded systems we delegate certain tasks to specific
   ;; threads. The `reader-thread' is responsible for reading network
   ;; requests from Emacs and sending them to the `control-thread'; the
@@ -518,8 +520,8 @@
     (force-output *debug-io*)))
 
 (defun open-streams (connection)
-  "Return the 4 streams for IO redirection:
-DEDICATED-OUTPUT INPUT OUTPUT IO"
+  "Return the 5 streams for IO redirection:
+DEDICATED-OUTPUT INPUT OUTPUT IO REPL-RESULTS"
   (multiple-value-bind (output-fn dedicated-output) 
       (make-output-function connection)
     (let ((input-fn
@@ -532,7 +534,11 @@
         (let ((out (or dedicated-output out)))
           (let ((io (make-two-way-stream in out)))
             (mapc #'make-stream-interactive (list in out io))
-            (values dedicated-output in out io)))))))
+            (let* ((repl-results-fn
+                    (make-output-function-for-target connection :repl-result))
+                   (repl-results
+                    (nth-value 1 (make-fn-streams nil repl-results-fn))))
+              (values dedicated-output in out io repl-results))))))))
 
 (defun make-output-function (connection)
   "Create function to send user output to Emacs.
@@ -553,6 +559,14 @@
                     (send-to-emacs `(:write-string ,string)))))
               nil)))
 
+(defun make-output-function-for-target (connection target)
+  "Create a function to send user output to a specific TARGET in Emacs."
+  (lambda (string) 
+    (with-connection (connection)
+      (with-simple-restart
+          (abort "Abort sending output to Emacs.")
+        (send-to-emacs `(:write-string ,string nil ,target))))))
+
 (defun open-dedicated-output-stream (socket-io)
   "Open a dedicated output connection to the Emacs on SOCKET-IO.
 Return an output stream suitable for writing program output.
@@ -880,11 +894,13 @@
        (send event)))))
 
 (defun initialize-streams-for-connection (connection)
-  (multiple-value-bind (dedicated in out io) (open-streams connection)
+  (multiple-value-bind (dedicated in out io repl-results) 
+      (open-streams connection)
     (setf (connection.dedicated-output connection) dedicated
           (connection.user-io connection)          io
           (connection.user-output connection)      out
-          (connection.user-input connection)       in)
+          (connection.user-input connection)       in
+          (connection.repl-results connection)     repl-results)
     connection))
 
 (defun create-connection (socket-io style)




More information about the slime-cvs mailing list