Emacs Scroll Fix For Macintosh

;; Macintosh scroll fix, adapted from suggestions by Tim Bray and David Reitter: see http://osdir.com/ml/emacs.macintosh.osx/2005-11/msg00047.html

(setq my-wheel-scroll-lines 5) ; or whatever you prefer

(defun safe-scroll-up () “Scroll up but don’t try at bottom” (interactive) (if (not (pos-visible-in-window-p (point-max))) (scroll-up my-wheel-scroll-lines))) (defun safe-scroll-down () “Scroll down but don’t try at top” (interactive) (if (not (pos-visible-in-window-p (point-min))) (scroll-down my-wheel-scroll-lines)))

(global-set-key [wheel-up] ’safe-scroll-down) (global-set-key [wheel-down] ’safe-scroll-up)