Could Emacs be rewritten in Python?

Patrick K. O'Brien pobrien at
Sun Apr 6 19:39:17 CEST 2003

Paul Rubin <> writes:

> pobrien at (Patrick K. O'Brien) writes:
> > If you were crazy enough to think that you could create a program
> > along the lines of Emacs, but written in Python, how would you go
> > about it?  How would you design the domain model for files, buffers,
> > windows, and frames?  How would you allow the same level of
> > customizability?  How would you map functions (or methods or whatever)
> > to keys?  Any thoughts?
> I think you're going to need some C extensions to represent buffers
> similar to how Emacs does it.  It's hard to move blocks of characters
> around in Python with the array module without constantly re-allocating 
> the arrays.  Of course it can't be done with strings because Python
> strings are immutable.

The Scintilla text control (written in C and wrapped in wxPython by a
control called wxStyledTextCtrl) handles the on-screen representation
and user-manipulation of the text.  So that part is actually easy.
Just read in a file, feed it to Scintilla, and go.  The next step is
wrapping all this in an Emacs-like framework.

> Aside from that, the general architecture can probably be similar to
> Emacs.  You might want to use a multi-threaded interpreter to make
> extensions more flexible (e.g. so they can respond to keystrokes while
> doing other stuff).  You generally won't need as much C code as Emacs
> used, because computers are much faster now than when Emacs was
> written.  Python and Emacs Lisp are fairly similar in speed, I think.

I shouldn't need any C, hopefully, since I'm using Scintilla.
Mimicking the Emacs architecture is where I want to focus next - how
to represent commands and keybindings and user-coded extensions and
customizations and so forth.

Patrick K. O'Brien
"Your source for Python programming expertise."

More information about the Python-list mailing list