]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow customizing precision scroll interpolation
authorPo Lu <luangruo@yahoo.com>
Wed, 8 Dec 2021 05:02:16 +0000 (13:02 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 8 Dec 2021 05:02:16 +0000 (13:02 +0800)
* 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.

lisp/pixel-scroll.el

index 2e09f9af2d434288c04bec36412b28326d2638e4..10736de2ae4d2470f2a0737494576a4f864f14a0 100644 (file)
@@ -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)