ppbitb
ppbitb

Reputation: 517

Clojure, Quil: Printing in draw function

I am a Clojure and Quil beginner.
As part of development, I would like to print information to the REPL in the draw function.
However, the following implementation doesn't work. There are no error generated, but it doesn't print anything either.
Why doesn't it work, and how can I print to the REPL from Quil draw functions?

Thank you in advance.

(ns quil-learning.core
  (:use quil.core))

(defn setup []
  (smooth)
  (frame-rate 60)
  (background 255))

(def saved-out *out*)

(defn draw []
  (println "test 1") ; doesn't work
  (let [*out* saved-out] (println "test 2")) ; doesn't work either
  (stroke 0)
  (stroke-weight 2)
  (ellipse (mouse-x) (mouse-y) 2 2))

 (defsketch example
   :title "print test"
   :setup setup
   :draw draw)

Upvotes: 2

Views: 633

Answers (1)

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

nrepl is writing your output to the wrong buffer, this was supposed to be fixed for most contexts in nrepl 0.1.4 http://grokbase.com/t/gg/clojure/129jwz1yh9/ann-nrepl-el-0-1-4-released. I suggest using emacs24+ and using it's built in packaging system to keep nrepl up to date. see the Emacs starter kit for details. Or you can take a look at my fork of it which adds nrepl and clojure-mode to the default package list

check the terminal from which you started emacs, sometimes it lands there.

Upvotes: 2

Related Questions