appengine-magic and vimclojure

42 views
Skip to first unread message

Ryan Waters

unread,
Sep 22, 2011, 10:40:39 AM9/22/11
to clojure...@googlegroups.com
I was wondering if anyone has gotten interactive development working with appengine-magic and vimclojure.  Below is an excerpt of a post written by Constantine on Jan. 9, 2011 regarding appengine-magic interactive development:

'I optimized the development process for interactive use. You write code with Emacs and SLIME, recompile functions interactively, and your 
local development web server will show all changes. No restarts and no nasty "watch this directory for changed class files" kludges are 
needed.'

I can certainly use 'lein appengine-prepare' and 'dev_appserver.sh ./project/war/' but it's very cumbersome: 20 seconds from compile and packaging to serving the website for every code change.  There are ways to speed this up but figured it'd be time better spent to see if vimclojure can interact with appengine-magic the way emacs slime can.

Fwiw, I have what I believe is a fully operational vimclojure and nailgun server.  I have repl access from a vim buffer as well as all the other niceties.

Thank you Constantine for appengine-magic and thank you Meikel for vimclojure  : )

Mark Rathwell

unread,
Sep 22, 2011, 10:55:06 AM9/22/11
to clojure...@googlegroups.com
I haven't tested, but I would think that if you have repl access, the
following should work as it does with Emacs/SLIME (though I could be
missing something):

user> (require '[my.website.core :as site])
user> (require '[appengine-magic.core :as gae])
user> (gae/serve site/my-website-app)

And saving changes to files should then be reflected when refreshing
your browser.

- Mark

Constantine Vetoshev

unread,
Sep 23, 2011, 12:02:26 AM9/23/11
to clojure...@googlegroups.com
I think Mark is right. Just do whatever you do in VimClojure to run
interactive development with Nailgun, and it should work. Recompile a
function or file through the REPL, and you should be good to go.

Several months ago, I applied a patch to appengine-magic to enable
VimClojure support (https://github.com/gcv/appengine-magic/pull/6),
although I don't know enough about Vim to actually try it. I assumed
that it works. If it doesn't, I'll need some step-by-step instructions
to get Vim+VimClojure running before I can debug the problem (I know
enough vi to do basic editing, but that's about it).

Ryan Waters

unread,
Sep 23, 2011, 4:27:06 PM9/23/11
to clojure...@googlegroups.com
Please note that I'm ignorant of how interactive development with Emacs/SLIME (or anything else) works with appengine-magic and gae.  ; )  Some or all of the following statements may be obvious!

What Mark wrote works for me at the same level of 'lein appengine-prepare' and 'dev_appserver.sh'.  If the pre-compiled jar files for the app are present then the above forms will serve what's there.  If I make a code change and save the file, the dev server has no knowledge of it.  Even if I shell out and do another 'lein appengine-prepare' and update the jar files in appname/war/WEB-INF/lib, the dev server doesn't check for the updated jar.

Soo ... to my ignorance it seems like there needs to be a way to have all the code load in the repl environment and for changes to be able to replace previously loaded code.

Constantine: I could put together a color-by-number setup for vimclojure but I wouldn't want to waste your time, either.  I'll keep looking at repl (and not jar) based development in vimclojure.

Mark Rathwell

unread,
Sep 23, 2011, 4:42:06 PM9/23/11
to clojure...@googlegroups.com
I'm equally ignorant of your setup...if there is a way to recompile
changed functions and/or files like there is with slime, then doing
that should suffice. If nothing else, just reload the namespaces in
the repl of the files you change should work:

;; this does load all code in the repl, and starts the appengine-magic
dev server
user> (require '[my.website.app_servlet :as servlet])


user> (require '[appengine-magic.core :as gae])

user> (gae/serve servlet/my-website-app)

;; ... change some code, then reload the namespace in repl ...
user> (require '[my.updated.ns] :reload)

;; ... worst case, reload everything in repl ...
user> (require '[myapp.app_servlet :as servlet] :reload-all)

I would think that this should work, and allow the changes to then be
visible in the browser.

- Mark

Constantine Vetoshev

unread,
Sep 23, 2011, 6:24:12 PM9/23/11
to clojure...@googlegroups.com
Small addendum: don't run dev_appserver.sh or 'lein dev-appserver',
and run 'lein appengine-clean' first (just to be on the safe side).
The only thing that should run a web server is the invocation to
appengine-magic.core/serve (see Mark's instructions).

Keep an eye on the standard output stream from Nailgun, VimClojure,
and the REPL, because I'm not sure where the working thread will end
up directing its output. The invocation to the serve function will
start Jetty on port 8080, and this prints some diagnostic output.

Please let us know how this goes; I'm pretty interested in making sure
appengine-magic works in non-SLIME Clojure environments.

Ryan Waters

unread,
Sep 24, 2011, 1:01:05 PM9/24/11
to clojure...@googlegroups.com
Mark: Your suggestions were spot on.  Once I used "(require '[my.updated.ns] :reload)" (which makes sense to me now that I see it) my code changes are reflected in what's running.

A note on my previous message - I was mistaken when I said the sequence of require's and appengine-magic.core/serve wouldn't work without a 'lein appengine-prepare'.  The jar files don't have to be present for interactive development.

Constantine: Not mixing up web server invocations is a good call  ; )  Not sure what I was thinking.

In summary, a working installation of vimclojure with the correct project.clj settings and running things at my project root I can do the following:

lein appengine-clean    <-- not needed, just proof things are clean
lein nailgun            <-- needed once for vimclojure
vim ./src/mywebsite/core
<LocalLeader>sr         <-- starts repl in another vim buffer
;;  navigate to repl buffer
(require '[my.website.core :as site])
(require '[appengine-magic.core :as gae])
(gae/serve site/my-website-app)
;;  verify app is running
;;  go to other buffer, make a change, then go to repl
(require '[my.updated.ns] :reload)
;;  see a change in the app

The cause of my problems weren't appengine-magic or vimclojure at all - I just didn't understand development at the repl.  Thanks for the help!
Reply all
Reply to author
Forward
0 new messages