LinuxHappy's Weblog

Failures and Successes of Linux-based Development

Archive for September, 2009

emacs on MacOS (10.6) using Carbon Emacs

Posted by linuxhappy on September 19, 2009

Ok, I’ve recently bought a mac book pro. To say the least, I’m not super excited about it.. In my opinion, it’s got a lot of the nice things Linux has, but a lot of features that I haven’t figured out yet, or that the Mac just doesn’t have. Then again, my mac is sexy as hell and lasts about 7 hours on a plane, so I can’t complain.

Anyways, not having an emacs where I could quickly “M-x query-replace (Alt-x query replace)” really pissed me off.. Having to Ctrl-Escape-x was just a road block in my retarded little brain, and to make things worst, Apple (like Lenovo) switched the stupid control button with the fn key. One month later, I said to myself, okay. I spent 2000 bucks on this machine, i should be able to figure out how to get a decent emacs on this thing.. I found aquaemacs.. but it was a little bit different from Gnu emacs, and to be honest.. nice try, but I since I work on Linux all day, coming home to something slightly different was just a bit of a pain. So here it is.. I stumbled up on Carbon emacs.. beautifully (so far) the same as what I use on Ubuntu 9.04.. First.. I found a comment posted on this posting:

The comment suggested to use Carbon Emacs, and then went on to say to make a softlink to /Applications/ so you can quickly call emacs from a terminal.. Well. that didn’t work for me. Carbon Emacs, for some reason, didn’t like being called from an absolute path. E.g. The following command failed:


.. and softlinking

/usr/bin/emacs to /Application/

Also failed miserably.

So I created a script, to replace the original /usr/bin/emacs binary. So..
1. cd /usr/bin
2. sudo mv emacs emacs.old.leopard
3. Assuming you installed emacs into the Applications folder, copy and paste the script below into a file called “emacs”
4. sudo chmod 755 emacs
5. You should be able to use emacs from the MacOS terminal, just like on Linux 🙂

while [ $# -ne 0 ]; do
echo "$1" |grep "^/"
if [ $? -eq 0 ]; then
cd ${EMACSHOME} && ./Emacs ${ARGLIST}

I had to append the $PWD variable to files that did not have an absolute path (those files listed on the command line that don't start with /) to allow opening of files, since we are having to 'cd' into the /Applications/ folder



Posted in Uncategorized | 1 Comment »