How to refactor (rename namespaces / move functions)?


I have built multiple apps (clj+cljs+cljc) which base on multiple common libraries. I was a Java developer for 20 years, my Clojure codebase is a mess. I learned some things and I would like to clean up. Especially I need to rename namespaces and move functions to other namespaces.

I am looking for a tool which can move functions and update all callers accross multiple projects like Eclipse does for Java.

Does any IDE for Clojure support such refactoring?

If there’s a tool to make this easier, I’d also like to know about it.

I’ve been satisfied with just using grep and similar tools. If you use emacs, find and replace across files is easy enough (

There’s also clj-refactor, which I haven’t used.

My understanding is that clojure is dynamic enough that automating this with 100% accuracy is impossible (suppose a macro generates function defs that are referenced elsewhere; suppose some monster on your team thinks it’s a good idea to (eval (list (symbol (str "i" "n" "c")) 1))), but I’m sure a tool could be built to support the common cases.

I think clj-refactor is your best bet. Cursive does support renaming namespaces and functions across the project, but it doesn’t have a refactoring for moving functions/symbols to another namespace.

I tried clj-refactor, but it fails if there is a cljs or cljc file in the project. :frowning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.