Could Emacs be rewritten in Python?

Kim Petersen kp at
Mon Apr 7 14:57:09 CEST 2003

Lothar Scholz wrote:
>>"comparable in power."  The reason is that there is a ton of elisp
>>code out there, including most of Emacs itself, that could be
>>translated to work with PyAlaMode.  My goal isn't to be able to
>>convert in a completely automated fashion, but close enough to be
>>attractive to both an elisp programmer and a Python programmer.
> Sorry, have you ever written a elisp program, something that is larger
> then
> 100 lines. I can't think about a way to provide this in python without
> writting a lisp like interpreter. Remember that the scope of elisp
> variables for example are not lexical. This is something very hard to
> emulate in python.

Why would the variable scheme that elisp uses be tougher to emulate in 
python than a lexical version ? From my pov it should make it a heck of 
a lot easier (think of emacsen as having 1 global dictionary and 1 
buffer specific dictionary for global/buffer local variables) then every 
time you call a function in elisp - do a shallow copy of local variable 
space (dictionary) and send it as the local vars - you can safely throw 
away the dict after function returns).

eg. something like this:

    def do_elisp_fun(local_name_space,fun,funargs,args):
       # apply the args to the funargs (simple ignore :optional etc.)
       map(lambda n,v,d=local_name_space:
       return retval

Excuses made for misremembering how lisp actually does optional args and 
rest ;-)

> I would really suggest to look at the structure of keyhandling,
> keymaps and buffers. And then forget about lisp and design a good
> python editor.

More information about the Python-list mailing list