Emacs as a powerful Python IDE

May 09, 2008 at 03:27 PM | categories: python, enigma curry, emacs | View Comments

Update 01/2009: this post is still valid, but see updated installation instructions here.

Last night at the Python user group I gave a short demo on using Emacs as a Python editor/IDE. My macbook pro refused to display on the projector so I thought my demo was going to be a 'no go'. Thankfully, sontek allowed me to use his Linux laptop. I hurriedly copied over my emacs environment, installed a few packages and was able to present after all. I think the demo went fairly well even though I think it was a bit hurried and I forgot to cover a few things, I think I was pretty nervous at the same time because of the fact that the mac didn't work and got me flustered. Oh well, I think people enjoyed it.

My Emacs Environment

Below are the Emacs features most applicable to Python development:

  • Rope and Ropemacs Rope is a general (non-emacs specific) Python IDE library. It has awesome support for multiple refactoring methods and code introspection. Inside Emacs, this gives us:
    • Full (working!!) code-completion support of modules, classes, methods etc. (M-/ and M-?)
    • Instant documentation for element under the cursor (C-c d)
    • Jump to module/class/method definition of element under the cursor (C-c g). This works for any Python code it finds in your PYTHONPATH, including things from the stdlib.
    • Refactoring of code (like rename -- C-c r r)
    • List all occurences of of a name in your entire project
    • and More.
  • YASnippet YASnippet is a snippet tool like TextMate. You can expand user defined keywords into whole blocks of predefined code. This is especially useful for the usual boilerplate that would go into a python file like
    #!/usr/bin/env python
    and
    if __name__ == '__main__':

    Granted, Python doesn't require much boilerplate, and therefore this package is much more suited to languages like Java, but I bring it up because I think its cool and if you get into the habit of using it, then a few keystrokes saved here and there will add up over time.

  • Subversion support with psvn.el Psvn is a comprehensive subversion client for Emacs. It integrates well with ediff mode so you can use it to check changes between versions. It does all of the other boring subversion stuff well too.
  • Ido-mode for buffer switching and file opening. Emacs, to the uninitiated, can be confusing because by default there is only one view into a single file at a time. How does one get to another file? Instead of cluttering the interface with GUIness and making the user click somewhere (and thereby forcing the user to waste their time by moving their hand off of the keyboard), Emacs gives powerful ways to switch between files. Ido-mode is one of these useful ways -- it makes a list of open files starting with the most frequently visted files and widdles this list down as you type part of the filename. You can have dozens of files open and only be a few keystrokes away from any one of them.

A lot of people, for whatever reason, don't feel that Emacs is an IDE at all. I don't personally care what you define it as -- the fact remains -- Emacs is a powerful Python environment and despite being over 32 years old has proven to be just as modern as any IDE today, and remains THE most configurable editor (operating system?) ever.

