Sunday, June 3, 2007

Finally Loving my Mac...

I spent much of yesterday working on my Mac, largely with the plan of addressing all the issues that bother me. Instead of actually trying to make progress on my primary task, I willingly accepted every diversion when I encountered an annoyance. That approach proved fruitful as I am now lots more comfortable working in front of OS X!

Here are some of the must-have things that, to my delight, I got working well:


I tried Carbon Emacs and Aquamacs, and prefer Carbon Emacs. It's GNU Emacs, and I generally have used XEmacs since the late '90s. In about 2000, I simplified my .emacs considerably in order to make it work well on Windows-based XEmacs distributions. Luckily, with those changes, it was just a twenty minute exercise to clean up the most urgent quirks.

Firefox 2.0

I use Firefox on GNU/Linux and on Windows, and had it installed on my Mac from day one, but was always frustrated by the keybinds of Home/End and Ctrl+Left/Right. For me, Home/End must go to the start/end of a line, Ctrl+Home/End must go to the start/end of document, and Ctrl+Left/Right must go backward/forward words. This is non-negotiable. This article describes some steps to address this problem by replacing the jar containing platformHTMLBindings.xml, but I found it easier to just edit that file directly using Emacs to open the jar file /Applications/ The required edits are pretty straightforward, and the new file is now a standard part of my CVS repository of my dot files. Note that I use DoubleCommand to fix those bindings for Carbon apps.

For Firefox, it's also critical that I have all the right extensions and GreaseMonkey scripts installed. Things like FEBE 5.0beta look like they might let me backup and restore my extension set, but I ended up just using InfoLister to create a nice HTML listing of my Firefox extensions on my various other boxes, and then focused on the right minimal set and installed them all. Here's part of the listing from my Windows and GNU/Linux boxes (which are now mostly the same as my Mac):
My greasemonkey scripts are also important to my general happiness. My two favourites are Advanced Google Keys (lets me use keys to navigate Google search results, similar to our experimental feature) and my own trivial Widen Google Results (optimize Google result snippets for bigger monitors). Those are a part of my CVS dots repository, too, so they were easy to add.


