GithubHelp home page GithubHelp logo

tcrayford / clojure-refactoring Goto Github PK

View Code? Open in Web Editor NEW
57.0 1.0 13.0 7.98 MB

Basic refactoring functionality for clojure/emacs

License: BSD 2-Clause "Simplified" License

Clojure 90.15% Emacs Lisp 9.85%

clojure-refactoring's Introduction

NOTICE OF DEPRECATION

This version of clojure-refactoring is deprecated. Up to date versions can be found at https://github.com/joodie/clojure-refactoring

END OF NOTE

Clojure Refactoring Mode

Provides automated refactoring for clojure code.

Available refactorings

Extract-fn - extracts the current expression and replaces it with a call to it.

Global rename - Replaces all calls to the symbol at point (in the current project) with the new name.

Thread-last - threads the current expression via ->>

Thread-first - threads the current expression via ->

Unthread - unthreads the current expression.

Extract global - defines the current expression as a global var for this namespace (using def).

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. Also only works for maps called with keywords.

Rename - Changes a name just in this sexp.

Emacs dependancies

Slime, ido, a running clojure connection, paredit, and thing at point.

Installation

Add clojure refactoring mode into lein's dev-dependancies then run lein deps

For example (inside project.clj) :dev-dependencies [[swank-clojure "1.2.1"] [clojure-refactoring "0.5.0"]]

Usage

Put clojure-refactoring-mode.el somewhere on your load path and add (require 'clojure-refactoring-mode) into your .emacs.

Clojure-refactoring-ido will then be bound to C-c C-r.

Note that global rename will be slow at first, as it has to read the source files into a cached.

NOTE: Still in alpha, has some breakages. Report any problems via Github Issues please.

Hacking Philosophy

  • Wherever possible, have a reverse of each refactoring.
  • Refactoring should be quick
  • Refactoring names should correspond to known refactorings from OO (where possible).
  • Write a functional test for each refactoring (takes in a string and outputs the correct string).

Known bugs

After doing a global rename, refactoring-mode doesn't reload the namespaces in the right order, so there is sometimes a null pointer exception after doing this. For now, you can fix this by restarting swank.

License

Copyright (C) 2009-2010 Tom Crayford.

clojure-refactoring's People

Contributors

joodie avatar tcrayford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

clojure-refactoring's Issues

Extract-fn failure:

extracting: (find-bindings-above-node (first node) expr bnd-syms)

from
(defn find-bindings-above-node
"Returns all binding forms above expr in node."
([node expr](find-bindings-above-node node expr []))
([node expr bnd-syms]
(unique-vec
(flatten
(cond (more-than-one seq? node)
(process-multiple-nodes node expr bnd-syms)

         (last-binding-form? node)
         (add-binding-form node bnd-syms)

         (binding-node? node)
         (process-remaining-bindings node expr bnd-syms)

         (seq? (first node))
         (find-bindings-above-node (first node) expr bnd-syms)

         :else
         (find-bindings-above-node (rest node) expr bnd-syms))))))

fails

No error thrown

Clojure error, "unable to resolve symbol"

I installed your promising package, but all I'm getting with all refactoring options is this error:

Unable to resolve symbol: extract-method in this context
[Thrown class java.lang.Exception]

I confirm that I have my lib folder withe the lein-obtained clojure-refactoring-0.1.5.jar, so I wonder if I'm missing any configuration step, or if my usage of your package is correct (I suppose this error has nothing to do with what's selected, though I've tried with several combinations of defun, s-exp, fn-name, no selection).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.