7

With GNU Emacs 26.1 installing either smooth scroll while adding

(require 'smooth-scroll)
(smooth-scroll-mode t)

to my .emacs, or smooth scrolling with

(require 'smooth-scrolling)
(smooth-scrolling-mode 1)

does turn on the smooth scrolling mode just fine, but two-finger vertical swipes on the trackpad do not deliver the purported smooth scrolling.

Switching to Yamamoto Mitsuharu's Emacs is a bit too much for just this one nice feature. I'd rather stick to a package.

Did you manage to get either of these two packages to smooth scroll with 26.1 or a recent version of Emacs?

By "smooth scroll" here I mean that one would get the scrolling obtained with, say, Safari (with files whose length exceeds that of the window/frame).

Update

The discussions online

are inherently confused. Missing in the middle of the questions/conversations is a definition of "line" in the expression "smooth scrolling by line". One solution is to qualify that term by replacing it with either "character-line" or "pixel-line". The present question is about the latter.

Calaf
  • 483
  • 3
  • 16
  • An implementation in Lisp of what could/should be done in C, is not going to be the best approach. To the extent that Mitsuharu does something better in C, then that would probably be better than vanilla Emacs with a Lisp attempted fix. If you are partial to staying with the vanilla Emacs, try `(setq scroll-conservatively 101)` and set the mouse / trackpad wheel scroll (within Emacs) to just one line at a time and try that. Forget about the other settings in the interim until you have fully explored that option, then play with other settings to your heart's content. You can type `C-h v` .. – lawlist Oct 02 '18 at 04:46
  • @lawlist Understood. But using C before even seeing whether the Lisp-side speed is adequate is a bit of premature optimization. The more critical issue is to see that it's doable at all using an elisp package. What API is Apple exposing? If that API is suitable, perhaps a modern CPU that is otherwise sitting idle will allow an Emacs buffer to scroll nicely. – Calaf Oct 02 '18 at 11:22
  • 1
    When you say that it should be like Safari, do you mean pixel scrolling, where it scrolls by less than the height of a line of text at a time? That's enabled with `pixel-scroll-mode`, though I don't know off-hand what events it responds to. It doesn't pixel scroll for page up or page down, for instance. `smooth-scrolling-mode` does subtly change the page up/page down behavior though, so perhaps you just need to be more precise about describing what you want? – db48x Oct 02 '18 at 15:52
  • @db48x Pretty simple, really. Start Emacs with no init file. Load a large text file. Double-swipe vertically. The bufer scrolls by pixel increments, not by text line (character) increments. It's much more pleasant on the eye, especially if you're going back and forth scrolling a program (yes, I'm aware of 'follow-mode' and split vertically, use a large screen, write brief blocks, etc... still..). – Calaf Oct 03 '18 at 23:48
  • That's not what the `smooth-scrolling` package does. You want to turn on `pixel-scroll-mode` instead. – db48x Oct 04 '18 at 07:26
  • 1
    @db48x `pixel-scroll-mode` is what I was looking for. Please add it as an answer, possibly while also telling everyone what the smooth-scrolling mode does (now that I see what they mean there by "line", I'm puzzled that this requires a package, since it's easy to set the variables without an extra package). A comment to readers who drop in here about the usability of `pixel-scroll-mode`: it's not quite as nice as one would want. The distraction of the final slowdown to stop at a character-line boundary just about ruins it--almost nullifying any niceness of the smooth-scrolling. (cont.) – Calaf Oct 04 '18 at 10:42
  • (cont.) The issue then is not so much whether Apple exposes an API to scroll by pixel-line (from what I'm seeing, it looks like they already do), but whether Apple is exposing an API that makes it possible to clip a character-line at the border (or else to draw a subset of a character-line). TL;DR: it's nowhere near as pleasant as looking at code through a web browser. – Calaf Oct 04 '18 at 10:42

2 Answers2

8

M-x pixel-scroll-mode, available since Emacs 26, is all that's needed to have pixel scrolling. Credit to @db48x

Calaf
  • 483
  • 3
  • 16
  • 1
    how do you go about configuring it? i noticed it jumps – Tian Jul 02 '20 at 03:31
  • 3
    This mode is very buggy. https://github.com/seagle0128/doom-modeline/issues/199 https://github.com/syl20bnr/spacemacs/issues/11549 https://www.reddit.com/r/emacs/comments/8rml8f/emacs_26_pixelscrollmode_gcs_like_theres_no/ – HappyFace Aug 18 '20 at 13:12
  • I opened an upstream [bug report](https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-05/msg00999.html) for pixel-scroll-mode. – HappyFace May 12 '21 at 11:53
2

You may also try good-scrool.el, a library which offers pixel scrolling like pixel-scroll-mode, but supports dynamic scrolling speed.

student
  • 1,007
  • 9
  • 29