Experiments in Emacs
One of the most difficult challenges facing me when beginning to work with both Erlang and Haskell, was the significant lack of good IDEs… Well, at least that was the theory, anyway. Instead it turned out to be a real motivator to finally get around to investigating the only IDE that counts.
The real problem wasn’t that I couldn’t use Emacs for basic editing, rather I didn’t really have any idea how to use any of the extra features. Essentially it was like working with a semi-decent TextEdit.app, with code highlighting and unfamiliar keyboard shortcuts. Even after reading some of Steve Yegge’s essays I still didn’t really have any idea what I was doing.
Ok, so basically I’m now writing this in Emacs’ SGML mode and carefully trying to get around the perverse limitations of Wordpress. (Where the heck did the allow raw HTML checkbox go for author text?) Ironically I don’t think I’ve yet gained the productivity advantages from my efforts yet, but honestly that can probably just be attributed to a slow down in my typing speed and the rather unexpected work schedule I’ve been (you never realize just how much you appreciate sleep until you don’t get enough).
If I haven’t gained any real productivity, the question becomes why then am I still using Emacs to write this post? Well, as it turns out its not actually too bad for even when you don’t know all of the keyboard commands (all commands come from the keyboard, and most important commands really never migrate to them menu or at least don’t indicate they’re keyboard equivelent).
Even more importantly perhaps is the gains that I’ve achieved in other tasks…writing blog posts in Emacs may not be any faster for me (although I do seem to see much more of the post at any one time)…but writing code sure is. I seriously doubt that I’d change from using things like XCode for Cocoa applications or DrScheme for PLT Scheme applications (although I may change my mind on Scheme), but at least I have direct access to the REPL in Haskell and Erlang.
The way most of the editing modes in Emacs actually work, it essentially will even load up a file your working directly into a REPL running side by side in another text buffer. From there you can test smaller parts of your program or even just run the whole thing from the top if you needed to. Anyone who’s worked with a Lisp dialect or even Python or Erlang (among others) should be able to apreciate that.
There are a couple of things that have been bugging me so far. The first is the lack of a spell checker. Emacs does have built-in support for ispell, but as you probably guessed, it doesn’t work on my machine (actually it isn’t even installed on my cygwin install). Too make matters worse, I still need to teach Emacs how to find my Cygwin install and use programs from it before the windows paths…ugh…
And the other thing doesn’t even have anything to do with Emacs, but rather, its a limitation with the Haskell code I’m working on. Essentially I don’t have a framework for OpenGL work that allows me to substitute the code on my side of the framework after the application has been started…or more to the point I can’t stop the application after it has started, forcing me to quit the entire REPL every time I test the Game.
Of course the simple workaround is to just keep restarting the REPL or move out of Emacs into a Cygwin shell, but its still very inconvenient (damn you GLUT).
All in all I can only really see how it goes, but at the very least it should make life just that little bit easier. At worst, I’ll just have to resort to my aging Mac Powerbook (for the BSD layer).
Until next time…
– Lorenz
October 20th, 2008 at 6:16
I’m not an emacs expert, but I may be able to help you with a couple of your emacs problems.
* Spell checking: I don’t think Cygwin has ispell, but it does have aspell which is supposedly a dropin replacement. Run Cygwin setup and make sure you’ve got aspell installed, then put this in your .emacs file:
;; substitute aspell for ispell
(setq-default ispell-program-name “c:/cygwin/bin/aspell.exe”)
* Put Cygwin apps into the Emacs search path: Put the following in your .emacs:
(when (file-exists-p “c:/cygwin/bin”)
;; Add cygwin directories to the emacs search path
(setq exec-path (cons “C:/cygwin/bin” exec-path))
(setq exec-path (cons “c:/cygwin/usr/local/bin” exec-path))
(setenv “PATH” (concat “c:\\cygwin\\bin;” (getenv “PATH”)))
(setenv “PATH” (concat “c:\\cygwin\\usr\\local\\bin;” (getenv “PATH”)))
Also, I’m sure by now you’ve figured out that you can set the HOME environment variable in Windows to change where Emacs looks for your .emacs file right? I’ve got mine set to look in c:\cygwin\home\bob. (obviously you’ll need to customize based on your cygwin username! )
There are some more Cygwin/Emacs customization advice on the Emacs Wiki: http://www.emacswiki.org/emacs/CygWin
October 21st, 2008 at 17:08
Hi Bob,
Yeah, I found some of that a little while back which definitely help a lot (before I switched to Linux as my primary OS…unrelated reasons), and the aspell thing is actually designed as a replacement for ispell on all platforms (Linux’s will quite often just symlink them).
The HOME trick is useful for working with the shell buffer as well, which doesn’t like spaces in the path (although cygwin itself doesn’t seem to care!?).
Either way, thanks for the input, hopefully it will help anyone reading this in the future.
– Lorenz