Using emacs-mac-port, and I'm trying to configure horizontal scrolling with the trackpad. The following expressions work if I execute them manually via eval-last-sexp,

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

but having added them to my init file seems to have no effect. I start up emacs, type a line long enough to be truncated, try to scroll sideways and I have no horizontal scroll. If I open up my init file (~/.emacs.d/init.el) and execute the relevant expressions manually, I DO get horizontal scrolling.

Some investigation shows that at initial startup, wheel-right and wheel-left are both bound to mac-mwheel-scroll, an interactive compiled Lisp function in Emacs.app/Contents/Resources/lisp/term/mac-win.el which "parses switches controlling interface with Mac window system".

Interestingly, the mac-mwheel-scroll definition includes a comment: TODO: horizontal scrolling

How can I give the settings in my init file a higher precedence than what's being set in mac-win.el? I'm guessing mac-win.el is being read later in startup process and thus overriding my settings, but I'm not really sure about that.

  • Try hitting C-h k before scrolling sideways. This will tell you which function is actually being called. – nanny Jun 24 '15 at 13:29
  • 2
    Not related to your problem, but there is no reason to quote a lambda form, and every reason not to quote a lambda form. – Drew Jun 24 '15 at 13:39
  • Interesting: it's calling mac-mwheel-scroll, in Emacs.app/Contents/Resources/lisp/term/mac-win.el. I'll update the question. – ivan Jun 24 '15 at 13:39
  • I found a copy of mac-win.el on the web, it looks like turning off mac-mouse-wheel-mode might help? – nanny Jun 24 '15 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.