views:

299

answers:

2

Hello: I use emacs.app on Mac OS X on a MacBook. Most applications on the computer allow me to scroll both vertically and horizontally with a two-finger drag on the trackpad. I would like to use this ability to position the cursor in emacs.

Adding the following lines to .emacs allows me to move the cursor vertically:

(global-set-key [wheel-up] 'previous-line)
(global-set-key [wheel-down] 'next-line)

I don't know of an equivalent setting for wheel-left or wheel-right. Can anyone help?

+3  A: 
(global-set-key (kbd "<mouse-7>")
  (lambda () (interactive) (message "WHEEEEEL")))

That worked for me. Try C-h c and then scroll the mouse the way you intend to to see what event is triggered. It will tell you in the echo area.

Deniz Dogan
This doesn't appear to work with the MagicTrackpad, C-h c also doesn't show anything for horizontal scrolling.
slomojo
+1  A: 

Put this in your .emacs-file:

;; Turn on horizontal scrolling with mouse wheel
(global-set-key (kbd "<mouse-6>") 'scroll-right)
(global-set-key (kbd "<mouse-7>") 'scroll-left)

When you first use it, emacs will ask you if you want to activate the restricted command scroll-left. That's just because some users find it confusing at first.

bened