Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use meta-dot (M-.) in python with emacs?

Tags:

Is there an equivalent of slime for python?

For example, if I position the cursor on foo() and do M-. (jump to definition) I would like to see the source definition of the function foo

This should work regardless of whether foo is in

1) the local project directory

2) in some ~/.virtualenvs/bar/lib/site-packages

3) in some other python-path

4) virtual env is in use (ie, it should look in my current virtualenv)

Does the pymacs/ropemacs combination do any of this?

like image 793
nunb Avatar asked Aug 17 '10 09:08

nunb


2 Answers

To avoid the -e you can use etags and with a find you recursively add the py file:

find . -type f -name '*.py' | xargs etags 
like image 50
mathk Avatar answered Oct 15 '22 21:10

mathk


Most of the answers mentioned here are outdated. A simple solution is to use elpy for M-. without etags(which requires additional work).

Install elpy as mentioned here.

M-x package-install elpy 

and then install python packages

$ sudo pip install rope jedi 

Restart emacs , open any python file and run M-.

Elpy is fully documented, you can read about M-. here.

like image 36
Pandikunta Anand Reddy Avatar answered Oct 15 '22 21:10

Pandikunta Anand Reddy