From fba17b0747ac8227c9e600b4398c3cc4295725e7 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 4 Dec 2021 14:01:59 +0800 Subject: [PATCH] Make precision pixel scrolling work in an hscrolled window * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down-page) (pixel-scroll-precision-scroll-up-page): Use beginning of visual line as window start if hscrolled. (pixel-scroll-precision): Don't delegate to mwheel-scroll if window is hscrolled. --- lisp/pixel-scroll.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 207d34811aa..ce2aee6c452 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -434,7 +434,13 @@ the height of the current window." delta) t) (unless (eq (window-start) desired-start) - (set-window-start nil desired-start t)) + (set-window-start nil (if (zerop (window-hscroll)) + desired-start + (save-excursion + (goto-char desired-start) + (beginning-of-visual-line) + (point))) + t)) (set-window-vscroll nil desired-vscroll t)))) (defun pixel-scroll-precision-scroll-down (delta) @@ -494,7 +500,13 @@ the height of the current window." (desired-start (posn-point desired-pos)) (desired-vscroll (cdr (posn-object-x-y desired-pos)))) (progn - (set-window-start nil desired-start t) + (set-window-start nil (if (zerop (window-hscroll)) + desired-start + (save-excursion + (goto-char desired-start) + (beginning-of-visual-line) + (point))) + t) (set-window-vscroll nil desired-vscroll t)) (set-window-vscroll nil (abs delta) t))))))) @@ -517,8 +529,7 @@ scroll the display according to the user's turning the mouse wheel." (interactive "e") (let ((window (mwheel-event-window event))) - (if (and (nth 4 event) - (zerop (window-hscroll window))) + (if (and (nth 4 event)) (let ((delta (round (cdr (nth 4 event))))) (unless (zerop delta) (if (> (abs delta) (window-text-height window t)) -- 2.39.2