Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have been hacking on ClojureScript recently as well (spent the weekend playing with ClojureScript One also!), but I am not an Emacs user (I use Vim). Can you explain the part about sending JavaScript to the browser without refresh from a normal repl (lein repl)? I see this advertised by ClojureScript but not an explanation as to how it works (probably assuming experienced lispers). My method for working has been save, ctrl+tab to browser, ctrl+f5 to refresh.


Honestly, this can actually be a PITA to set up for vanilla ClojureScript apps because the order of steps is very important, and one of the rad things about ClojureScript One for beginners (myself included) is that it's seems much easier to get working, so if you're not an Emacs user to begin with, I would clone ClojureScript One and follow along to try it out. There are some nice scripts and Clojure code meant for dev-time that come with it that smooth out the edges a bit.

But in general, you have to set up your inferior-lisp-program in Emacs with the shell script desribed here: https://github.com/clojure/clojurescript/wiki/Emacs-%26-infe... (for ClojureScript One, it suffices to use "lein repl" as your inf-lisp.)

Then you need to (:require [clojure.browser.repl :as repl) in your ns, and run (repl/repl "http://localhost:9000 ") (there's a space here to prevent HN from swallowing the close-quote, but it shouldn't be there) at the beginning of your ClojureScript app.

Start the REPL in Emacs (M-x inferior-lisp RET, ie press Alt-x, type "inferior-lisp", hit return) and then open the browser and point it at your app. Test it by typing (js/alert) in Emacs. Then, when you're in a ClojureScript buffer (or any Lisp buffer, I think) C-x C-e will send the form before the point to the REPL, which is actually connected to the browser.

I'll leave setting it up for Vim as an exercise for the reader (kidding, kind of, I just don't have any idea if any one has worked on this yet, although there are Vim modes for regular Clojure, so maybe)


Oops, this is wrong: (repl/repl "http://localhost:9000 ") Should be (repl/connect "http://localhost:9000/repl ")

I also kind of misread MatthewPhillips post and thought he was looking for Emacs instructions. For sending code to the browser from a normal REPL, (started with `lein repl`) I think a good place to start is these two files from Cljs One:

https://github.com/brentonashworth/one/blob/master/src/app/c...

https://github.com/brentonashworth/one/blob/master/src/lib/c...

Together they should help in setting this up for a vanilla Cljs project, or require them in your fork of Cljs One and start a REPL.


I use Vim and did get something similar setup for ClojureScript. I used a lein repl running in Gnu Screen and sent clojurescript from Vim to the browser based repl using vim-slime https://github.com/jpalardy/vim-slime. It worked very well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: