tcrayford / clojure-refactoring

Basic refactoring functionality for clojure/emacs
BSD 2-Clause "Simplified" License
57 stars 13 forks source link

Clojure error, "unable to resolve symbol" #1

Open edgargoncalves opened 14 years ago

edgargoncalves commented 14 years ago

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).

tcrayford commented 14 years ago

I'm pretty sure I know what the problem is here, and have now fixed it on the latest version of clojure-refactoring-mode.el on github. Download that and eval-buffer it again and you should be good to go.

Thanks for the heads up!

edgargoncalves commented 14 years ago

Thanks for the quick fix! I still have problems, though I suspect they're due to the clojure.contrib version I'm using (1.2 snapshot). The following error occurs for extract-fn, extract-local (at least):

partition-by already refers to: #'clojure.contrib.seq-utils/partition-by in namespace: clojure-refactoring.extract-method [Thrown class java.lang.IllegalStateException]

Also, about rename-fn:

I can't find that function, do you have it on another library you're not requiring? (you should perhaps include it on your .el )

Thanks again!

tcrayford commented 14 years ago

I've fixed the errors with 1.2 on the latest version as well. (though this breaks stuff for people using 1.1). If you want to submit a patch for 1.1 support, please do.

Cleanup-buffer is from the emacs starter kit. Its definition is here: http://gist.github.com/446870. I'll debate about including it.

Rename-fn should definitely pick up the name of the fn at point (possibly using thingatp.el), but I haven't got round to that yet. Rename fn doesn't really do very much at the moment, its the next big thing to add.

I have a query regarding this for users: rename-fn either needs to touch stuff on disk, or it needs to fling a list of changes to emacs. Do you have any preferences either way?

Thanks a bunch for all the feedback, much appreciated!

edgargoncalves commented 14 years ago

It's working properly now, thanks a lot! Related to the backwards-compatibility, aren't people generally moving on to clojure 1.2? Most libraries I'm using have stopped supporting 1.1 - at most, they have a end-of-line branch/binary distribution artifact, and the development is only done for 1.2. For my usage, personally, I don't need the 1.1 support, but if you want to I can try and make you that patch.

Now about rename-fn: yeah, thingatp.el is the emacsen-way to go! And I can only compare to other IDEs/languages (e.g., java+eclipse or java+jdee), and it's more common to have a rename refactorization work on all files, even the unopened ones.

Now once you have the main functionality working, I would propose a slight enhancement on the emacs side (perhaps for all refactorizations): when using one of your commands, a lower window should pop up (a large minibuffer, or something like the Completions buffer) with a changes manager. From this manager one would see a list of proposed changes (grouped into files), and you could preview them, see a diff for them, apply them, apply all, revert to the originals or cancel everything. I understand this is perhaps out of scope, but it would make usage of your library a breeze, even for newcomers (I'd say it would become as mandatory as clojure-mode itself!). What do you think about it?

I'm glad you appreciate and make good use of my comments!

tcrayford commented 14 years ago

I'm interested in that, good idea! I'll probably only do this for refactoring that touches more than the current scope, as with those you can easily see what has changed.

Are you any good with elisp? I'd love to have some help on that side of things, I'm pretty strong with clojure itself, but emacs is a whole different world (and you can see the code is kinda messy).

I've now upgraded the latest version to "0.1.6-SNAPSHOT", which should fix most things (I'm testing it out now). Being a SNAPSHOT, I'll be updating this a lot over the next week or so (which is about the timing I expect to add rename-fn support properly).

edgargoncalves commented 14 years ago

I think I'd manage something, at least in a rough-but-usable state. But I'll probably have to wait a couple of months before getting my hands on hat, I'm pretty tied up on right now. As soon as I have a decent codebase for that manager, I'll mail you with details.

tcrayford commented 14 years ago

Sure.