Rebinding <s-mouse-1> to <mouse-2> in Emacs on OS X

I use a macbook pro and thus am subjected to a trackpad with one button. I can, of course, do mouse-1 by clicking and mouse-3 by clicking with two fingers, but there isn't much I can do about a middle click (mouse-2).

I'm surprised this hasn't bit me before, but I only recently started being annoyed by the lack of a middle mouse button. In particular, I've started using ERC and flyspell, both of which have functions that require a middle click.

I've googled extensively but haven't been able to find a way to do this. Here is precisely what I'd like to do:

In Emacs, I'd like for Emacs to view command+mouse-1 as if it were mouse-2. Basically, I'd like a way to rebind <s-mouse-1> to trigger a <mouse-2> event. Is this possible?

If it is helpful at all, I'm using one of the Emacs 24 builds of Cocoa Emacs and I'm running Lion on a '08 era macbook pro.


Solution 1:

Try this:

(define-key key-translation-map (kbd "<C-down-mouse-1>") (kbd "<down-mouse-2>"))

For more information, read Translation Keymaps.