Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

touchpad horizontal scrolling in 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?

like image 739
nwhsvc Avatar asked Jun 25 '09 06:06

nwhsvc


3 Answers

this slightly simpler version works for me:

(global-set-key [wheel-right] 'scroll-left)
(global-set-key [wheel-left] 'scroll-right)

or for osx reversed scroll directions:

(global-set-key [wheel-right] 'scroll-left)
(global-set-key [wheel-left] 'scroll-right)
like image 106
rgiar Avatar answered Sep 18 '22 04:09

rgiar


In version 26.2 I can set these variables from the mouse customize group:

'(mouse-wheel-flip-direction t) ;; correct left-right scroll direction for OS X
'(mouse-wheel-tilt-scroll t)    ;; enable left-right scroll from trackpad
like image 21
user12290680 Avatar answered Sep 22 '22 04:09

user12290680


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.

like image 34
bened Avatar answered Sep 20 '22 04:09

bened