Could Emacs be rewritten in Python?
Carl Banks
imbosol-1049688353 at aerojockey.com
Mon Apr 7 01:23:08 EDT 2003
"Greg Ewing (using news.cis.dfn.de)" wrote:
> Carl Banks wrote:
>> As an example, take the section on buffers. First function is
>> "current-buffer".
>> Next three functions are "save-current-buffer", "with-current-buffer",
>> and "with-temp-buffer". These are actually not functions, but special
>> forms and macros.
>
> In a truly Pythonic design, I think I would do away with
> the notion of a current-buffer as a dynamically scoped
> global variable. Instead, the buffer to be operated on
> would be passed as a parameter to anything which does
> things to a buffer (or they would be methods of Buffer).
>
> You may need to have a current-buffer and associated
> functions for elisp compatibility, but they should be
> implemented on top of a more Pythonic layer.
Three objections:
First, current-buffer is a function, not a dynamically-scoped
variable.
Second, given that the keyboard focus can only be active in one buffer
at a time, the idea of a current buffer is absolutely necessary. You
could argue that you need a current window, not a current buffer, but
you need a current something. When you type "a", some function is
going to have to call "current-buffer".
Third, there are a *ton* of functions in Emacs that operate on a
certain point in a certain buffer (delete-char, kill-region, etc.).
These kinds of functions typically get bound to keystrokes and other
sorts of commands, which a user expects to work in the current buffer.
If all these functions had to be passed the current buffer as an
argument, it would just complicate things.
The user-interaction functions can, in turn, call general functions
that operate on a given buffer.
The idea of a "Pythonic" layer is a good one, but let's not get rid of
uncomplicated functions like delete-char just because it violates some
notion of what's Pythonic.
--
CARL BANKS
More information about the Python-list
mailing list