jorgenschaefer / elpy

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

Can we go to definition of module? #768

Open maximvl opened 8 years ago

maximvl commented 8 years ago

Hi! I've found that elpy-goto-definition works well with functions, classes and variables. But I can't go to the definition of modules. The pattern from module1 import module2 is widely used in python and I think it would be nice to have it implemented, if backend supports this, of course.

Simple test I've tried - with file a.py:

def fun_a():
  pass

and file b.py in same directory:

import a
a.fun_a()

So, if I'm in b.py, and point is on fun_a - it will move me to the definition of fun_a. But if point is on a either in import or function call - elpy-goto-definition will do nothing.

jorgenschaefer commented 8 years ago

Hello, and thanks for the suggestion! Elpy simply passes the position to the backend – you seem to be using Rope, which does not do the right thing in this situation. If you add (setq elpy-rpc-backend "jedi") to your config and restart (or just deinstall rope and install jedi), does it work then?

maximvl commented 8 years ago

@jorgenschaefer Well, ye, with jedi go to module definiton works, but symlinked libraries, which were working with rope don't work with jedi. I'll make reproducible example later.

jorgenschaefer commented 8 years ago

Ah, sorry for not understanding before! A reproduceable example would be great – this is something Jedi would have to implement :-)