Question re Mikael Sundberg's Getting started with compojure

15 views
Skip to first unread message

Jacek Laskowski

unread,
Aug 31, 2010, 10:24:50 AM8/31/10
to clo...@googlegroups.com
Hi,

I've been reading Mikael Sundberg's Getting started with compojure [1]
and been wondering how to reload a function "display" (without Emacs
and swank) so I don't have to restart repl. I'd love to update the
function while running lein repl. Is it possible?* How?

[1] http://cleancode.se/2010/08/30/getting-started-with-compojure.html

* I know it's possible, but dunno how and therefore the question :)

Jacek

--
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl

Mark Rathwell

unread,
Aug 31, 2010, 10:44:26 AM8/31/10
to clo...@googlegroups.com

I'm not sure if this is the question you are asking, but to reload a namespace in a repl, depending on whether you are use-ing the ns or require-ing it, there are :reload and :reload-all  keyword arguments accepted:

(require '[foo.something :as something] :reload)
(require '[foo.something :as something] :reload-all)
...


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Jacek Laskowski

unread,
Aug 31, 2010, 10:52:36 AM8/31/10
to clo...@googlegroups.com
On Tue, Aug 31, 2010 at 4:44 PM, Mark Rathwell <mark.r...@gmail.com> wrote:
>
> I'm not sure if this is the question you are asking, but to reload a
> namespace in a repl, depending on whether you are use-ing the ns or
> require-ing it, there are :reload and :reload-all  keyword arguments
> accepted:
> (require '[foo.something :as something] :reload)
> (require '[foo.something :as something] :reload-all)

Thanks! That was it.

As we're at it, how does people reload functions while connected to a
remote Clojure app from within Emacs? Do they also
(require...:reload)? Is there a tutorial/article about it?

Michał Marczyk

unread,
Aug 31, 2010, 11:11:56 AM8/31/10
to clo...@googlegroups.com
On 31 August 2010 16:52, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
> As we're at it, how does people reload functions while connected to a
> remote Clojure app from within Emacs? Do they also
> (require...:reload)? Is there a tutorial/article about it?

One possibility is to open the remote file wherein the function in
question is defined, modify it as appropriate, then either enter
(require :reload ...) at the REPL or press C-c C-k (a SLIME / Swank
binding) in the buffer with the modified code. (Or press C-c C-c with
point inside the top-level form in question.)

Another possibility -- which is open even if the app has been packaged
as a .jar / .war file -- is to switch to the appropriate namespace at
the REPL and evaluate the appropriate defn; or maybe stay in the user
namespace and use clojure.core/intern / alter-var-root / .bindRoot to
replace the root binding of the Var holding the function.

Sincerely,
Michał

Mikael Sundberg

unread,
Sep 1, 2010, 6:32:54 AM9/1/10
to clo...@googlegroups.com
Hi
thanks for the great question, and the answer! i have updated the post
to contain the information.

http://cleancode.se/2010/08/30/getting-started-with-compojure.html


/Micke

2010/8/31 Michał Marczyk <michal....@gmail.com>:

Reply all
Reply to author
Forward
0 new messages