Emacs & OS X


One of my favorite things about Mac’s Terminal application is the ability to save window sets. With it, you can have a bunch of window instantly show up, all logged into the desired host, each in the exact location you want and in the exact size. Since they’re just files on disk, you can index them with Quicksilver, and then it’s just a few keystrokes to get a perfect, custom working environment up & running:



I’m all about reducing the friction in getting started on something, so I really like this.

My only gripe so far has been that default key mappings are a little off. When I hit the page-up key, most likely I don’t want the window to page up, I want emacs, less, or whatever is running in the shell to page up. You can do it, but it requires doing Shift-PgUp — one keystroke too many. Poking around, I found it lets you change your options (including your defaults), but it turns out that since key mappings are stored in window sets, it won’t have any effect on ones you’ve already created.

At last count, I have about 14 sets — too many to manually recreate. Cracking one open in an editor, I found they’re just simple XML. In that case, all it takes to fix them is a little Perl hackery:

     perl -i -p -e 's|scrollPageUp:|xxx|' *
     perl -i -p -e 's|33[5~|scrollPageUp:|' *
     perl -i -p -e 's|xxx|33[5~|' *
     perl -i -p -e 's|scrollPageDown:|xxx|' *
     perl -i -p -e 's|33[6~|scrollPageDown:|' *
     perl -i -p -e 's|xxx|33[6~|' *

This will reverse things around so PgUp/PgDn are passed on to the shell whereas Shift+PgUp/PgDn scrolls the window.

I’d suggest you tar up any directory beforehand, so you can recover should anything squirrelly happen. Note that you can’t just add .bak to the -i switch as the successive steps would clobber you original backups.

One Response to “Emacs & OS X”

  1. Christopher Smith Says:

    It gets better man. Since the only purpose of a MacTerminal session is to run Emacs, you can just save your emacs session directly. ;-)

Leave a Reply