Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to python modules in emacs

I'm looking into emacs as an alternative to Eclipse. One of my favorite features in Eclipse is being able to mouse over almost any python object and get a listing of its source, then clicking on it to go directly to its code in another file.

I know this must be possible in emacs, I'm just wondering if it's already implemented in a script somewhere and, if so, how to get it up and running on emacs.

Looks like my version is Version 24.2.

Also, since I'll be doing Django development, it would be great if there's a plugin that understands Django template syntax.

like image 241
Jordan Reiter Avatar asked Nov 03 '22 12:11

Jordan Reiter


1 Answers

I also switched from Eclipse to Emacs and I must say that after adjusting to more text-focused ways of exploring code, I don't miss this feature at all.

In Emacs, you can just open a shell prompt (M-x shell). Then run IPython from within the Emacs shell and you're all set. I typically split my screen in half horizontally and make the bottom window thinner, so that it's like the Eclipse console used to be.

I added a feature in my .emacs that lets me "bring to focus" the bottom window and swap it into the top window. So when I am coding, if I come across something where I want to see the source code, I just type C-x c to swap the IPython shell into the top window, and then I type %psource < code thing > and it will display the source.

This covers 95%+ of the use cases I ever had for quickly getting the source in Eclipse. I also don't care about the need to type C-x b or C-x C-f to open the code files. In fact, after about 2 or 3 hours of programming, I find that almost every buffer I could possibly need will already be open, and I just type C-x b < start of file name > and then tab-complete it.

Since I have become more proficient at typing and not needing to move attention away to the mouse, I think this is now actually faster than the "quick" mouse-over plus F3 tactic in Eclipse. And to boot, having IPython open at the bottom is way better than the non-interactive Eclipse console. And you can use things like M-p and M-n to get the forward-backward behavior of IPython in terms of going back through commands.

The one thing I miss is tab completion in IPython. And for this, I think there are some add-ons that will do it but I haven't invested the time yet to install them.

Let me know if you want to see any of the elisp code for the options I mentioned above.

like image 51
ely Avatar answered Nov 15 '22 06:11

ely