I've tarred up my Emacs environment for general consumption. Instructions:

  • Install Pymacs
  • Install Rope and Ropemacs
  • BTW, those three packages should be the only packages other than Emacs you'll need. Everything else is self contained.
  • Extract the tarball to your home directory. This creates a directory called ryan-emacs-env.
  • Rename "ryan-emacs-env" to ".emacs.d"
  • Symlink my dot-emacs file to your .emacs. Run "ln -s .emacs.d/dot-emacs .emacs".
  • If you also want to do Java development run "tar xfvz jde-2.3.5.1.tar.gz". I leave it tarred because you don't need to pollute your environment if you're not going to use Java. (Also for whatever reason, jde doesn't like to be stuck in my subversion repository so I just leave it tarred up and untar on every machine I check it out on.)

Extra tips:

  • Put your .emacs.d directory under version control. Never rely on your distros emacs packages, install all future elisp files yourself in your .emacs.d file and commit to your repository often. This way you've got an environment that is easily transportable and synchronizable across multiple machines. This is the major reason why my emacs environment was so fast to trasnfer from my macbook pro to sontek's laptop during the demo.
  • Speaking of sontek, he brought up an excellent point in #utahpython the other day, he's not going to be using my emacs environment except for reference, instead he's starting with a clean slate. This is by far the best and most prudent thing to do. My emacs environment is a culmination of several years of plugging in and deleting various packages and writing various snippets of elisp. Your needs are always going to be different than mine and you are also going to be better off by educating yourself along the way by creating your own.

Some more fun Emacs evangelism:

Read and Post Comments

What Fantasy/Sci-Fi Character are you?

October 20, 2005 at 07:57 AM | categories: enigma curry, cool stuff | View Comments

Which Fantasy/SciFi Character Are You?

This is a fun little quiz to see what Fantasy or Sci-Fi character you are.

I answered truthfully and I turned out to be Spock... but I was also curious to see what happened if I changed my answers slightly. Did you know what the difference between Spock and Harry Potter is? I'll tell you. Harry Potter would gladly kill his best friend if it were to mean immortality for himself. Thank goodness that isn't something I'm apt to do.. something drastic indeed might have occured had I turned out Harry Potter.

Read and Post Comments

New Hosting and Star Trek

August 16, 2005 at 11:39 PM | categories: enigma curry | View Comments

Sorry, The website has been down for a few days for maintainance.

My Parents have been in the process of moving, and as such they have told me that I cannot host my site on the server at the (old) house now. I have moved my site now to Powweb ... I've already had some issues (adjustments to lifestyle really. They don't offer shell access here) ... We'll see how it goes. On the plus side, it's darn cheap.

I succesfully moved my TikiWiki site over to Powweb only to find that two weeks later it was broken. After numerous hours of attempting to fix it, I decided to bag the whole thing and switch toWordpress. It seems to be overall much more peppy than the TikiWiki code. I really like the Wiki side of TikiWiki, so I'll definitely be looking for something for my Wiki needs in the future, which may mean re-installing TikiWiki.

Kellie and I went down to Las Vegas last week and went to our first Star Trek Convention. I have mixed feelings about the experience. On the one hand, it was extremely cool to see so many familiar faces, people that I have admired and respected for most of my life. On the other hand, there were 2,000 other people there that made the experience so much less personal than I would have liked. I have a dream of someday meeting Bill Shatner. I don't want that meeting to be where I pay $80 for a photo-op and have 2 seconds with him. Great guy, wrong place.

Some of the highlights:
  • We heard the Las Vegas Philharmonic reproduce Star Trek Theme songs. It was extremely well done. James Darren (Vic Fontaine himself) sung as an intermission. It was a surprise appearnce (Nana Visitor was supposed to appear instead.) A once in a lifetime opportunity.
  • William Shatner. Need I say more?
  • Patrick Stewart uses regular bathrooms. I was waiting for Kellie outside of a public restroom at the Hilton, and out comes Patrick with his three body guards. Not three feet in front of me, he passed me by. Closest I've ever been to a Star Trek actor.
  • Kellie and I both dressed up as Trill for the symphony. The day after for the convention, we had run out of marker to make the spots, so only Kellie was Trill on that day. Very good costume, easy to do, and lots and lots of respect by passer-by Trek fans. Of course, not everyone asked the appropriate question: "How far down do they go?" ... all the way of course :)
  • Kellie recieved Spock's autograph... young spock that is... young Pon Far spock that is... Stephen Manley to be exact. The aquaintance went about like this:
    • Stephen Manley: Hey, those are excellent spots!
    • Kellie: Thanks! (Then she probably said "You have to ask the question though...")
    ... and we walked on...
    • Ryan: Do you know who you just spoke to?
    • Kellie: No...
    • Ryan: That was Spock.. young Spock..
    • Kellie: Oh cool! I have to get his autograph now!
We went up and got his autograph. I mentioned to him that he should personalize the autograph by saying "Nice Spots" or something of the like... here is what she got instead: "To Kellie: My Vulcan blood boils... Nice Spots!"

All in all, it was a very good experience, although I probably won't want to go back for several years.

Here are some photos of our Trek:



