473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Your favorite Python-related (X)Emacs thingamajiks?


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";

Jul 18 '05 #1
1 1308
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" <ed*********@majakari.net> wrote in message
news:87************@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!

$_ = '456476617264204d616a616b6172692c20612043687269737 469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc

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

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
IDE
by: Thomas Lindgaard | last post by:
Hello I am probably going to start a war now... but so be it :) I just want to hear what all you guys who eat pythons for breakfast use for python coding. Currently I use Kate, but I would...
81
by: julio | last post by:
Sorry but there is no another way, c# .net and mono are going to rip python, not because python is a bad lenguage, but because is to darn old and it refuses to innovate things, to fix wrong things,...
0
by: Greg Novak | last post by:
I realize that this is a pretty esoteric question, but I'm not even getting any traction on it by myself. I believe that the problem has to do with signal handling for programs run underneath...
1
by: Marcio Rosa da Silva | last post by:
Hi all, My first try on using RST to write an email. so I can (will) make mistakes :-) I am experiencing the problem shown in this thread_ of the `python-mode`_ discussion list hosted at...
29
by: seberino | last post by:
I'm trying to move beyond Emacs/Vim/Kate and was wondering if Eclipse is better and if it is the *best* IDE for Python. Should I leave Emacs and do Python coding in Eclipse? Chris
30
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for...
4
by: emin.shopper | last post by:
Emacs seems to freeze when doing certain shell commands on Microsoft Windows. The following is a simple example with Xemacs: ---------------------------------------------------------- ...
4
by: Richard Szopa | last post by:
Hi All, I am a devoted Emacs user and I write a lot in Python. However, I never managed to get my Emacs configuration right for this purpose. There were some discussions on this, but the threads...
7
by: Michele Simionato | last post by:
I have noticed that the python-mode for Emacs that comes with the latest Ubuntu is missing the class browser. Moreover if works differently from the python-mode I was used to (for instance CTRL-c-c...
0
by: xahlee | last post by:
Here's a little tutorial that lets you write emacs commands for processing the current text selection in emacs in your favorite lang. Elisp Wrapper For Perl Scripts...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.