| 3490 | | (let* ((ppos (posn-at-point)) |
|---|
| 3491 | | (py (cdr (or (posn-actual-col-row ppos) |
|---|
| 3492 | | (posn-col-row ppos)))) |
|---|
| 3493 | | (vs (window-vscroll nil t)) |
|---|
| 3494 | | (evis (or (pos-visible-in-window-p (window-end nil t) nil t) |
|---|
| 3495 | | (pos-visible-in-window-p (1- (window-end nil t)) nil t))) |
|---|
| 3496 | | (rbot (nth 3 evis)) |
|---|
| 3497 | | (vpos (nth 5 evis))) |
|---|
| 3498 | | (cond |
|---|
| 3499 | | ;; (0) Last window line should be visible - fail if not. |
|---|
| 3500 | | ((null evis) |
|---|
| 3501 | | nil) |
|---|
| 3502 | | ;; If last line of window is fully visible, move forward. |
|---|
| 3503 | | ((null rbot) |
|---|
| 3504 | | nil) |
|---|
| 3505 | | ;; If cursor is not in the bottom scroll margin, move forward. |
|---|
| 3506 | | ((< py (min (- (window-text-height) scroll-margin 1) |
|---|
| 3507 | | (1- vpos))) |
|---|
| 3508 | | nil) |
|---|
| 3509 | | ;; When already vscrolled, we vscroll some more if we can, |
|---|
| 3510 | | ;; or clear vscroll and move forward at end of tall image. |
|---|
| 3511 | | ((> vs 0) |
|---|
| 3512 | | (when (> rbot 0) |
|---|
| 3513 | | (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t))) |
|---|
| 3514 | | ;; If cursor just entered the bottom scroll margin, move forward, |
|---|
| 3515 | | ;; but also vscroll one line so redisplay wont recenter. |
|---|
| 3516 | | ((= py (min (- (window-text-height) scroll-margin 1) |
|---|
| 3517 | | (1- vpos))) |
|---|
| 3518 | | (set-window-vscroll nil (frame-char-height) t) |
|---|
| 3519 | | (line-move-1 arg noerror to-end) |
|---|
| 3520 | | t) |
|---|
| 3521 | | ;; If there are lines above the last line, scroll-up one line. |
|---|
| 3522 | | ((> vpos 0) |
|---|
| 3523 | | (scroll-up 1) |
|---|
| 3524 | | t) |
|---|
| 3525 | | ;; Finally, start vscroll. |
|---|
| 3526 | | (t |
|---|
| 3527 | | (set-window-vscroll nil (frame-char-height) t)))))) |
|---|
| | 3490 | (let* ((lh (window-line-height -1)) |
|---|
| | 3491 | (vpos (nth 1 lh)) |
|---|
| | 3492 | (ypos (nth 2 lh)) |
|---|
| | 3493 | (rbot (nth 3 lh)) |
|---|
| | 3494 | ppos py vs) |
|---|
| | 3495 | (when (or (null lh) |
|---|
| | 3496 | (>= rbot (frame-char-height)) |
|---|
| | 3497 | (<= ypos (- (frame-char-height)))) |
|---|
| | 3498 | (unless lh |
|---|
| | 3499 | (let* ((wend (window-end nil t)) |
|---|
| | 3500 | (evis (or (pos-visible-in-window-p wend nil t) |
|---|
| | 3501 | (pos-visible-in-window-p (1- wend) nil t)))) |
|---|
| | 3502 | (setq rbot (nth 3 evis) |
|---|
| | 3503 | vpos (nth 5 evis)))) |
|---|
| | 3504 | (cond |
|---|
| | 3505 | ;; If last line of window is fully visible, move forward. |
|---|
| | 3506 | ((or (null rbot) (= rbot 0)) |
|---|
| | 3507 | nil) |
|---|
| | 3508 | ;; If cursor is not in the bottom scroll margin, move forward. |
|---|
| | 3509 | ((and (> vpos 0) |
|---|
| | 3510 | (< (setq ppos (posn-at-point) |
|---|
| | 3511 | py (cdr (or (posn-actual-col-row ppos) |
|---|
| | 3512 | (posn-col-row ppos)))) |
|---|
| | 3513 | (min (- (window-text-height) scroll-margin 1) (1- vpos)))) |
|---|
| | 3514 | nil) |
|---|
| | 3515 | ;; When already vscrolled, we vscroll some more if we can, |
|---|
| | 3516 | ;; or clear vscroll and move forward at end of tall image. |
|---|
| | 3517 | ((> (setq vs (window-vscroll nil t)) 0) |
|---|
| | 3518 | (when (> rbot 0) |
|---|
| | 3519 | (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t))) |
|---|
| | 3520 | ;; If cursor just entered the bottom scroll margin, move forward, |
|---|
| | 3521 | ;; but also vscroll one line so redisplay wont recenter. |
|---|
| | 3522 | ((and (> vpos 0) |
|---|
| | 3523 | (= py (min (- (window-text-height) scroll-margin 1) |
|---|
| | 3524 | (1- vpos)))) |
|---|
| | 3525 | (set-window-vscroll nil (frame-char-height) t) |
|---|
| | 3526 | (line-move-1 arg noerror to-end) |
|---|
| | 3527 | t) |
|---|
| | 3528 | ;; If there are lines above the last line, scroll-up one line. |
|---|
| | 3529 | ((> vpos 0) |
|---|
| | 3530 | (scroll-up 1) |
|---|
| | 3531 | t) |
|---|
| | 3532 | ;; Finally, start vscroll. |
|---|
| | 3533 | (t |
|---|
| | 3534 | (set-window-vscroll nil (frame-char-height) t))))))) |
|---|