And finally, here is a picture I took of Mr Shatner. (Sorry for the quality, the seats were far away, and my camera doesn't zoom hardly at all)
William Shatner (Low Quality)

Read and Post Comments

Autocomp

August 05, 2005 at 09:03 PM | categories: car computer, enigma curry | View Comments

I've been spending the past month planning and building a car computer. A what you say? Yes, a PC in my car.

For all those wondering why I might want a computer in my car, here is a list of things I plan to be able to do with it:

  • Store all of my music on it. Be able to run out of gas far sooner then I run out of music.
  • Be able to play video games while waiting in the car for some reason. (About a week ago Kellie and I waited in the drive through at McDonalds for about 30 minutes.) ...
  • edit: ugg... my friend Gandhi just mentioned that yes... they now rent DVDs there too... *shudder*
  • Track my location and distance to destination with onboard GPS and appropriate software
  • Use an OBD-II interface to gather statistics from the engine's computer. (Speed, RPMs, Fuel Efficiency, engine warning messages etc)
  • Install a camera in the front of the car that will record on the computer. This will allow me to take time lapsed video of trips.
  • Wardriving
  • Just for pure curiosity: I wonder if loading a bunch of files onto the hard drive, driving across own to a friends house and offloading them to his computer via the wireless connection is faster then transferring them via DSL?

Here are the system specs:
  • Via Epia SP13000 mini-itx motherboard
  • 1GB DDR400 ram
  • 250GB Western Digital HDD
  • Opus 120W DC-DC power regulator (auto starts the computer when the car is turned on and shuts it off afterward also allowing for a specified delay after the car is shut off)
  • Ubuntu 'Hoary Hedgehog' Linux — hibernation works flawlessly
  • This screen: Image (I bought it before they raised the price mrgreen)

I completed the first major step on modifying my car this weekend. For Fourth of July weekend I went up to my parents house, where my Dad has lots of tools. He has lots of experience as a carpenter. We were able to quickly produce this:

Image


It is a fold down computer enclosure in the right hand side of my trunk. Much credit goes to bulgogi777 on the Mp3car.com forums for his trunk install. I belive that we have improved a bit on his design a bit (less destruction to the car) but without his initiative along with the power of the net to allowing people to collaborate in that manner,,, well I probably would have come up with something far less elegant.

More pictures of the install process are in my pictures gallery

Many thanks go to both of my parents for their assistance in this stage of the install. My Dad for his carpentry skills, and for my Mom who helped apply the fabric.

I'll post more as this project progresses.

  • Ryan
Read and Post Comments

Lately

July 01, 2005 at 10:43 PM | categories: enigma curry | View Comments

I haven't posted here recently. Work has been tasking, and I've been spending most of my free time reading the Mp3Car.com Forums. I have purchased parts to build a computer for my car (a carputer, or what I prefer to call an autocomp)

I'll be posting pictures of that soon.

Some other things that I have been raving about recently:

  • Raggle - a curses based RSS feed aggregator (plus check out the --server flag, it's a full blown HTTP server for your feeds as well)
  • This video - A stupid, yet still very entertaining little video of what might happen if you play a bit too much Counter Strike.
  • Memory Alpha - An awesome Star Trek wiki... I mean holy WOW.... Wiki's in general have got to be the coolest thing on the Web, but this site simply rocks!
I've had mixed feelings about the Grokster case recently. (If you don't know what I'm talking about... please see the bumper sticker I posted a few posts ago wink) The way I see it:
  • It really sucks that corporate power in this country has gotten to the point where if they brandish their clout and lobbying dollars enough they can get the centralized government to listen to any form of rhetoric imaginable.
  • It is also clear to me that once you break down the decision that the Supreme Court made, we are really no worse off then we were before: They have essentially upheld the Betamax decision .. as long as a technology is not primarily designed for piracy, then it ought to be legal. The fact that another case is now being held for Grokster to find out what their primary design was ... well... it's unimportant to me.
I plan to mount my computer in my car this weekend, so hopefully I'll have pics to show later next week.

  • Ryan
Read and Post Comments

Next Page »