Thinkpad TrackPoint Scrolling in Ubuntu Lucid/10.04

Update: for (easier) instructions for Ubuntu Maverick/10.10 and later, click here.

Another Ubuntu release, another set of X.org shakeups.

Some things in X changed in Lucid (xorg 1:7.5+5 and higher), breaking existing Thinkpad TrackPoint scrolling configurations that modify files in /etc/hal/fdi/policy (like those you may have seen in this previous post). You can use gpointing-device-settings to apply the same policy, but I found that even that stops working after a suspend/resume cycle.

Samson Yeung pointed out to me the following fix which can be applied on Ubuntu Lucid/10.04:

Create a new file /usr/lib/X11/xorg.conf.d/20-thinkpad.conf with the following contents (on Ubuntu Maverick/10.10 and later, save the file to /usr/share/X11/xorg.conf.d/20-thinkpad.conf instead):

Section "InputClass"
    Identifier "Trackpoint Wheel Emulation"
    MatchProduct "TrackPoint"
    MatchDevicePath "/dev/input/event*"
    Driver "evdev"
    Option "EmulateWheel" "true"
    Option "EmulateWheelButton" "2"
    Option "Emulate3Buttons" "false"
    Option "XAxisMapping" "6 7"
    Option "YAxisMapping" "4 5"
EndSection

Then restart X.

The configuration above works for both Thinkpad laptops with TrackPoints and the Thinkpad TrackPoint keyboard.

Source: instructions derived from these instructions by Samson Yeung. Thanks, Samson!

Resolving conflicts (in version control)

When Git (or another VCS) attempts to apply a patch that doesn't apply cleanly, it will defer to you, the user, to figure out the right thing to do. Usually you get, dumped in your lap, a file that has all these funny conflict markers in it, showing alternative versions of the content:

    <action name="Execute"><execute>google-chrome</execute></action>
  </keybind>
  <keybind key="W-s-b">
<<<<<<< HEAD
    <action name="Execute"><execute>firefox-3.6</execute></action>
=======
    <action name="Execute"><execute>firefox-3.7</execute></action>
>>>>>>> f50523b...
  </keybind>
  <keybind key="W-a">
    <action name="Execute"><execute>rhythmbox</execute></action>

You can edit that file by hand to get the state you want, but Emacs has a specialized mode for resolving conflicts. Type M‑x vc‑resolve‑conflicts and you get a three-paned frame like the following:

  • Press n and p to move between diff hunks.
  • For each hunk you can press a or b to transfer the version from the left or right side, respectively, to the output. You can leave the conflicted versions if there's something you really need to fix up by hand.
  • Press q when you're done. Emacs returns you to your fixed-up file. Save it.

Some Emacs macro tricks

Keyboard macros are the Emacs feature that I wish every program had. Especially web browsers: having to carry out repetitive tasks in web apps always feels to me like a throwback to a less civilized era.

