Could Emacs be rewritten in Python?

Beni Cherniavsky cben at techunix.technion.ac.il
Mon Apr 7 11:59:00 EDT 2003


Patrick K. O'Brien wrote on 2003-04-06:

> 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 wrote some implementation ideas in other posts, I'll now write my
wishes for being better than emacs...

My #1 wish is not to have one major mode with one syntax per buffer.
Suppose I'm writing Python so I want python-mode - but I'm also
writing reStructuredText in my doc-strings so I want rest-mode [being
written by somebody now, still incomplete].  And then the python is
generating xml snippets, so I want xml-mode inside specific places.

Emacs started out by assuming there is just one major mode.  That
means there is one syntax table, one paragraph-start regexp, one
evrything.  Some specific things are allowed to be modified by minor
modes and text properties/overlay and the rest can be half-emulated by
mmm-mode.sf.net but I strongly believe this can and should be
addressed from the first day.

When Python mode discovers that something is a string, it should mark
it as foreign territory and let the user decide what modes get to
control its content.  A buffer will thus contain a hierarchy of modes.

This reminds me, there must be better ways to achieve syntax
sensitivity than emacs.  It's not something to add at an after-thougt
in font-lock in an optional way; there should be standard mechanisms
for modes to extract and communicate syntactic information.

As a whole, I want more flexible ways to describe syntaxes, so that
specialized modes could be constructed from pieces reather than
written from scratch.  E.g. I want <tag>...</tag> in xml to be
described as sort of "big parentheses" in a way that show-paren will
understand.

#2 (or is it 4 already?): this is a dangerous issue but perhaps flat
text buffers are not the best way.  They are, for most editing modes;
however when I need a list-of-dicts buffer, a repr-of-list-of-dicts is
not the ideal thing to work with.

Emacs has quite a lot of modes that are not about editing flat text at
all (dired, buffer-list, custom, rmail's inbox, speedbar, etc.).
They could well benefit from an being able to manipulate other
structures.  To be able to use page-up/down and any other bindings
that are not overriden, any such structure will need to provide view
of itself in simpler terms, all down to flat text...

I have many other ideas but I can't put them down clearly yet...

-- 
Beni Cherniavsky <cben at tx.technion.ac.il>
When I grow up I want to write an Emacs.





More information about the Python-list mailing list