Your favorite Python-related (X)Emacs thingamajiks?

Peter Milliken peterm at resmed.com.au
Tue Mar 2 16:45:09 EST 2004


If you're interested in code abbreviations (aka skeletons) then you might
want to look at ELSE - it has a (reasonably) complete set of definitions for
the entire Python language. It's well documented (40+ page users manual) and
you don't need any funny unreadable hieroglyphics to create a new construct
like you do with skeleton.el :-) e.g. the following is the definition of a
Python def statement in ELSE's template language:

DEFINE PLACEHOLDER FUNCDEF -
    /LANGUAGE="Python" -
    /NOAUTO_SUBSTITUTE -
    /DESCRIPTION=""
    /DUPLICATION=CONTEXT_DEPENDENT -
    /SEPARATOR="" -
    /TYPE=NONTERMINAL -

    "def {identifier} ([defparameter]...):"
    "  [document_string]"
    "  {statement}..."
    ""

END DEFINE

ELSE provides commands to navigate backwards and forwards between
placeholders (the text enclosed by {}'s and []'s - which are [obviously]
persistent BTW, you don't "lose" them between edit sessions or by expanding
a new abbreviation like you do with skeleton.el) and when you start typing
into one of them it gets deleted automatically and replaced by the
characters being typed.

It can be viewed and downloaded at http://www.zipworld.com.au/~peterm

Regards,
Peter


"Edvard Majakari" <edvard+news at majakari.net> wrote in message
news:87llmjn5mh.fsf at titan.staselog.com...
>
> I just thought to share mine:
>
> (define-skeleton esm-skel-python-def
>   "Inserts a new python function definition at point."
>   "method name: "
>   "def " str
>   "("
>   ("argument, %s: "
>    str & ", ") & -2 & "):" | -1 & "():"
>    \n
>    >"\"\"\"" ("comment: " str) ".\"\"\"" \n)
>
> (define-abbrev python-mode-abbrev-table "def" "" 'esm-skel-python-def)
>
> It's not very neat, but it does create a simple, consistent Python def
> whenever you type 'def ' and prompts for a name, list of arguments and
> comment for the method. Some day I'll try to make it more intelligent and
> automatically add 'self' as the first parameter, if I'm inside a class.
>
> --
> # Edvard Majakari Software Engineer
> # PGP PUBLIC KEY available    Soli Deo Gloria!
>
> $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
> join('',map{chr hex}(split/(\w{2})/)),uc
substr(crypt(60281449,'es'),2,4),"\n";
>





More information about the Python-list mailing list