Skip to content

Refactor Clojure Codeλ︎

General refactor steps such as changing function names can be done with the Evil tools, iedit, narrowing and helm-ag. General tools do not require a running Clojure REPL.

Examples of refactoring names: functions, namespace or project.

Structural editing via the SPC k lisp state uses smartparens to alter the your code whist respecting the structure, as defined by parens, [ ] { } ( ) and even " ". Smartparens works for all languages, although is most useful with lisp syntax.

Refactor Approach Usage
narrowing refactor in function on region (usually with iedit)
iedit refactor in current namespace
helm-ag project wide refactor (usually with iedit)
lisp state A state for smartparens
clojure-mode , r for clojure specific refactor commands
Clojure LSP , r for clojure specific refactor commands

Clojure REPL based refactoringλ︎

Clojure specific refactor commands are in the clojure-mode refactor menu, , r provided by the package clj-refactor. Many refactor commands require a running Clojure REPL to work.

, e u (cider-undef) when changing a name of a var (def, defn) to keep the REPL clean of stale names.