Refactor Clojure Codeλ︎
General refactor steps such as changing function names can be done with the Evil tools, iedit, narrowing and helm-ag. These 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 structural editing |
| 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. These refactor commands typically require a running Clojure REPL
, e u (cider-undef) when changing a name of a var (def, defn) to keep the REPL clean of stale names.