[Bordeaux-threads-devel] binding output stream in thread for slime use
Hi I am trying to use bordeaux threads. Trying to figure out how to make output from a thread function appear in slime instead of the lisp terminal. The lisp I am using is Clozure Common Lisp Version 1.6-r14468M (WindowsX8664) I beleive I have the latest bordeaux threads Following is my test code. I hope the intentions are clear. What am I doing wrong or missing? Code follows Thanks, -Antony (asdf:oos 'asdf:load-op :bordeaux-threads) (format t "~%appearing in slime") (defun thread-test () (format t "~%appearing in lisp terminal: ~A" (bordeaux-threads:thread-name (bordeaux-threads:current-thread)))) (let ((bindings '((*standard-input* . *standard-input*) (*standard-output* . *standard-output*) (*query-io* . *query-io*) (*trace-output* . *trace-output*)))) ;;is this correct? (dolist (name '("foo" "bar")) (bordeaux-threads:make-thread #'thread-test :name name :initial-bindings bindings)))
The way I capture the slime output stream is this: (let ((s *standard-output*)) (defun foo () (format s "Debug output"))) And evaluate it with M-x or by pasting into the REPL itself. That's guaranteed to make foo capture a binding to the slime output stream. To get your approach to work you need to do: (let ((bindings (list (cons '*standard-output* *standard-output*)))) (bt:make-thread #'foo :initial-bindings bindings)) That is, the value of *standard-output* needs to be evaluated. Hope that helps. Vladimir 2010/12/11 Antony <lisp.linux@gmail.com>:
Hi
I am trying to use bordeaux threads. Trying to figure out how to make output from a thread function appear in slime instead of the lisp terminal. The lisp I am using is Clozure Common Lisp Version 1.6-r14468M (WindowsX8664)
I beleive I have the latest bordeaux threads
Following is my test code. I hope the intentions are clear.
What am I doing wrong or missing?
Code follows Thanks, -Antony
(asdf:oos 'asdf:load-op :bordeaux-threads)
(format t "~%appearing in slime")
(defun thread-test () (format t "~%appearing in lisp terminal: ~A" (bordeaux-threads:thread-name (bordeaux-threads:current-thread))))
(let ((bindings '((*standard-input* . *standard-input*) (*standard-output* . *standard-output*) (*query-io* . *query-io*) (*trace-output* . *trace-output*)))) ;;is this correct? (dolist (name '("foo" "bar")) (bordeaux-threads:make-thread #'thread-test :name name :initial-bindings bindings)))
_______________________________________________ Bordeaux-threads-devel mailing list Bordeaux-threads-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/bordeaux-threads-devel
Thank you very much. It's clear now and works too. -Antony On 12/14/2010 6:35 PM, Vladimir Sedach wrote:
To get your approach to work you need to do:
(let ((bindings (list (cons '*standard-output* *standard-output*)))) (bt:make-thread #'foo :initial-bindings bindings))
That is, the value of *standard-output* needs to be evaluated.
In article <4D0348A3.2000105@gmail.com>, Antony <lisp.linux@gmail.com> wrote:
Hi
I am trying to use bordeaux threads. Trying to figure out how to make output from a thread function appear in slime instead of the lisp terminal. The lisp I am using is Clozure Common Lisp Version 1.6-r14468M (WindowsX8664)
I beleive I have the latest bordeaux threads
Following is my test code. I hope the intentions are clear.
What am I doing wrong or missing?
Code follows Thanks, -Antony
(asdf:oos 'asdf:load-op :bordeaux-threads)
(format t "~%appearing in slime")
(defun thread-test () (format t "~%appearing in lisp terminal: ~A" (bordeaux-threads:thread-name (bordeaux-threads:current-thread))))
(let ((bindings '((*standard-input* . *standard-input*) (*standard-output* . *standard-output*) (*query-io* . *query-io*) (*trace-output* . *trace-output*)))) ;;is this correct? (dolist (name '("foo" "bar")) (bordeaux-threads:make-thread #'thread-test :name name :initial-bindings bindings)))
You can place (setq swank:*globally-redirect-io* t) into your ~/.swank.lisp to globally install the slime repl streams, so all output will show up in your *slime-repl ...* buffer. Another way, next to what Vladimir said, is to use (define-symbol-macro *repl-stream* (swank::connection.user-output (swank::default-connection))) I'd say this question would have been more appropriate on slime-devel. :-) Anyway, hth, -T.
participants (3)
-
Antony
-
Tobias C Rittweiler
-
Vladimir Sedach