Some notes on my emacs setup. Maybe this should go in README for my dotemacs.

Python

Which mode?

There is python-mode.el, and python.el. I have settled on python-mode from the elpa repositories.

Rope?

I tried ropemacs, and really like it when it works. For simple refactorings it can be very convenient, eg. M-x rope-rename.

But the problem is, it tends to choke on large codebases. At work our largest repo is about 300k lines of Python. Open a file with a lot of imports from that codebase and watch emacs hang. It suddenly becomes nearly impossible to do anything in that buffer.

So, I can live without the nice refactoring feautures.

Jedi!

jedi:goto-definition

Without doubt the single biggest productivity boost in my entire python config is this keybinding that takes me to the definition of the method or function invocation I'm looking at:

(add-hook 'python-mode-hook
  (lambda ()
    (define-key python-mode-map (kbd "C-c g") 'jedi:goto-definition)
    ;; ... other stuff ...
  )
)

(The same feature is in Rope as rope-goto-definition, but the jedi version seems to work just as well.)

completion

Jedi completion works reasonably well with no special tweaks.

Flymake

For realtime linting, I currently use the flymake-python-pyflakes package from melpa. I also use flymake-cursor (also from melpa) which shows flymake errors appear in the minibuffer, so I don't have to move the mouse around to see them.

Menu navigation

To have a dropdown menu for jumping to function and class definitions in the current buffer:

(add-hook 'python-mode-hook 'imenu-add-menubar-index)

Comments

comments powered by Disqus