Thursday, April 01, 2010

some windows-specific minor emacs-fu of particular interest to clojure programmers

The problem: since Cygwin 1.7, the use of Windows-style path names (e.g. C:\foo\bar rather than /cygdrive/c/foo/bar) has been deprecated. If you run a cygwin utility from within Emacs, it will do this now deprecated thing. The utility will still work, but will print a warning message on stderr.

This is particularly annoying if you're developing in Clojure, and are fond of using slime-edit-definition (usually bound to M-.). If the definition is inside a jar file, slime will use the unzip command under the covers to get at it. As unzip is not one of the random utilities that ship with the Emacs+W32 package, it quite nicely gets picked up out of my Cygwin install. But, this ends up inserting the warning message at the top of the resulting buffer.

Because of the extra lines, my cursor ends up (horror!) in the wrong place.

Possible solutions:

Get an unzip.exe without this problem.
Nice idea, but I'd have to maintain it myself; the unzip from cygwin gets updated whenever i update cygwin. Not that unzip is constantly getting updated, but still.
Make a wrapper shell script for unzip that runs the appropriate argument through cygpath
Simple, but this leaks outside of my emacs setup. Since the problem is coming from emacs, I'd like to fix it there.
defadvice
Now you're talkin'!

I put the following in my .emacs: