diff options
| author | Po Lu | 2021-12-02 09:15:43 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-02 09:15:43 +0800 |
| commit | 01a6c0b409c4d9ad92c4bb99bdb06c742bf3b0dd (patch) | |
| tree | 5579b89fe592085c335a55b3c718f19edec55c9f | |
| parent | 1914d946d62de4ab7bab1434bcea09087d61bb5a (diff) | |
| download | emacs-01a6c0b409c4d9ad92c4bb99bdb06c742bf3b0dd.tar.gz emacs-01a6c0b409c4d9ad92c4bb99bdb06c742bf3b0dd.zip | |
Get rid of vmotion loop in `pixel-scroll-precision-scroll-up'
* lisp/pixel-scroll.el (pixel-scroll-precision-scroll-up): Use
posn-at-x-y for cursor motion.
| -rw-r--r-- | lisp/pixel-scroll.el | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 59b5b71b923..9cd2352e199 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el | |||
| @@ -412,22 +412,25 @@ the height of the current window." | |||
| 412 | (let* ((edges (window-edges nil t nil t)) | 412 | (let* ((edges (window-edges nil t nil t)) |
| 413 | (max-y (- (nth 3 edges) | 413 | (max-y (- (nth 3 edges) |
| 414 | (nth 1 edges))) | 414 | (nth 1 edges))) |
| 415 | (usable-height max-y)) | 415 | (usable-height max-y) |
| 416 | (when-let* ((posn (posn-at-point)) | 416 | (posn (posn-at-x-y 0 (+ (window-tab-line-height) |
| 417 | (current-y (+ (cdr (posn-x-y posn)) | 417 | (window-header-line-height) |
| 418 | (line-pixel-height)))) | 418 | (- max-y delta)))) |
| 419 | (while (and (<= (- max-y current-y) delta) | 419 | (point (posn-point posn)) |
| 420 | (<= (cdr (posn-object-width-height posn)) | 420 | (up-point (save-excursion |
| 421 | usable-height)) | 421 | (goto-char point) |
| 422 | (vertical-motion -1) | 422 | (vertical-motion -1) |
| 423 | (setq current-y (- current-y (line-pixel-height)))) | 423 | (point)))) |
| 424 | (when (and (>= (cdr (posn-object-width-height posn)) | 424 | (when (> (point) up-point) |
| 425 | usable-height) | 425 | (when (let ((pos-visible (pos-visible-in-window-p up-point nil t))) |
| 426 | (let ((prev-line-height (save-excursion | 426 | (or (eq (length pos-visible) 2) |
| 427 | (vertical-motion -1) | 427 | (when-let* ((posn (posn-at-point up-point)) |
| 428 | (line-pixel-height)))) | 428 | (edges (window-edges nil t)) |
| 429 | (<= 0 (- (cdr (posn-x-y posn)) prev-line-height)))) | 429 | (usable-height (- (nth 3 edges) |
| 430 | (vertical-motion -1))) | 430 | (nth 1 edges)))) |
| 431 | (> (cdr (posn-object-width-height posn)) | ||
| 432 | usable-height)))) | ||
| 433 | (goto-char up-point))) | ||
| 431 | (let ((current-vscroll (window-vscroll nil t))) | 434 | (let ((current-vscroll (window-vscroll nil t))) |
| 432 | (if (<= delta current-vscroll) | 435 | (if (<= delta current-vscroll) |
| 433 | (set-window-vscroll nil (- current-vscroll delta) t) | 436 | (set-window-vscroll nil (- current-vscroll delta) t) |