Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make Python etags a bit smarter with emacs?

I work on my Django project with emacs. In my virtualenv "postactivate" script I have the following simple command:

find -L . -type f -name "*.py" | xargs etags -e > /dev/null 2>&1 &

The TAGS file generates just fine but the system seems rather dumb. When the cursor is a model filter call, e.g.

MyModel.objects.filter(...)

and I hit M-., sometimes emacs takes me place where MyModel is imported at the time of the file (the actual import statement). I only ever want to visit class, method, and function definitions.

Is there a way to make etags smarter?

Thanks, Ryan Kaskel

like image 907
Ryan Kaskel Avatar asked Jun 03 '10 10:06

Ryan Kaskel


1 Answers

Getting correct module analysis with a language like python is very hard, due to his dynamic nature the best way to get correct information is doing static analysis or heuristics.

Currently the best I've found is exploring methods with the ropemacs extension that has great features like code assist (quite smart) and calltips.

Unfortunately it's not easy to get it right with ropemacs, you should install first pymacs and then configure install various rope libraries. (I'm working on a packaged version of it)

Another package that would statically analyze your python code and produce "smarter tags" would be something like pysmell, but I haven't used it extensively

like image 166
pygabriel Avatar answered Sep 28 '22 07:09

pygabriel