From: Po Lu Date: Wed, 8 Dec 2021 05:02:16 +0000 (+0800) Subject: Allow customizing precision scroll interpolation X-Git-Tag: emacs-29.0.90~3609^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c4dab6c179a78ae17d02becf66a098bd72a12233;p=emacs.git Allow customizing precision scroll interpolation * lisp/pixel-scroll.el (pixel-scroll-precision-interpolation-total-time) (pixel-scroll-precision-interpolation-factor): New user options. (pixel-scroll-precision-interpolate): Use these new options. (pixel-scroll-precision-mode): Set `make-cursor-line-fully-visible' to nil. --- diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 2e09f9af2d4..10736de2ae4 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -141,6 +141,18 @@ Nil means to not interpolate such scrolls." number) :version "29.1") +(defcustom pixel-scroll-precision-interpolation-total-time 0.01 + "The total time in seconds to spend interpolating a large scroll." + :group 'mouse + :type 'float + :version 29.1) + +(defcustom pixel-scroll-precision-interpolation-factor 2.0 + "A factor to apply to the distance of an interpolated scroll." + :group 'mouse + :type 'float + :version 29.1) + (defun pixel-scroll-in-rush-p () "Return non-nil if next scroll should be non-smooth. When scrolling request is delivered soon after the previous one, @@ -531,7 +543,8 @@ This results in the window being scrolled by DELTA pixels with an animation." (while-no-input (let ((percentage 0) - (total-time 0.01) + (total-time pixel-scroll-precision-interpolation-total-time) + (factor pixel-scroll-precision-interpolation-factor) (time-elapsed 0.0) (between-scroll 0.001)) (while (< percentage 1) @@ -540,10 +553,10 @@ animation." percentage (/ time-elapsed total-time)) (if (< delta 0) (pixel-scroll-precision-scroll-down - (ceiling (abs (* delta + (ceiling (abs (* (* delta factor) (/ between-scroll total-time))))) (pixel-scroll-precision-scroll-up - (ceiling (* delta + (ceiling (* (* delta factor) (/ between-scroll total-time))))) (redisplay t))))) @@ -691,6 +704,8 @@ precisely, according to the turning of the mouse wheel." :group 'mouse :keymap pixel-scroll-precision-mode-map (setq mwheel-coalesce-scroll-events + (not pixel-scroll-precision-mode) + make-cursor-line-fully-visible (not pixel-scroll-precision-mode))) (provide 'pixel-scroll)