Auto reloading of dependencies with cider

528 views
Skip to first unread message

Mark P

unread,
Jun 22, 2014, 9:21:09 PM6/22/14
to clo...@googlegroups.com
I am fairly new to using cider.  Initially I put all my code into my core.clj file that lein created for me.  But now I am splitting my file up into multiple clj files and using things like:

(ns myprog.core
  (:use [myprog.milk :as milkx :only []])
  (:use [myprog.cheese.brie :as briex :only [brielist]])
  (:use [myprog.cheese.cheddar :as chedderx :only [chedderlist]])
  (:gen-class))

to pull in definitions from other clj files into my core.clj.

This seems to be working well enough, except that, doing "C-c C-k" (ie cider-load-current-buffer) no longer always loads everything.

It seems to auto load all the other clj files the first time.  But when I make changes in these other files (which I save), these are not seen after doing a "C-c C-k" in core.clj.  It seems that I need to explicitly go to each buffer with a modification in it and do "C-c C-k" in each one.  Then I can do "C-c C-k" in the main buffer and all the changes will be seen.

I can cope with this, but it would be nice to be able to give a command in the core.clj buffer which effectively does "load core.clj and recursively reload any dependency buffers/files".  (Even better would be if it only reloaded those files/buffers which had changed since the last load.)

What do other people generally do here?  I suspect there is a commandline way of getting lein to do this for me.  Is that what people do?  Or do people just make sure they do "C-c C-k" in each relevant buffer?  (But isn't this error prone - ie if you forget to do this in some buffer that you've changed?)

Thanks,

Mark.



Ralf Schmitt

unread,
Jun 23, 2014, 1:13:41 AM6/23/14
to clo...@googlegroups.com
Mark P <pier...@gmail.com> writes:

> What do other people generally do here? I suspect there is a commandline
> way of getting lein to do this for me. Is that what people do? Or do
> people just make sure they do "C-c C-k" in each relevant buffer? (But
> isn't this error prone - ie if you forget to do this in some buffer that
> you've changed?)

Take a look at tools.namespace [1], which handles reloading your
namespaces. Also please read
http://dev.solita.fi/2014/03/18/pimp-my-repl.html.

[1] https://github.com/clojure/tools.namespace

--
Cheers
Ralf

Michael Griffiths

unread,
Jun 23, 2014, 6:08:40 AM6/23/14
to clo...@googlegroups.com
You can also use the `cider-refresh` command, which is bound to `C-c C-x` by default. It uses tools.namespace.repl/refresh under the hood.

Mark P

unread,
Jun 24, 2014, 1:23:19 AM6/24/14
to clo...@googlegroups.com, ra...@systemexit.de
Thanks Ralf.  This looks like exactly what I need.

Mark P

unread,
Jun 24, 2014, 1:30:36 AM6/24/14
to clo...@googlegroups.com
Thanks Michael.  With a bit of updating and configuring I seem to have this working

For the benefit of other readers of this thread...  to get C-c C-x to work, it seems you still need to configure things properly for tools.namespace... see the links in Ralf's post above for details on this.

Also, I needed to upgrade to the latest version of cider (0.7.0) for the cider integration with refresh.

Cheers,

Mark.
Reply all
Reply to author
Forward
0 new messages