Topics include: programming, Apple, Unix, gadgets, large-scale web sites and other nerdy stuff.

Emacs Notes for Summer 2008

2008-05-30 15:40:34

Every now and then, I re-evaluate and switch up the emacs version that I use. Often this is driven by a major OS upgrade, like Panther->Tiger or Tiger->Leopard. Sometimes it's just because it's been a while, or something that has been bugging me, and I've reached the breaking point. Or I want to avoid real work for an hour.

In the version of Carbon Emacs I used for Tiger (which I had built myself from GNU sources), I had some emacs lisp that would set the default font on startup. The built in default font was too big for my tastes, and it was consequently anti-aliased. I really don't like anti-aliased fonts in my editors and terminals.

For some reason, this lisp no longer worked in the Carbon Emacs I had to start using for Leopard. In fact the little dialog box that you could pop up a standard Mac font selector window didn't even work, so I couldn't change the font from the default Monaco 12-point anti-aliased font. I've been suffering this cruelty for over 6 months.

Today I tried a number of recipes for getting a newer emacs (I wanted to try 22.2), but they failed. I ended up using this hack:

First, download emacs 22.2 sources from GNU.

cd emacs-22.2 sudo cp -R mac/ /Applications/ sudo cp /usr/bin/emacs /Applications/

My old lisp still didn't work the way it used to, but part of it did:

(global-set-key "\C-x\C-t" 'mac-font-panel-mode)

This allows me to bring up the little Mac font selector window. Then some apropos work turned up "set-default-font." Mac fonts on Emacs have seriously inscrutable names. But if you interactive run M-x set-default-font and then hit ? when it asks which font, you get a nice listing of ALL the crazy Emacs-ized mac font names.

The font I wanted was:

(set-default-font "-apple-monaco-medium-r-normal--10-90-72-72-m-90-mac-roman")

That's Monaco 10 point. So I just stuff that in my emacs lisp initialization file along with:

(global-font-lock-mode 1) (set-frame-width (selected-frame) 90) (set-frame-height (selected-frame) 80) (set-frame-position (selected-frame) 1 6)

And my Emacs is ready to use when it starts up. Just like back in 1991 on my SPARCstation 2.