If it doesnt fit, use a bigger hammer.

This one isn't perfect, but works even with a Maven-started swank.

; use with (System/setOut (sys-out-replacer))
(import (java.io PrintStream PipedInputStream PipedOutputStream))
(defn sys-out-replacer []
     (let [pin (PipedInputStream.)
           out (PrintStream. (PipedOutputStream. pin))
           current-out *out*
           pusher (fn [] (let [b (.read pin)]
                           (binding [*out* current-out]
                             (.write *out* b))
                           (.flush out)
                           (recur)))]
       (.start (Thread. pusher))
       out))

Feedback highly welcome.

Regards, alxu

On 18 Mai, 21:09, alux <alu...@googlemail.com> wrote:
> Hi.
>
> (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)
>
> works for me if I start Clojure with M-x slime
> But if I start it with Maven, and try to connect, it prevents the REPL
> from starting.
>
> Mini Buffer says:
> "error in process filter: No inferior lisp process"
>
> Hm.
>
> (I actually didnt expect this to work, but to prevent me from working
> isnt nice ;-)
>
> Greetings, alux
>
> On 18 Mai, 20:37, Dave Fayram <dfay...@gmail.com> wrote:
>
>
>
> > That is a very useful bit of information. Thanks!
>
> > On Tue, May 18, 2010 at 6:01 AM, Moritz Ulrich
>
> > <ulrich.mor...@googlemail.com> wrote:
> > > Slime supports redirecting the inferior-lisp-output to the repl:
>
> > > Add
>
> > > (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)
>
> > > to your .emacs
>
> > > On Tue, May 18, 2010 at 4:39 AM, Dave Fayram <dfay...@gmail.com> wrote:
> > >> It doesn't suppress output, it just doesn't propagate it to your repl
> > >> buffer. Check for that output in your *inferior-lisp* buffer; it
> > >> should be faithfully reproduced there.
>
> > >> You might want to consider using an alternative means of logging in
> > >> the future. Perhaps an agent that buffers lines.
>
> > >> - dlf
>
> > >> On Mon, May 17, 2010 at 6:26 PM, Preecha P <yum...@gmail.com> wrote:
> > >>> I tried to play around with thread with these lines of code. It should
> > >>> print the value of variable but it doesn't..
>
> > >>> In emacs.
> > >>> user> (def x 5)
> > >>> #'user/x
> > >>> user> x
> > >>> 5
> > >>> user> (import [java.lang Thread])
> > >>> java.lang.Thread
> > >>> user> (.start (Thread. (fn [] (print x))))
> > >>> nil
>
> > >>> or with agent
> > >>> user> (def foo (agent 0))
> > >>> #'user/foo
> > >>> user> foo
> > >>> #<ag...@6af2f0d0: 0>
> > >>> user> (send foo (fn[num] (do (println num) (inc num))))
> > >>> #<ag...@6af2f0d0: 0>
>
> > >>> I ran the exact same code in command-line and the thread could print
> > >>> the output fine.
>
> > >>> Clojure 1.1.0-master-SNAPSHOT
> > >>> user=> (def foo (agent 0))
> > >>> #'user/foo
> > >>> user=> foo
> > >>> #<ag...@194835fb: 0>
> > >>> user=> (send foo (fn[num] (do (println num) (inc num) )))
> > >>> 0
> > >>> #<ag...@194835fb: 0>
>
> > >>> I installed everything from elpa, so I guess some of the component
> > >>> might gone wrong. Any idea ?
>
> > >>> thanks.
>
> > >>> --
> > >>> You received this message because you are subscribed to the Google
> > >>> Groups "Clojure" group.
> > >>> To post to this group, send email to clojure@googlegroups.com
> > >>> Note that posts from new members are moderated - please be patient with 
> > >>> your first post.
> > >>> To unsubscribe from this group, send email to
> > >>> clojure+unsubscr...@googlegroups.com
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/clojure?hl=en
>
> > >> --
> > >> --
> > >> Dave Fayram
> > >> dfay...@gmail.com
>
> > >> --
> > >> You received this message because you are subscribed to the Google
> > >> Groups "Clojure" group.
> > >> To post to this group, send email to clojure@googlegroups.com
> > >> Note that posts from new members are moderated - please be patient with 
> > >> your first post.
> > >> To unsubscribe from this group, send email to
> > >> clojure+unsubscr...@googlegroups.com
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/clojure?hl=en
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clojure@googlegroups.com
> > > Note that posts from new members are moderated - please be patient with 
> > > your first post.
> > > To unsubscribe from this group, send email to
> > > clojure+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/clojure?hl=en
>
> > --
> > --
> > Dave Fayram
> > dfay...@gmail.com
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group 
> > athttp://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to