emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c4dab6c: Allow customizing precision scroll interpolation


From: Po Lu
Subject: master c4dab6c: Allow customizing precision scroll interpolation
Date: Wed, 8 Dec 2021 00:04:23 -0500 (EST)

branch: master
commit c4dab6c179a78ae17d02becf66a098bd72a12233
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 lisp/pixel-scroll.el | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index 2e09f9a..10736de 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]