mac emacs

I’m glad that MacOSX is unix-based, but it still hides too much of the guts, making it harder than necessary to accomplish essential technical activities.  My first home computer was a (actually, one of the first off the assembly line, with the signatures of team inside of the case — I recall being a guest on “Computer Chronicles” showing off B&W capture w/ KoalaVision). But at work, and for any serious web , I’ve been using  (both SuSe and RedHat) as my platform of choice for maybe 5 years now, mostly as a foundation for XEmacs.  But with all the problems in interfacing with an increasing Micro$oft hegemony, we’ve reluctently decided to switch to at work too, especially since I should still have access to most of the same *nix tools, n’est pas?

Well, it turns out that XEmacs is hopelessly broken on the Mac (it builds alright, but soon crashes and is irretreivably corrupted evermore).  But then there’s Carbon Emacs which, while missing some of the cools XEmacs features like packages, graphics capability, and improved (I think) menu organization, seems to work pretty darned well, and quickly to boot.

Unfortunately, trying to replicate my old linux configuration was a real hassle.  First, my lovingly-crafted-over-a-decade custom.el file was almost completely incompatible with gnu syntax, so I had to basically roll a new one from scratch.  Missing are all the little tweaks that made life easier, but I expect they will be reimplemented soon.

But things really got hairy after I had installed XSlide.  Ittook several days to discover that applications on the Mac don’t inherit environment variables the way they do in normal *nix through my .profile. There’s a special file which holds parameters for the gui, somewhat like an xinit file (but not).

Case in point: I installed xt/xp/sax to do XSL transforms, and added the classpath variable to my profile.  Although I could perform batch transforms using the command line, using the XSLide tool in Emacs generated a java exception.  In fact, executing the exact same command from a terminal session and from eshell in Emacs, the latter would fail (and no, it wasn’t user perms).  Typing “printenv” revealed the problem: my CLASSPATH simply was not set in Emacs.

Information online (and very hidden it seems) suggests that applications need their environment variables set in ~/.MacOS/environment.plist.  To do this, you need to create the directory and then use /Developer/Applications/Utilities/Property_List_Editor to pupulate the XML file.  Unfortunately, this didn’t work either (it *may* work w/ normal programs, but not w/ Emacs).

After days of programmer hair-pulling, it turns out the fix was quite simple: simply declare the environment variables in .emacs (sometimes I think I purposely avoid the obvious), thusly:

(setenv “CLASSPATH” “/usr/local/xt/xt.jar:/usr/local/xt/sax.jar:/usr/local/xp.jar”)

Now that that’s working, let’s see if I can get my perl, ruby, and html modes to function.

FWIW, you can also use a command line trick to make all your unix and dot-files visible from the Finder (although they are always visible from dired): “defaults write com.apple.Finder AppleShowAllFiles YES” — use w/ care and only if/when you need it: it turns out that all those DS_store files show up too (one could use Dired-x and omit special files 😉 .   Of course, appending “NO” will revert to the default.

Leave a Reply