(More information about keyboard macros, for the uninitiated: see #2.)

Here are some useful macro-related commands that I recently learned to use:

Extending a macro. If you record a macro, then realize you forgot to add an important step at the end, you don't have to re-record it. C-u F3 replays the last macro and then lets you tack on more commands to the end of it.

For example, C-u F3 RET F4 replays the last macro and then appends RET to the end of it. (You can also use C-u C-u F3 ... F4 to extend a macro without replaying it again first.)

Editing a macro. For more intensive fixes or changes to macros, you can edit your most recent macro with C-x C-k C-e (kmacro-edit-macro-repeat). You get a buffer like the following, and you can remove keystrokes or add new ones:

;; Keyboard Macro Editor.
;; Press C-c C-c to finish; press C-x k RET to cancel.
;; Original keys: ESC c ESC f ESC f ESC f C-d RET<

Command: last-kbd-macro
Key: none

Macro:

ESC c   ;; capitalize-word
ESC f   ;; forward-word
ESC f   ;; forward-word
ESC f   ;; forward-word
C-d   ;; delete-char
RET   ;; newline

Creating a macro from your keyboard history. If you just performed some task that you'd like to repeat, but didn't have the foresight to start recording a macro before you started, all is not lost. C-x C-k l (kmacro-edit-lossage) brings up a buffer (like the edit buffer above) containing your most recent 300 keystrokes, which you can pare down to create a new macro.

Bringing Gmail Muzzle out of retirement

I really liked the Gmail Labs "Muzzle" feature, which hides the status messages of contacts in the Gmail chat list. Unfortunately, Google retired this lab last week.

Happily, Yojimbow has replicated the functionality of Muzzle in a Greasemonkey script. (The script is only 8 lines long, with just 2 lines of Javascript! A very elegant solution.)

Firefox users can install Greasemonkey, and then install this user script; meanwhile, Google Chrome natively understands user scripts (making them look like extensions), and you can just click on links to them to install.

2009 in Review (belated)

Well, better late than never, I suppose.

Things in software/computing that were new for me last year:

  • I started writing Zeya, at first just to scratch an itch. I was surprised by the response to it.
  • My day job is now mostly writing Java. I'm more comfortable with more dynamic languages but there are quite a few things I like about Java. More about this later.
  • Switched to Google Chrome. It's blazing fast.
  • Started using Google Wave for a few things. It's still in a state of major flux and a lot of issues are still being ironed out, but I really like it. No other discussion tool I've ever used matches Wave in immediacy while scaling up to support readable and usable conversations that contain up to hundreds of contributors. In many scenarios I think having people on a Wave can make them more productive than if you could put them in a room together.

These were the most popular blog posts I wrote last year:

And these were the most visited blog posts that were written in previous years:

"Edit with Emacs" Chrome extension

Alex Bennée has written an Edit with Emacs extension for Google Chrome. It's Chrome's answer to Firefox's "It's all text" extension, which makes composing emails, blog posts, and other long-form text in a browser a lot more tolerable. (Hooray!)

Since Chrome extensions can't spawn arbitrary processes, the Edit with Emacs extension requires the cooperation of an additional edit server that can. The edit server is implemented in elisp and is bundled with the extension.

Installation instructions:

  1. Visit the extension gallery page and click "Install".
  2. In Chrome, click on the wrench menu, Extensions, "Options" under "Edit with Emacs", and follow the instructions there for setting up the edit server.
  3. After configuring the edit server, click "Test Edit Server" to make sure everything is working.
  4. Henceforth, in any new tabs you open, you'll see a little "edit" button next to any textarea elements, which you can click on to pop up a new editor frame. (You can also double-click on the textarea.)

Firefox 3.6

Mozilla released Firefox 3.6 last week. There are many noticeable improvements compared to Firefox 3.5, but two that stand out to me.

First, performance has improved quite a bit. And not just Javascript performance. Startup time is improved; the awesomebar responds instantly to keystrokes; Javascript and redraw/redisplay are faster. I no longer perceive a huge speed difference between Firefox and Google Chrome on most web apps, and the UI has become more responsive. (A few things—startup time, redraw/redisplay/scrolling, and creating/closing new windows and tabs—are still minorly annoying when I use Firefox alongside Chrome—but 3.5 and 3.6 are like night and day.)

Second, Firefox 3.6's implementation of HTML5 media, or at least audio, is superb. Having spent lots of time hacking on and listening to Zeya on Chrome, Firefox 3.5, and Firefox 3.6, the latter is the one where things most often just seem to work as spec'd. Moreover it's Firefox 3.6 (and only Firefox 3.6) that can consistently maintain the illusion that I'm using a native media player rather than a web-based one. That's colossal.

So, kudos to the Firefox developers.

PSA: the ubuntu-mozilla-daily PPA has nightly builds of Firefox 3.5, 3.6, and 3.7 packaged for all Ubuntu releases since Hardy. It's a low-hassle way to teach an old dog new tricks.