views:

111

answers:

1

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

A: 

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

pygabriel