From a1701b60ea83f3ad8df3dbb4f2f917a6294f8f2e Mon Sep 17 00:00:00 2001 From: Daneel Date: Mon, 23 Feb 2026 14:11:16 +0100 Subject: [PATCH] fix(macos): enable pixel-scroll-precision-mode for smooth trackpad/mouse scrolling macOS NS/Cocoa Emacs generates pixel-level scroll events from trackpad and Magic Mouse. Without pixel-scroll-precision-mode, these events are handled as line-based scrolling, resulting in jerky or broken scroll behavior. Changes: - Enable pixel-scroll-precision-mode (Emacs 29+) in GUI mode - Set pixel-scroll-precision-large-scroll-height to 40.0 (prevents trackpad fling from being interpolated frame-by-frame) - Enable momentum scrolling (trackpad inertia from macOS) - Keep line-based mouse-wheel-scroll-amount as fallback for physical scroll wheels --- config.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/config.el b/config.el index 6f21ae1..85e96dc 100644 --- a/config.el +++ b/config.el @@ -178,10 +178,25 @@ Bound to cmd+v in org-mode and markdown-mode." [down-mouse-1] [down-mouse-2] [down-mouse-3])) (global-set-key key #'ignore)) (setq mouse-highlight nil) - ;; Smooth scroll wheel: 3 lines per tick, no acceleration + + ;; Scroll wheel — macOS NS/Cocoa generates pixel-level scroll events from + ;; trackpad and Magic Mouse. pixel-scroll-precision-mode (Emacs 29+) handles + ;; these natively for smooth, 1:1 scrolling. Line-based mouse-wheel-scroll-amount + ;; is kept as fallback for physical scroll wheels that send line events. (setq mouse-wheel-scroll-amount '(3 ((shift) . 1) ((control) . nil)) mouse-wheel-progressive-speed nil - mouse-wheel-follow-mouse t)) + mouse-wheel-follow-mouse t) + + ;; Enable pixel-precise scrolling (Emacs 29+) — essential for macOS trackpad/ + ;; Magic Mouse. Translates pixel deltas from NS scroll events into smooth + ;; pixel-level buffer scrolling instead of jerky line jumps. + (when (fboundp 'pixel-scroll-precision-mode) + (pixel-scroll-precision-mode 1) + ;; Large scroll threshold: pixel deltas above this trigger line-based scroll + ;; (prevents trackpad fling from being interpolated frame-by-frame). + (setq pixel-scroll-precision-large-scroll-height 40.0 + ;; Use momentum scrolling from macOS (trackpad inertia) + pixel-scroll-precision-use-momentum t)))