OSX Gestures for Emacs Scrolling

I’m now working in a Ruby on Rails team, which means I’m collaborating with a lot of TextMate users on a daily basis. I’ve been an Emacs user for years, and have never really seen the benefit of TextMate.

I do occasionally envy the silky interactions of GUI editors, in all their pointy clicky glory. Despite loving the speed of navigating with keystrokes, there are times when zipping around the editor is easier done with a mouse, and I love using my Apple Magic Trackpad and Lion gestures for doing this.

Recently, I’ve been feeling the Ctrl-V / Meta-V keystrokes for paging up and down have been a bit clumsy and imprecise. What I’ve wanted is the lovely two-finger scroll that I’ve become accustomed to on all my other Lion apps. Well I’ve found a lovely .emacs customisation that provides two finger scrolling for console Emacs interaction.

To enable this, add the following to your ~/.emacs file:

OSX Emacs mouse scrollStackoverflow source
1
2
3
4
5
6
7
8
9
10
11
12
13
;; Enable mouse support
(unless window-system
  (require 'mouse)
  (xterm-mouse-mode t)
  (global-set-key [mouse-4] '(lambda ()
                              (interactive)
                              (scroll-down 1)))
  (global-set-key [mouse-5] '(lambda ()
                              (interactive)
                              (scroll-up 1)))
  (defun track-mouse (e))
  (setq mouse-sel-mode t)
)

If your Emacs is ringing the terminal bell, or worse yet spraying Growl notifications, every time you scroll to the top or bottom of the buffer, you can disable this by adding the following to your ~/.emacs:

Stop that ringing Emacs bellOriginal source
1
2
;; disable bell function
(setq ring-bell-function 'ignore)

Copyright © 2016 - Branden Faulls. Powered by Octopress