Skip to content
Lars Andersen edited this page Nov 17, 2015 · 89 revisions

Available refactorings

*: These functions require an active repl connection and our middleware.

A cheatsheat is available here (pdf version).

These functions are available, but used so rarely they're not given a keybinding default:

  • cljr-reify-to-defrecord* replace a call to reify with a call to a defrecord constructor.
  • cljr-version Display version information for clj-refactor and the refactor-nrepl middleware.
  • cljr-toggle-debug-mode When something isn't working as intended debug mode can be toggled to get some more information about what's going on.

Customization

To take a look at the available settings do: M-x customize-group <RET> cljr <RET>

Misc features

Magic requires

Common namespace shorthands are automatically required when you type them:

For instance, typing (io/) adds [clojure.java.io :as io] to the requires.

  • io is clojure.java.io
  • set is clojure.set
  • str is clojure.string
  • walk is clojure.walk
  • zip is clojure.zip

The namespaces in cljr-magic-require-namespaces act like seed values, but once you start writing your own aliases those will be used as candidates in addition to the seed values. Note that since the result of looking up an alias in the project itself is considered to be more current, cljr-magic-require-namespaces is never consulted if the alias lookup in the project provides a hit.

You can turn this off with:

(setq cljr-magic-requires nil)

or set it to :prompt if you want to confirm before it inserts.

Automatic insertion of namespace declaration

When you open a blank .clj-file, clj-refactor inserts the namespace declaration for you.

It will also add the relevant :use clauses in test files, normally using clojure.test, but if you're depending on midje or expectations in your project.clj it uses that instead.

Prefer to insert your own ns-declarations? Then:

(setq clj-add-ns-to-blank-clj-files nil)

Tweaks to paredit

With clj-refactor enabled, any keybindings for paredit-raise-sexp is replaced by cljr-raise-sexp which does the same thing - except it also removes any # in front of function literals and sets.

More stuff to check out

You might also like