Question

I have a fairly standard Quil file that I am editing with Emacs and nrepl.

(defn setup []
  (qc/smooth)
  (qc/frame-rate 24)
  (qc/background 200))

(defn draw []
  (draw-world))

(qc/defsketch run
  :title "Circles!"
  :setup setup
  :draw draw
  :size [800 600]
  :renderer :opengl)

To start with, I use C-c C-l to load the file; this creates a sketch window. I then edit my draw-world function to, say, draw in a different color. My question is:

How do I update the current Quil window with this new function?

*C-x C-e doesn't seem to work.

Was it helpful?

Solution

Try C-M-x (this evals the current top-level form) in the function you want to change or C-c C-k (this evals the current buffer) in the source buffer. Btw, C-x C-e should be working too (it certainly works for me, but I rarely use it). Maybe you're not using nrepl.el's latest version?

OTHER TIPS

I just set up a sample project to handle my workflow for live-coding in Quil. I copied some basics from several places, such as the Quil wiki and forums.

If you look at the basic core.clj file of the project, you'll see it requires separate "draw" and "setup" namespaces:

(ns basic-metronome.core
  (:use [basic-metronome.setup :only [HEIGHT WIDTH]])
  (:require [basic-metronome.draw :as dynamic-draw]
            [basic-metronome.setup :as dynamic-setup]
            [quil.core :as qc]))

(defn run-sketch []
  (qc/defsketch the-sketch
    :title "Hello Metronome"
    :setup dynamic-setup/setup
    :draw dynamic-draw/draw
    :size [WIDTH HEIGHT]))

From: https://github.com/mudphone/basic_quil_metronome/blob/master/src/basic_metronome/core.clj

In this way, I can re-evaluate C-c C-k the draw.clj file without having to re-evaluate the top-level core namespace (which can cause problems, such as the one you describe where you're seeing a new window).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top