I'm fairly particular about the terminal program I use: key-bindings, supporting-escape sequences, control over what happens as I scroll back through the buffer, search functionally, and more, are all key to my productivity. My a priori goal was to make Mac's native Terminal application work for me. Right away, though, I noticed that it didn't have antialiased fonts. I don't know whether I turned them off in a misguided attempt to favour performance over eye candy, but I immediately went back into Window Settings -> Display and turned the setting back on. I also prefer a non-blinking blue block cursor, and lots of scrollback buffer (but don't jump to the bottom just because I start typing).

The default keyboard bindings in Terminal are very much biased towards rudimentary use. I generally want to be able to run even an 'emacs -nw' in a Terminal and have a reasonable set of modifiers available that send keystrokes to the application rather than being interpreted by the Terminal. In particular, Home/End, Ctrl+Left/Right, and PageUp/PageDown were set to manipulate the scrollback buffer, rather than send escape sequences for those keystrokes. Although I did the bindings on my own based on my .Xresources-cpp file that I've evolved over the years for xterm, this article has a reasonable couple of suggestions. I also recommend Edward Moy's definitive reference to xterm escape sequences.

The last of my Terminal tweaks was to change my shell to Zsh; I chose to do this just for interactive shells started by Terminal rather than changing my login shell -- that conservatism is mostly a holdover from bad experiences with very minor but subtle incompatibilities between bash and earlier versions of Zshell.


My Mac has $ZSH_VERSION = 4.2.3, and my only real issue in getting it going was that the Makefile I use to generate my .zshrc relied on one of my scripts that depends on nawk or GNU AWK. (I know what you're thinking: You use a Makefile to generate your .zshrc?!?! It actually makes a lot of sense to strip that down and do dead code elimination since shells parse it every time they startup... maybe a contemporary shell has a better solution like dumping itself after your base config is loaded, but I did this almost 15 years ago and it's worked great for me.)

Unfortunately, 10.4 seems to ship only with a pretty bare-bones AWK, and the base install of Fink (and even the FinkCommander view of the available packages) didn't show gawk. Moreover, I didn't want my basic Terminal+Zsh configuration to depend on binaries in /sw/bin. Thus, I simply re-wrote the one script in Perl. For the curious, the script in question is now called dedup-path and simply removes multiple occurrences of a path component in a path (after normalizing the components) and optionally removes path components that match a regular expression. There were a couple other little things I needed to tweak for some shell tools (e.g., export LESS='-i -X' to make less's search case-insensitive and have it not clear the screen when exiting), but generally my configuration was pretty comfortable right away.

BTW, after the fact, I did install Fink's gawk using sudo /sw/bin/apt-get install gawk.

Global Keybindings and Window Management

One of the hardest things for me to get right on the Mac relates to the various keybindings I use to get around on the desktop, manage windows, and so forth. I try very hard to avoid using the mouse for most things as it kills my train of thought (and hence my productivity) to have to move my fingers off the keyboard. As I mentioned in an earlier post, Window Dragon was a real lifesaver in letting me move and resize windows without having to aim at far-too-little and often-obscured controls on window decorations. I found several other preference-panel tools that also really help.

First, though, let me note that the "Universal Access" System Preference has lots of good stuff in it. After turning on "Enable access for assistive devices", I have Cmd+Option+= and Cmd+Option+_ do zoom in/out which helps lots when looking at smallish web page layout details or otherwise just working around ill-conceived UIs. I also turn Mouse Keys on so that I can control my pointer with the keyboard -- often that's faster than reaching up for my mouse.

I also edited various other global keybindings using the "Keyboard & Mouse" System Preference. Most important is turning on "Full keyboard access" at the bottom of the screen. But I also tweaked lots of the keys to avoid overlap with Emacs keystrokes that my fingers have had memorized for over a decade. The Microsoft IntelliType Pro keyboard I use came with a nifty configuration tool that also provides some nice capabilities, and see also my earlier mention of DoubleCommand.

I also found a couple of window/application switchers that I like better than the default Alt-Tab handling. I think I'm going to stick with Witch, but LightSwitch and WindowShade X both have some neat features that I may want to keep around. Coupled with QuickSilver for launching new applications (and a whole lot more, it seems, once I read through its capabilities [or maybe watch this QuickSilver video]), I'm pretty comfortable getting around my Mac.

Remaining Issues

My two biggest remaining issues:

1) I need more modifier keys -- Shift, Ctrl, Cmd, and Option are great, but on GNU/Linux I set up both Super and Hyper, too. This is important because there are often various layers of user interactions that might benefit from the same basic bindings, and modifier keys are the only recourse for disambiguating these. E.g., as I'm editing this Blog post inside Firefox, I might want Left to go cursor-left, Ctrl+Left to go left on word, Alt+Left to make Firefox go back to the prior page in the history, Cmd+Left to go to the Browser tab to the left of this one, Hyper+Left to change focus to the window to the left of the Firefox window, and Cmd+Option+Left to go to the left virtual console. I do use multiple-option keys for lots of keystrokes, but support for a bitmap of option keys is inconsistent at best, and avoiding conflict with all the various modifiers that different applications depend on is tricky (especially Emacs inside of a Terminal -- that goes through numerous different keyboard filtering/handling mechanisms before the application finally takes action on the escape sequences sent by the Terminal).

2) I really really want my menus inside the windows so that I can have focus-follows-mouse. I tried setting focus-follows-mouse for Terminal windows, but that's not enough. Moreover, I didn't like the focus getting held by Terminal windows when I used Alt+Tab (or LiteSwitch or Witch) to switch to another window (maybe one of them can warp the pointer... I've not looked for that yet). Real focus-follows-mouse mode seems incompatible with the circumspect design decision of the application menu being tied to the top of the screen. Fitts' law is irrelevant for me because I use keybindings to manipulate the menus. Ugh... but I've mentioned that before.

That's all for now... the outcome of these many hours of tweaking my Mac Mini is that I'm really, truly, finally loving the OS X experience!


yum said...

Hey Greg!
Nice posts - I have been a Mac convert for a few months and have griped about non-WindowMaker style moving & resizing. You should post more!

(a former CSE341 student)

Greg Badros said...

Reminder to self: I use Zooom/2, now, instead of Window Dragon. Better Touch Tool is pretty useful, too.