[slime-devel] REPL problems

Madhu enometh at meer.net
Wed Jun 3 08:08:18 UTC 2009


* Benjamin L. Russell <6q572514ruc9h0td4fv6391hbtvqkmpa8v at 4ax.com> :
Wrote on Mon, 01 Jun 2009 17:59:44 +0900:

|>Actually, whether you have this problem probably depends on your
|>setup; I only have it with my regular GNU Emacs (which reads in my
|>.emacs file) when calling "M-x slime RET", but not when using the
|>default Lispbox (which ignores that file).  Here's the relevant
|>section from my .emacs file:

IIRC the problem should happen only with CVS SLIME and NOT with
SLIME-2.0

| I finally discovered a patch, posted by Samium Gromoff in the thread
| "PATCH Output redirection in the SIMPLE SERVE EVENTS case." (see
| http://article.gmane.org/gmane.lisp.slime.devel/8513), documenting
| this bug and patching it.
|
| However, it introduced a new bug:  This time, the banner does not
| appear, and I get the following lines in my REPL at startup, instead:

[snip]

| Anybody know how to patch this patch?  Apparently, this patch does not
| seem to have been applied in the CVS version of swank.lisp

No, I do not know how to fix the patch, and do not see your problem. But
I'm appending a WIP patch on the lines of Samium's patch which I've
tested on Lispworks/Linux.  1. I've not tried it with CLISP 2. This will
not work on CMUCL.  3. I do not expect this will address the problems
which were [snipped] above.  In case you care to try it and in the
unlikely event it fixed something, I'd appreciate a note, so maybe I can
clean it up and follow up this approach with more testing.

I've been wailing on this since 2006 but the streams design in swank is
utter crap and instead of getting fixed has been pushed in the direction
of becoming an "unmaintainable mess".  Sadly I do not see the design
flaws being fixed in the future to support the various existing
interaction modes, instead i expect to see the crap-design justified by
support for those interaction modes dropped.

Furthermore the REPL printing is broken: If you switch to the REPL enter
(+ 2 3), you get the result `5' printed.  Now if you switch to lisp
buffer, (say *slime-scratch*) and evaluate an expression (format t
"foo") by C-M-x or C-x C-e (slime-eval-last-expression) You'll find the
output of "foo" BEFORE the `5'

--Madhu

diff --git a/swank.lisp b/swank.lisp
index 4df8020..1dec402 100644
--- a/swank.lisp
+++ b/swank.lisp
@@ -1394,9 +1394,21 @@ The processing is done in the extent of the toplevel restart."
                                       :serve-requests #'install-fd-handler
                                       :cleanup #'deinstall-fd-handler))
                     ((nil)
-                     (make-connection :socket-io socket-io
-                                      :serve-requests #'simple-serve-requests))
-                    )))
+                     (let ((c (make-connection :socket-io socket-io
+                                      :serve-requests #'simple-serve-requests)))
+;; ;madhu 090601
+                       (initialize-streams-for-connection c)
+           (with-struct* (connection. @ c)
+             (setf (@ env)
+                   `((*standard-output* . ,(@ user-output))
+                     (*standard-input*  . ,(@ user-input))
+                     (*trace-output*    . ,(or (@ trace-output) (@ user-output)))
+                     (*error-output*    . ,(@ user-output))
+                     (*debug-io*        . ,(@ user-io))
+                     (*query-io*        . ,(@ user-io))
+                     (*terminal-io*     . ,(@ user-io)))))
+           c)))))
+
            (setf (connection.communication-style c) style)
            (setf success t)
            c)
@@ -1556,6 +1568,7 @@ NIL if streams are not globally redirected.")
 ;;; We always redirect the standard streams to Emacs while evaluating
 ;;; an RPC. This is done with simple dynamic bindings.
 
+#+nil ;madhu 090601
 (defslimefun create-repl (target)
   (assert (eq target nil))
   (let ((conn *emacs-connection*))
@@ -1575,6 +1588,31 @@ NIL if streams are not globally redirected.")
       (list (package-name *package*)
             (package-string-for-prompt *package*)))))
 
+(defslimefun create-repl (target) ;madhu 090601
+  (assert (eq target nil))
+  (let ((conn *emacs-connection*))
+    (if (connection.user-io conn)
+        (format t "Skipping ~S" conn)
+        (progn
+          (initialize-streams-for-connection conn)
+          (with-struct* (connection. @ conn)
+            (setf (@ env)
+                  `((*standard-output* . ,(@ user-output))
+                    (*standard-input*  . ,(@ user-input))
+                    (*trace-output*    . ,(or (@ trace-output) (@ user-output)))
+                    (*error-output*    . ,(@ user-output))
+                    (*debug-io*        . ,(@ user-io))
+                    (*query-io*        . ,(@ user-io))
+                    (*terminal-io*     . ,(@ user-io))))
+            (maybe-redirect-global-io conn)
+            (when (use-threads-p)
+              (setf (@ repl-thread) (spawn-repl-thread conn "repl-thread")))
+            (list (package-name *package*)
+                  (package-string-for-prompt *package*)))))))
+
+#+nil
+(open-streams (make-connection  :socket-io nil :serve-requests t))
+
 (defun initialize-streams-for-connection (connection)
   (multiple-value-bind (dedicated in out io repl-results) 
       (open-streams connection)








More information about the slime-devel mailing list