emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sly 149d7ef784: Fix #581: Reset output stream column when


From: ELPA Syncer
Subject: [nongnu] elpa/sly 149d7ef784: Fix #581: Reset output stream column when flushing listener streams
Date: Tue, 11 Apr 2023 12:02:11 -0400 (EDT)

branch: elpa/sly
commit 149d7ef7844b3824b1df148295cedf6ff85c2b99
Author: dieggsy <dieggsy@pm.me>
Commit: João Távora <joaotavora@gmail.com>

    Fix #581: Reset output stream column when flushing listener streams
    
    Close #583.
    
    Streams, whether gray or not, have a so-called output-column or
    line-column.  This change makes sure to reset it to 0 when the stream
    is flushed, fixing the REPL problems described in #581.
    
    In slynk/slynk-gray.lisp a new generic RESET-STREAM-LINE-COLUMN is
    added, with a method for SLY's gray stream couple class,
    SLY-OUTPUT-STREAM, and a couple of extra methods for SBCL and CMUCL,
    which aren't always using gray streams in the context where
    stream-flushing is needed.
    
    This allows us to call RESET-STREAM-LINE-COLUMN safely in
    slynk/slynk.lisp's FLUSH-LISTENER-STREAMS (except for abcl, which has
    some problem I didn't investigate).
    
    * slynk/slynk-gray.lisp (reset-stream-line-column): New generic and
      methods.
    
    * slynk/slynk.lisp (flush-listener-streams): Call
      reset-stream-line-column.
    
    Commit-message-by: João Távora <joaotavora@gmail.com>
---
 slynk/slynk-gray.lisp | 13 +++++++++++++
 slynk/slynk.lisp      |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/slynk/slynk-gray.lisp b/slynk/slynk-gray.lisp
index 1ab865865e..43fe05bd9f 100644
--- a/slynk/slynk-gray.lisp
+++ b/slynk/slynk-gray.lisp
@@ -99,6 +99,19 @@
 (defmethod stream-line-column ((stream sly-output-stream))
   (with-sly-output-stream stream column))
 
+(defmethod reset-stream-line-column ((stream sly-output-stream))
+  (with-sly-output-stream stream (setf column 0)))
+
+#+sbcl
+(defmethod reset-stream-line-column ((stream sb-sys:fd-stream))
+  (with-slots (sb-impl::output-column) stream
+    (setf sb-impl::output-column 0)))
+
+#+cmucl
+(defmethod reset-stream-line-column ((stream system:fd-stream))
+  (with-slots (lisp::char-pos) stream
+    (setf lisp::char-pos 0)))
+
 (defmethod stream-finish-output ((stream sly-output-stream))
   (with-sly-output-stream stream
     (unless (zerop fill-pointer)
diff --git a/slynk/slynk.lisp b/slynk/slynk.lisp
index 8a1b5c606f..71a7db4000 100644
--- a/slynk/slynk.lisp
+++ b/slynk/slynk.lisp
@@ -603,6 +603,8 @@ corresponding values in the CDR of VALUE."
 (defun flush-listener-streams (listener)
   (with-slots (in out) listener
     (force-output out)
+    #-armedbear
+    (slynk-gray::reset-stream-line-column out)
     (clear-input in)))
 
 (defmethod close-listener (l)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]