chrispooledotcom

Simple Python Completion Source for Auto-Complete

01 August 2011

This is a plugin for Auto-Complete (in Emacs) which provides a quick, simple completion source for available python symbols.

Auto-Complete in action

You can of course use rope (with ropemacs), but on Mac OS X this is incredibly slow (typically taking 10 seconds to start a new python buffer), and using rope just for symbol completion is a bit like cracking a nut with a sledge hammer.

Installation

Download the plugin here.

Setup Auto-Complete in the usual fashion, and make sure it gets loaded for python buffers. Then, place ac-python.el in your load-path, and add

(require 'ac-python)

to your .emacs file (after loading Auto-Complete).

Usage

Python symbols will be completed by Auto-Complete, once Emacs learns about these symbols. This is the short-coming of the plugin, but it’s a small price to pay.

To teach Emacs about symbols in imported modules, Emacs needs to execute the Python source. This can be accomplished with python-send-buffer for example, often bound to C-c C-c. If a python process is already running, this is essentially instantaneous.

It works with both python.el and python-mode.el.