
Emacs setup for Python development - rachbelaid
http://caisah.info/emacs-for-python/
======
coolsunglasses
That's a lot of junk that doesn't have a lot to do with Python.

Take a look here at my dotfiles to see how to use Rope/Ropemode/Ropemacs to
get a Python-aware Emacs environment with the goodies that entails:

<https://github.com/bitemyapp/dotfiles/>

Edit: Try to ignore or not be daunted by the other directories, my Emacs setup
is well maintained but very old and has over 400,000 LOC.

~~~
flatline
Yep, Rope in emacs is the way to go. I remember having trouble getting Pymacs
set up the first time around, but if you are working on an actual python
project (not just some loosely couple source files) I have not found a better
environment anywhere.

------
julienchastang
On a related note, emacs support for ipython notebook with ein
(<http://tkf.github.io/emacs-ipython-notebook/>) is marvelous. If you are
comfortable with emacs, ein is far superior for interacting with your ipython
notebook compared to the browser experience.

~~~
jsw97
Seriously. I spend a large fraction of my day in ein. Great for exploratory
data analysis.

------
brudgers
I have found EmacsRedux informative for learning GNUemacs. The key for me was
understanding that Emacs is command driven and that shortcuts are merely
shortcuts to commands - i.e. M-x <command> invokes the <command> of which
emacs has hundreds (+ lisp expressions). Unlike shortcuts, commands can be
accessed with auto-complete.

<http://emacsredux.com/>

------
tikhonj
The Emacs tutorial is a great place to start.

Using Emacs is a bit of a paradigm shift in text editing, so you should expect
a bit more work up front for great results later on. Going through the
tutorial and learning the basic vocabulary and commands takes care of most of
that up-front cost and should not take long. I think it took me less than two
weeks of fairly casual use.

Part of the beauty is that most of the things in the blog are not limited to
Python. All the general text-editing stuff trivially transfers to other
languages you may want to learn. And Emacs supports any language you _do_ want
to learn to one extent or the other. For some languages, Emacs is even the
only option!

So you should consider going through at least the beginning of all this even
if you're not interested in Python _per se_.

Also, check out some of the Emacs Rocks![1] videos. I keep on recommending
them because they are _awesome_. They really show off why Emacs is truly
magical.

[1]: <http://emacsrocks.com/>

~~~
ninetax
>> For some languages, Emacs is even the only option

Which ones would those be? Common Lisp using SLIME?

~~~
Ixiaus
Erlang. Even though some IDE's are starting to support it now. Erlang is the
original reason I got into using Emacs actually.

------
parennoob
I have a similar emacs setup with cedet, autocomplete, and whatnot, but I have
one problem -- things like "evaluate this buffer" don't work when your python
environment is on a remote server (due to work constraints I am obliged to do
this). Files open fine over tramp, but a lot of things (python-mode, jedi,
etc.) don't understand that they are interacting with a remote python shell.
Is there any easy way that someone here has found to get around that?

~~~
cdjk
The way I get around that is running emacs on the remote server in
screen/tmux. If there's a better way I'd love to know it, but I haven't found
it to be too much of a problem.

~~~
parennoob
I have tried this, and it works fine... _almost_ :) The only problem I have is
that doesn't give you some of the GUI goodness. For example, I find CEDET's
code folding incredibly useful when I want to get a bird's eye view of my
modules, and the CLI version doesn't seem to support drawing the expandoes.

Thanks for the tip though.

~~~
cdjk
True, but "emacs in screen/tmux" has a few other advantages for me - namely
that I can leave all my buffers open when I leave the office and easily pick
up from home. It's also more pleasant over a slow vpn connection.

------
theanalyst
I'm happy with using elpy for python development in Emacs. The defaults are
nice. Also backends like jedi/rope are supported.
<https://github.com/jorgenschaefer/elpy>

------
mrgoldenbrown
The author seems to imply that sublime does not qualify as a "serious" editor,
and offers a link to quora as explanation, but the article there doesn't
address what Sublime is missing at all.

~~~
codewright
>doesn't address what Sublime is missing at all.

Being a fully programmable work environment.

Edit: I used ST2 for about a month. The Python was neat but it's going to fade
away eventually.

~~~
FuzzyDunlop
Vim and Emacs have had decades to get to that point. ST is a comparative baby.
I'd love to see a modern editor that isn't designed around a terminal join
those ranks.

~~~
lake99
There is Acme for Plan9 [1] and it has inspired a few other editors. I don't
use them myself because they don't have syntax highlighting.

[1]: demo at <http://www.youtube.com/watch?v=dP1xVpMPn8M>

~~~
symmetricsaurus
That looks awesome. Having used the WMII window manager it looks quite
familiar. Even then the learning curve seems steep.

------
giulivo
I've attempted something similar but without installing any external package
and by documenting the config inline so that one could pick only what needed:

[http://giuliofidente.com/2013/04/getting-to-know-and-use-
ema...](http://giuliofidente.com/2013/04/getting-to-know-and-use-emacs-
better.html)

In there I tried to address also other issues like saving the backup files out
of the working dir, show the line numbers, highlight long lines.

------
lsiebert
Can someone link a vim setup for python, for comparison puposes, perhaps with
a short feature comparison? I'm currently a vim user with a fairly basic setup
(I tried st 2 but couldn't figure it out for managing my work flow) , but I
find the idea of emacs attractive.

~~~
tomsthumb
Conque shell can 'run a terminal' inside of vim, but it's a bit buggy. It's
not really fair to compare vim and emacs, because vim is _just_ a text editor.
Vim + screen or vim + tmux (my preference) is much closer to the same ...
category of thing that emacs is.

You can split tmux tabs so that you can have vim up in one pane on a 'tab' and
python running in another pane in the same 'tab'. Both tmux and screen have
decent copy/paste functionality that mimics vim's movement behaviour to some
degree. (Tmux also has scriptable sessions, if you like different workflows
for different types of projects)

If you want a nice vim setup SPF-13 is a decent place to start. There are tmux
configs everywhere. Also Ipython does a lot for you as far as completion,
looking at documentation, and the like.

I think that's kind of what you're after, sorry if it's not.

~~~
chameco
Tmuxinator especially makes doing the vim + tmux thing so much better because
it has nice session support (just type "mux <name>" to bring up a session).
I've been using it for about six months now, and my current setup can do
anything an IDE can in a fraction of a time.

~~~
mrgoldenbrown
What do you use for automatic refactoring? Are there good command line tools
for renaming methods across an entire source tree for example?

~~~
tomsthumb
sed can do in place recursive changes for search patterns. if you use vim
search and replace across a file it's pretty much the same.

~~~
mrgoldenbrown
I was thinking of something more context aware than a simple find/replace. If
you're changing MyClass.getFoo() to MyClass.getBar(), you only want to do that
on instances of MyClass.

~~~
lsiebert
If there is a plugin for intelligent refactoring in vim, I have yet to see it.
You can use tabdo or buffdo for multiple files, but the class/object parsing
isn't there.

------
agentultra
iPython Notebook is really cool and the emacs client is extremely well done. I
highly recommend checking it out.

<http://tkf.github.io/emacs-ipython-notebook/>

