I already use scroll-conservatively to smooth the vertical scrolling behaviour of Emacs. The horizontal scrolling is still pretty bad. The screen jumps by many columns, and I often lose track of where I am.

Is it possible to make this more smoothly?

  • Horizontal scrolling? You are not using visual-line-mode? – choroba Aug 15 '13 at 8:31
  • 1
    Oh no, I dislike that mode. :) – Arne Aug 15 '13 at 11:16

There appears no direct equivalent of scroll-conservatively for horizontal scrolling, but customizing hscroll-step (and perhaps also hscroll-margin) should produce something at least close to the same behavior. From the manual:

The variable hscroll-margin controls how close point can get to the window's left and right edges before automatic scrolling occurs. It is measured in columns. For example, if the value is 5, then moving point within 5 columns of an edge causes horizontal scrolling away from that edge.

The variable hscroll-step determines how many columns to scroll the window when point gets too close to the edge. Zero, the default value, means to center point horizontally within the window. A positive integer value specifies the number of columns to scroll by. A floating-point number specifies the fraction of the window's width to scroll by.

  • Works perfectly. – Arne Aug 21 '13 at 14:25
  • @Arne Excellent! Glad to hear it. – Aaron Miller Aug 21 '13 at 14:28

This is off-topic to scrolling with my trackpad, but who knows:

(global-set-key (kbd "<mouse-7>") '(lambda ()
                                     (scroll-left 4)))
(global-set-key (kbd "<mouse-6>") '(lambda ()
                                     (scroll-right 4)))

If you want to discover what Emacs thinks your horizontal scroll "button" is, try C-h k (describe-key) and then use your horizontal scroll. So in my current setup, Emacs reports <mouse-7> and <mouse-6>. I started with (scroll-left 1), but replaced with 4 to get faster scrolling.

  • Excellent, I couldn't get hscroll-step to take effect, but this works well - thank you. – davidA Dec 4 '19 at 1:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.