May 1, 2009 7:31 PM
Eclipse is good. But as a die hard Emacs fan, Emacs is the IDE for me. I needed a better way to quickly switch back and forth between Emacs and Eclipse. So I cooked up an Eclipse plugin that does exactly that. Click a button in the toolbar and the current active window in Eclipse will open in Emacs. It will also try to position the cursor at the same place it was in the Eclipse window. Also, you can configure the plug-in to execute any lisp code after doing this.

This plug-in uses gnuserve (available at Andy Norman's site and at meltin.net) and requires gnuclientw to be in the PATH variable. You can also point to the full path to gnuclientw in the plugin's preferences page.

Screenshots

Emacs Plugin for Eclipse Toolbar and Menu:

Emacs Plugin for Eclipse Toolbar and Menu

Preferences:

Emacs Plugin for Eclipse Preferences

Download

The plug-in and its sources (licensed under the LGPL) can be downloaded from:

Github repo for emacs-eclipse

This plugin has been tested with Eclipse ganymede and Emacs 22.1. Not sure if this will work in other versions of Eclipse. If you do manage to get it to work, drop in a comment and I'll update this article.

Note for Flex Builder Users

Strangely, when an Actionscript or MXML file is opened via the Flex Builder plug-in, getSelectionProvider().getSelection().getOffset() returns an offset which does not directly map the character position in Emacs. So this caused the cursor position in emacs to be more than the actual. Till this is worked out, in the case of MXML and AS files, the plugin will only move the cursor to the correct line and not the correct character offset in Emacs.

This issue does not affect the Java or any other perspective.

History

The only way to open a file in Emacs from Eclipse was to right click the file and say "Open In" another editor and pick gnuclientw. This closes the window in Eclipse and any time you open that file, it always opens in Emacs. Needless to say, this was very frustrating.

I had tried out the Emacs Plug-In for Eclipse by Alan Donovan and was disappointed when it did not work. As he had LGPLed his source, I used it to build this plugin.

CategoryEmacs Comment(s)

Copyright © 2004-2011 Anirudh Sasikumar. All rights reserved.
Last Updated: January 13, 2012 3:22 PM