Could Emacs be rewritten in Python?

Patrick K. O'Brien pobrien at orbtech.com
Fri Apr 18 10:54:39 EDT 2003


"Greg Ewing (using news.cis.dfn.de)" <ckea25d02 at sneakemail.com> writes:

> Patrick K. O'Brien wrote:
> > Assuming I had the
> > mechanism in place to bind keystrokes to a user-created command, how
> > would I know what parameters that command expected?
> 
> I think there's a mistake here in thinking of commands
> as being bound to keystrokes and nothing else. It
> would be better to think in terms of handlers for
> keystrokes being bound to particular objects, or
> classes of objects.
> 
> For instance, a command that operated on the text
> in a buffer would be attached to the Buffer class,
> and one that operated on a window would be
> attached to the Window class.
> 
> So the command for binding a command wouldn't
> just say "bind this function to this key", it
> would say "bind this function to an occurrence
> of this key being received by this class of
> object".

Hmm.  Sounds a bit like the typical event handling in a GUI.  That
could be good.  So, off the top of my head, let's say each object had
a dictionary used to register keychord/event handler pairs, and that
the event handler functions were bound to the object as methods.  That
would allow the functions access to attributes and other methods of
the object.  If the function/method were bound to the object
containing most of the state needed by the method, there would be no
need to pass parameters to the method.  Other objects could be
accessed by navigating the object graph.

Did I understand you correctly?

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------




More information about the Python-list mailing list