jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.89k stars 259 forks source link

Refactoring discontinued for elpy #774

Open kootenpv opened 8 years ago

kootenpv commented 8 years ago

I'm interested in adding support for refactoring to Emacs / Python.

I remember refactoring was discontinued for elpy, and I was wondering if this could be an addition to elpy at some point:

https://github.com/kootenpv/python-comprehension

jorgenschaefer commented 8 years ago

Hello, and thanks for the suggestion! This looks like an interesting tool. I'd have to see how much code it actually handles – it would probably be a better idea if this would use Python to parse Python instead of a homegrown parser, though.

emacsway commented 8 years ago

use Python to parse Python

I think so too, - compiler.parse()

AST also can be parsed by elisp similar to js2-mode, but it's more difficult.

Btw, rope works great for me.

emacsway commented 8 years ago

Also emacs has parser for python in builtin sematic. But native compiler.parse() maybe a better solution.

kootenpv commented 8 years ago

@emacsway Does rope handle list comprehension/decomprehension?

emacsway commented 8 years ago

I mean, that rope works great for me (for refactoring, autocomplete). Even if @jorgenschaefer will exclude rope from elpy (I hope this will never happen), - I'll use rope with ropemacs in this case (sometimes I use ropemacs today, for example for rope-find-occurrences).

Does rope handle list comprehension/decomprehension?

@kootenpv maybe does, but not explicitly, by Restructuring. But rope has clean code, stable interfaces, and excellent codebase, it's easy to extend rope. You can use rope's parsed syntax tree (based on AST) to create explicit refactoring method for comprehension/decomprehension.

Also see source code of lib2to3, it also does refactoring by AST (yapf uses it). But I think, pull request to rope will be better (it's not good to have a lot of dependencies). Btw, author of yapf has did commits to rope.

emacsway commented 8 years ago

Also see wisent-python-lex-buffer in emacs-src/lisp/cedet/semantic/wisent/python.el (if you prefer elisp rather than python)

jorgenschaefer commented 8 years ago

I will not include a Python parser written in Emacs Lisp in Elpy.

emacsway commented 8 years ago

It's builtin in emacs since 2010-01-10, see log history of emacs source code http://git.savannah.gnu.org/cgit/emacs.git/log/lisp/cedet/semantic/wisent/python.el We don't need to include it, it's already included.