elisp -> Python (was Re: [OT] Emacs, Eclipse, Leo (was Re: IDE

François Pinard pinard at iro.umontreal.ca
Thu Jul 22 11:53:02 EDT 2004


[Paul Rubin]

> [François Pinard]

> > Pymacs is not Emacs Lisp, and Python in Vim is not Vimscript either,
> > tweaks are needed in both cases for accessing some of the underlying
> > scripting facilities.  Pymacs is rather elegant, Python in Vim is
> > rather clean.

> What are these editors?  Are they written in Python?  How do they
> implement the editing buffer?  How do they implement searching
> backwards for a regexp in the buffer?

Pymacs is just a add-on over Emacs, it is not an editor in itself, like
Emacs is.  Pymacs is written half in Python, half in Emacs Lisp.  Pymacs
allows Emacs to externally start a collaborating Python interpreter, and
be extended with Python instead of Emacs Lisp.  The Python extension,
executed by the Python interpreter, handles editing by "asking" Emacs to
do the work.  For example, it could call `lisp.buffer-substring()' to
get a copy of part of a buffer, massage that string in Python, and then
use both `lisp.delete()' and `lisp.insert()' to replace the original
text by the modified one.  One normally writes `from Pymacs import lisp'
first, and the `lisp' object contains a lot of magic, including all
about the communication protocol.

Python in Vim is just a add-on over Vim, it is not an editor in itself,
like Vim is.  Python in Vim is the full Python interpreter, written in
C, and linked right into Vim.  Python in Vim allows Vim to be extended
with Python instead of Vimscript.  The Python extension handles editing
by "directly" acting on `vim.current.buffer', which is a Python list
of buffer lines.  One normally write `import vim' first, and the `vim'
module offers a lot of magic, provided by the Vim-Python integration.

Searching backwards for a regexp in the buffer?  In both Pymacs and
Python in Vim, I would likely get Python to ask either Emacs, likely
through something like `lisp.regexp_search_backwards("REGEXP")', or Vim,
likely through something like `vim.command("normal ?REGEXP?")'.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard



More information about the Python-list mailing list