Provides several automated refactorings of clojure code.
Use with a test suite and some manual
Thread-last - threads the current expression via
Thread-first - threads the current expression via
Unthread - unthreads the current expression. TODO: this only works with
Extract-fn - extracts the current expression and replaces it with a
call to it.
Extract global - defines the current expression as a global var for
this namespace (using
Rename-binding - select a block, then replace all instances of
old-name with new-name.
Extract local - defines the current expression as a local variable for
the current function definition.
Destructure map - Replaces calls to keywords on a particular map with
a destructuring for that map in the args. Only works on top-level defn
forms with one type of arity.
Slime, a running clojure connection, paredit, and thing at point.
Bind a key to clojure-refactoring-ido, and make sure you select
what you want to operate on first.
(global-set-key (kbd "s-e") 'clojure-refactoring-ido)
Eval the file clojure-refactoring-mode.el inside emacs.
TODO: this should be a minor-mode.
TODO: provide a default binding for clojure-refactoring-ido
NOTE: Very alpha, has some breakages. Report any problems via Github issues.
Add a dev-dependancies to your lein/swank enabled project, then run
For example (inside project.clj)
:dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]
- Wherever possible, have a reverse of each refactoring.
- Refactoring should be quick
- Refactoring names should correspond to known refactorings from OO.
- Write a functional test for each refactoring (takes in a string and
outputs the correct string).
- Breaks if there are any \n newlines inside refactored code.
Copyright (C) 2009 Tom Crayford.