Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Your favorite Python-related (X)Emacs thingamajiks?

Reply
Thread Tools

Your favorite Python-related (X)Emacs thingamajiks?

 
 
Edvard Majakari
Guest
Posts: n/a
 
      03-02-2004

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!

$_ = '456476617264204d616a616b6172692c20612043687269737 469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";

 
Reply With Quote
 
 
 
 
Peter Milliken
Guest
Posts: n/a
 
      03-02-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+> wrote in message
news:...
>
> 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!
>
> $_ = '456476617264204d616a616b6172692c20612043687269737 469616e20'; print
> join('',map{chr hex}(split/(\w{2})/)),uc

substr(crypt(60281449,'es'),2,4),"\n";
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Your Favorite Artist Silverstrand Media 34 02-08-2011 05:40 AM
Cast Your Vote For Your Favorite Movie right now. aasghar Digital Photography 0 06-16-2008 07:29 AM
Your favorite tutorial for caching viewstate? clintonG ASP .Net 8 01-11-2006 08:45 PM
Your Favorite RegEx Library? clintonG ASP .Net 1 10-08-2005 12:57 AM
Putting your Cell Phone Camera to good use - help fund your favorite charity David Blumenstein Digital Photography 2 08-04-2004 09:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57