Emacs? VIM!

Peter Milliken peter.milliken at gtech.com
Wed Aug 8 23:54:47 CEST 2001

Since you are trolling for what Emacs can do for Python programming - what
about language sensitive editting (LSE) support? aka templates. Emacs has
several packages that ease the generation of writing code - writing code,
when you come right down to it look very similar to filling in a form, the
biggest difference is that eash line in a code file provides a selection of
a different "form" to fill in e.g. the following class structure and if
statement are both "forms" where the user fills in the variable names etc in
the "fields" delineated by {} or []'s - some of these are further menus that
allow selection of yet other "forms"

class {classname} [inheritance] :


   if {expression}:

Why force wear and tear on those fingers continually typing in character
sequences such as "if", "class", "def", ":" etc etc when you can get the
editor to do it for you? You can also achieve code "abbreviations" with
these same packages i.e.

  if<some-function-key> expands to:

     if {expression}:

navigation between the "placeholders" (strings enclosed by {}'s or []'s) are
simple commands. Once with these constructs then just start typing, the
Emacs packages deletes the placeholder text and replaces it with your
automatically i.e.if you typed "age == 10" when the cursor was within the
"{expression}" placeholder of the above if statement then Emacs would give
you this:

   if age == 10:

Emacs comes bundled with two such facilities - skeleton and tempo. A further
LSE is one that I have authored and upon which the above examples are based.
This one is called ELSE (Emacs Language Sensitive Editor :-)). All of these
packages are "independent" of the language being generated, all you have to
do is find a set of templates for *your* language. Of course, the various
packages are differ in their ease of use, many major mode maintainers use
skeleton.el (that way when a user downloads their major mode then they don't
have to bundle any other package). Skeleton and tempo are (in my opinion
:-)) harder to use because when you generate a construct they force you
through a question/asnwer session in the mini-buffer before they generate
the desired code - ELSE generates the code much more simply (as shown above)
and provides the advantages of "persistence" across edit session which the
others don't i.e. generate a code template with skeleton and you have to
fill it *all* in *now* wherease ELSE leaves the placeholder strings in the
buffer - you can "fill them in" any time you like :-).

ELSE comes with templates for Python. I am not aware of any templates for
Python using skeleton or tempo, although they are not terribly hard to

To give you a further flavour for ELSE and some Python templates, have a
look at http://members.nbci.com/pmilliken/ - Note that the Python templates
shown here are a very, very early version and don't conform to some of the
Python coding conventions. I am currently moving sites, so what you find
here is somewhat out of date. If anyone is interested in pursuing past this
point then just send an email and I will send the latest version of
else-mode.el and the Python templates.


"Adam 'Vonlia' Seyfarth" <adam.seyfarth at home.com> wrote in message
news:Pine.LNX.4.33.0108081041000.2138-100000 at cc489744-a...
> On Wed, 8 Aug 2001, Erik Max Francis wrote:
> > Adam 'Vonlia' Seyfarth wrote:
> >
> > >         You Emacs users, you've been boasting about "X/Emacs's Python
> > > mode".  First of all, you said you didn't like Vi because it was
> > > modal.
> > > Secondly, Vim has a Python environment.  Ie, with vim you can get
> > > syntax
> > > highlighting for Python, and automatic indenting for Python.  What
> > > more
> > > could you want?
> >
> > So use it if you like it.  No one's forcing you.
> Yes, I know, (I am) but I thought python.org could provide links to (or
> at least tell about) all (or "most") of the editors that have a Python
> environment.  This would benifet people, like me, who thought for a
> second that I would have to give up Vi for Emacs just to edit Python
> code, following the indenting standards (depressing).  Does anybody know
> of another editor that has Python stuff (or a file that enables Python
> stuff)?  I think I heard that Zeus does...
> (note:  I had another reason for sending the last one, I wanted to know
> what else Emacs in Python mode could do.)
> --
>      Whenever a computer is booted into Windoze - a penguin dies of a
>      broken heart.
>                -- Steve Baker
>     /||  Adam Seyfarth <http://members.home.net/adam.seyfarth/>  ||\
>    /«||  <mailto:cloud at users.sf.net>   <http://www.majik3d.org>  ||»\
>    \«||  <http://tuxaqfh.sf.net>        <http://tuxkart.sf.net>  ||»/
>     \||  <http://vim.sf.net>           <http://www.majik3d.org>  ||/

More information about the Python-list mailing list