views:

589

answers:

3

I've decided to get into IronPython, as I work pretty much exclusively in .NET, but need something a little less stuffy than C# for mocking up quick stuff. Python has been fine for small things, throwaway tests, that sort of stuff, but it's to the point that I need to be able to get to some of our .NET code.

Despite my complete revulsion, I've been using emacs for Python editing, and I'd like to use it for IronPython as well, assuming it's possible. Google has not been forthcoming with resources, so I thought I'd see if anybody around here knew of a way to get that working.

A: 

If you feel "complete revulsion" when using emacs to edit Python, switch to something less revolting. There are some suggestions on SO (e.g. best-gui-python-interpreter), and some will fit IronPython too.

I find SciTE a good fit for many lightweight programming tasks, including Python and IronPython.

gimel
I use SciTE for lots of things. The main reason I started using emacs was because I hate having to switch apps to test things, and all of the other Python IDEs I tried felt half-baked, or just downright didn't work.
Lee Crabtree
SciTE provides a simple shell for running scripts (Tools/Go [F5])...
gimel
A: 

I've used KomodoEdit with custom run action for IronPython, it doesn't really handle non-Python classed very well for auto complete though.

wegrata
+6  A: 

You can use IronPython as if it were a standard Jython interpreter in emacs.

This assumes that you are using EmacsW32 and that you have installed python-mode from launchpad. (Note that python-mode from launchpad IS DIFFERENT from the python mode that comes with emacsw32!)

Make sure you have IronPython installed, and you know its location on the filesystem.

Open up emacs, then open the file ~/.emacs and add a line of code that sets the variable py-jython-command to point to IronPython, as below. You'll want to change the value below

(setq py-jython-command "c:/Program Files/IronPython 2.0.1/ipy.exe")

Restart emacs to make sure that variable is set correctly.

Open a python file, hit control-c control-t to toggle to the Jython(IronPython) shell, then hit control-c ! to start up the shell.

At this point you can hit control-c control-c to execute the contents of the open file inside IronPython, or just play around inside IronPython.

The directions above assume that you can install python-mode, but if you don't know how to do that, I can add more instructions.

Also, I'd be happy to expand on any of this if it's unclear.

shapr
Excellent explanation. Thanks.
Lee Crabtree
Hi, Can you tell me how to do same thing when you have cygwin? I added this line but it still can not recognize and import "clr".I am using Python with Emacs on Cygwin, I configured Code completion and etc from "http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/"
Gollum
Sadly, I do not know how to handle CygWin, and I no longer have a Windows job.
shapr