diff options
| author | Kim F. Storm | 2006-09-15 21:04:39 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-09-15 21:04:39 +0000 |
| commit | ba646e8d2c3638db66bd6da33c52d17f91a9fc13 (patch) | |
| tree | 22cb85c3ef68dd48e5dc477eca0e6f134336e785 | |
| parent | b3a1034515cea88b83f569a744ae791b624cb747 (diff) | |
| download | emacs-ba646e8d2c3638db66bd6da33c52d17f91a9fc13.tar.gz emacs-ba646e8d2c3638db66bd6da33c52d17f91a9fc13.zip | |
(line-move-partial): Use window-line-visiblity to
quickly check whether last line is partially visible, and only do
the hard (and slow) part in that case.
| -rw-r--r-- | lisp/simple.el | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index ba80ebcb9d1..5c7cca5b31e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3487,43 +3487,49 @@ Outline mode sets this." | |||
| 3487 | (set-window-vscroll nil (- vs (frame-char-height)) t))) | 3487 | (set-window-vscroll nil (- vs (frame-char-height)) t))) |
| 3488 | 3488 | ||
| 3489 | ;; Move forward (down). | 3489 | ;; Move forward (down). |
| 3490 | (let* ((evis (or (pos-visible-in-window-p (window-end nil t) nil t) | 3490 | (let ((wvis (window-line-visibility))) |
| 3491 | (pos-visible-in-window-p (1- (window-end nil t)) nil t))) | 3491 | (when (or (null wvis) |
| 3492 | (rbot (nth 3 evis)) | 3492 | (and (consp wvis) |
| 3493 | (vpos (nth 5 evis)) | 3493 | (or (>= (car wvis) (frame-char-height)) |
| 3494 | ppos py vs) | 3494 | (>= (cdr wvis) (frame-char-height))))) |
| 3495 | (cond | 3495 | (let* ((wend (window-end nil t)) |
| 3496 | ;; Last window line should be visible - fail if not. | 3496 | (evis (or (pos-visible-in-window-p wend nil t) |
| 3497 | ((null evis) | 3497 | (pos-visible-in-window-p (1- wend) nil t))) |
| 3498 | nil) | 3498 | (rbot (nth 3 evis)) |
| 3499 | ;; If last line of window is fully visible, move forward. | 3499 | (vpos (nth 5 evis)) |
| 3500 | ((null rbot) | 3500 | ppos py vs) |
| 3501 | nil) | 3501 | (cond |
| 3502 | ;; If cursor is not in the bottom scroll margin, move forward. | 3502 | ;; Last window line should be visible - fail if not. |
| 3503 | ((< (setq ppos (posn-at-point) | 3503 | ((null evis) |
| 3504 | py (cdr (or (posn-actual-col-row ppos) | 3504 | nil) |
| 3505 | (posn-col-row ppos)))) | 3505 | ;; If last line of window is fully visible, move forward. |
| 3506 | (min (- (window-text-height) scroll-margin 1) (1- vpos))) | 3506 | ((null rbot) |
| 3507 | nil) | 3507 | nil) |
| 3508 | ;; When already vscrolled, we vscroll some more if we can, | 3508 | ;; If cursor is not in the bottom scroll margin, move forward. |
| 3509 | ;; or clear vscroll and move forward at end of tall image. | 3509 | ((< (setq ppos (posn-at-point) |
| 3510 | ((> (setq vs (window-vscroll nil t)) 0) | 3510 | py (cdr (or (posn-actual-col-row ppos) |
| 3511 | (when (> rbot 0) | 3511 | (posn-col-row ppos)))) |
| 3512 | (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t))) | 3512 | (min (- (window-text-height) scroll-margin 1) (1- vpos))) |
| 3513 | ;; If cursor just entered the bottom scroll margin, move forward, | 3513 | nil) |
| 3514 | ;; but also vscroll one line so redisplay wont recenter. | 3514 | ;; When already vscrolled, we vscroll some more if we can, |
| 3515 | ((= py (min (- (window-text-height) scroll-margin 1) | 3515 | ;; or clear vscroll and move forward at end of tall image. |
| 3516 | (1- vpos))) | 3516 | ((> (setq vs (window-vscroll nil t)) 0) |
| 3517 | (set-window-vscroll nil (frame-char-height) t) | 3517 | (when (> rbot 0) |
| 3518 | (line-move-1 arg noerror to-end) | 3518 | (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t))) |
| 3519 | t) | 3519 | ;; If cursor just entered the bottom scroll margin, move forward, |
| 3520 | ;; If there are lines above the last line, scroll-up one line. | 3520 | ;; but also vscroll one line so redisplay wont recenter. |
| 3521 | ((> vpos 0) | 3521 | ((= py (min (- (window-text-height) scroll-margin 1) |
| 3522 | (scroll-up 1) | 3522 | (1- vpos))) |
| 3523 | t) | 3523 | (set-window-vscroll nil (frame-char-height) t) |
| 3524 | ;; Finally, start vscroll. | 3524 | (line-move-1 arg noerror to-end) |
| 3525 | (t | 3525 | t) |
| 3526 | (set-window-vscroll nil (frame-char-height) t)))))) | 3526 | ;; If there are lines above the last line, scroll-up one line. |
| 3527 | ((> vpos 0) | ||
| 3528 | (scroll-up 1) | ||
| 3529 | t) | ||
| 3530 | ;; Finally, start vscroll. | ||
| 3531 | (t | ||
| 3532 | (set-window-vscroll nil (frame-char-height) t)))))))) | ||
| 3527 | 3533 | ||
| 3528 | 3534 | ||
| 3529 | ;; This is like line-move-1 except that it also performs | 3535 | ;; This is like line-move-1 except that it also performs |