NOTE: After playing with this configuration for a while, I discovered Jedi. Jedi is an alternative to rope, but the setup is easier and the operation is much quicker/smoother. See this post for more details.
A lot has been written already on how to configure emacs to make it a super powered Python IDE. Here are just some of the sources I have found:
- Emacs setup for Python development – This installs primarily ropemacs and pyflakes/flymake
- Emacs for python – This is a full Python setup all pre-package
- The emacs wiki entry – As with most EmacsWiki entries, there is lots of good information, but not much organization.
So, to add to the confusion and noise, here are my notes as I evolve my own Python setup.
- Install the pyflakes python library:
- easy_install.exe pyflakes
- Note that the emacs is installed below.
- Install rope python library. I like to use easy_install:
easy_install.exe rope - Install ropemode python library:
easy_install.exe ropemode - Install pymacs library. This one is a little trickier because it is both a Python and emacs library
- For the emacs modules, most can be found in the repositories:
- M-x package-list-packages RET
- Now search for pymacs, flymake, flymake-python-pyflakes, pyflakes
- Mark each one with “i”
- Then install them with “x”
- You will have to install ropemacs manually.
- Download it from here.
- Un-tar the archive.
- In the new directory, run
python setup.py install
- Update your .emacs file:
;;pymacs (autoload 'pymacs-apply "pymacs") (autoload 'pymacs-call "pymacs") (autoload 'pymacs-eval "pymacs" nil t) (autoload 'pymacs-exec "pymacs" nil t) (autoload 'pymacs-load "pymacs" nil t) ;;ropemacs (defun load-ropemacs () "Load pymacs and ropemacs" (interactive) (require 'pymacs) (pymacs-load "ropemacs" "rope-") ;; Automatically save project python buffers before refactorings ;;(setq ropemacs-confirm-saving 'nil) ) ;;Flymake errors in Mini-buffer (defun my-flymake-show-help () (when (get-char-property (point) 'flymake-overlay) (let ((help (get-char-property (point) 'help-echo))) (if help (message "%s" help))))) (add-hook 'post-command-hook 'my-flymake-show-help) (add-hook 'python-mode-hook (lambda () (load-ropemacs) (ac-ropemacs-initialize) (add-to-list 'ac-sources 'ac-source-ropemacs) (require 'flymake-python-pyflakes) (flymake-python-pyflakes-load) ))
- If you get a “Key Sequence” error. Read this.
- In my case Bookmark+ was using C-x p n. This was greedy in their case as they bound 4 different key sequences to the same command.
- In order to free up C-x p n, I had to add the following command after loading Bookmark+: (global-unset-key “\C-xpn”)
- Have a look at the ropemacs readme to get an idea for the new tools it offers.
- If you have trouble getting pyflakes to run, have a look here and especially here.
- Making things faster
- Loading ropemacs through pymacs is very slow – no solution yet
- Running Pyflakes on every save is slow – Use python-check instead TODO or this
- rope can be very slow
- TODO
- https://groups.google.com/forum/?fromgroups=#!searchin/rope-dev/ropevim:$20why$20so$20slow$20when$20saving/rope-dev/o0OWbyghjgA/9oVGodHjSPIJ
- TODO: What about pylint?
See Also:
- http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/
[…] « emacs and python using Rope […]