(defvar pixel-scroll-precision-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map [wheel-down] #'pixel-scroll-precision)
- (define-key map [wheel-up] #'pixel-scroll-precision)
- (define-key map [touch-end] #'pixel-scroll-start-momentum)
- (define-key map [mode-line wheel-down] #'pixel-scroll-precision)
- (define-key map [mode-line wheel-up] #'pixel-scroll-precision)
- (define-key map [mode-line touch-end] #'pixel-scroll-start-momentum)
- (define-key map [header-line wheel-down] #'pixel-scroll-precision)
- (define-key map [header-line wheel-up] #'pixel-scroll-precision)
- (define-key map [header-line touch-end] #'pixel-scroll-start-momentum)
- (define-key map [vertical-scroll-bar wheel-down] #'pixel-scroll-precision)
- (define-key map [vertical-scroll-bar wheel-up] #'pixel-scroll-precision)
- (define-key map [vertical-scroll-bar touch-end] #'pixel-scroll-start-momentum)
- (define-key map [left-margin wheel-down] #'pixel-scroll-precision)
- (define-key map [left-margin wheel-up] #'pixel-scroll-precision)
- (define-key map [left-margin touch-end] #'pixel-scroll-start-momentum)
- (define-key map [right-margin wheel-down] #'pixel-scroll-precision)
- (define-key map [right-margin wheel-up] #'pixel-scroll-precision)
- (define-key map [right-margin touch-end] #'pixel-scroll-start-momentum)
- (define-key map [left-fringe wheel-down] #'pixel-scroll-precision)
- (define-key map [left-fringe wheel-up] #'pixel-scroll-precision)
- (define-key map [left-fringe touch-end] #'pixel-scroll-start-momentum)
- (define-key map [right-fringe wheel-down] #'pixel-scroll-precision)
- (define-key map [right-fringe wheel-up] #'pixel-scroll-precision)
- (define-key map [right-fringe touch-end] #'pixel-scroll-start-momentum)
+ (define-key map [wheel-down] 'pixel-scroll-precision)
+ (define-key map [wheel-up] 'pixel-scroll-precision)
+ (define-key map [touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [mode-line wheel-down] 'pixel-scroll-precision)
+ (define-key map [mode-line wheel-up] 'pixel-scroll-precision)
+ (define-key map [mode-line touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [header-line wheel-down] 'pixel-scroll-precision)
+ (define-key map [header-line wheel-up] 'pixel-scroll-precision)
+ (define-key map [header-line touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [vertical-scroll-bar wheel-down] 'pixel-scroll-precision)
+ (define-key map [vertical-scroll-bar wheel-up] 'pixel-scroll-precision)
+ (define-key map [vertical-scroll-bar touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [left-margin wheel-down] 'pixel-scroll-precision)
+ (define-key map [left-margin wheel-up] 'pixel-scroll-precision)
+ (define-key map [left-margin touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [right-margin wheel-down] 'pixel-scroll-precision)
+ (define-key map [right-margin wheel-up] 'pixel-scroll-precision)
+ (define-key map [right-margin touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [left-fringe wheel-down] 'pixel-scroll-precision)
+ (define-key map [left-fringe wheel-up] 'pixel-scroll-precision)
+ (define-key map [left-fringe touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [right-fringe wheel-down] 'pixel-scroll-precision)
+ (define-key map [right-fringe wheel-up] 'pixel-scroll-precision)
+ (define-key map [right-fringe touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [next] 'pixel-scroll-interpolate-down)
+ (define-key map [prior] 'pixel-scroll-interpolate-up)
map)
"The key map used by `pixel-scroll-precision-mode'.")
:type 'float
:version "29.1")
+(defcustom pixel-scroll-precision-interpolate-page nil
+ "Whether or not to interpolate scrolling via the Page Down and Page Up keys.
+This is only effective when `pixel-scroll-precision-mode' is enabled."
+ :group 'scrolling
+ :type 'boolean
+ :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,
(aset state 0 (make-ring 10))
(aset state 1 nil))))))))
+(defun pixel-scroll-interpolate-down ()
+ "Interpolate a scroll downwards by one page."
+ (interactive)
+ (if pixel-scroll-precision-interpolate-page
+ (pixel-scroll-precision-interpolate (- (window-text-height nil t)))
+ (scroll-up)))
+
+(defun pixel-scroll-interpolate-up ()
+ "Interpolate a scroll upwards by one page."
+ (interactive)
+ (if pixel-scroll-precision-interpolate-page
+ (pixel-scroll-precision-interpolate (window-text-height nil t))
+ (scroll-down)))
+
;;;###autoload
(define-minor-mode pixel-scroll-precision-mode
"Toggle pixel scrolling.