Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 to trigger a 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.

share|improve this question

Try this:

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

For more information, read Translation Keymaps.

share|improve this answer
1  
When I do this and then try to use a cmd-click for flyspell it complains with the following error message: flyspell-correct-word must be bound to an event with parameters. Any suggestions? – Alex R Feb 18 '12 at 1:08
    
Weird, I saw the same error message. The following works for me though: (global-set-key [M-down-mouse-1] 'flyspell-correct-word) – edwardw Mar 27 '13 at 14:27

Trey's suggestion did not work for me but this did:

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

This maps control-left-click to middle-click (the down- piece didn't work for me).

Note to Alex R: C-... is control-, not command- (which is lowercase s-...)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .