diff options
| author | Kim F. Storm | 2006-09-05 22:52:29 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-09-05 22:52:29 +0000 |
| commit | b704b1f01913d9319c15ce91ea988ffe211d2f03 (patch) | |
| tree | 065a7b529ed70a538e1b0bc672f09dfc7fc3b4ff | |
| parent | 902f06edb1a49047be86f1483eb5d03a766d8f4c (diff) | |
| download | emacs-b704b1f01913d9319c15ce91ea988ffe211d2f03.tar.gz emacs-b704b1f01913d9319c15ce91ea988ffe211d2f03.zip | |
(line-move-partial): New function to do vscrolling for
partially visible images / tall lines. Rewrite based on code
previously in line-move. Simplify backwards vscrolling.
(line-move): Use it. Simplify.
| -rw-r--r-- | lisp/simple.el | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index fbc110fbb29..8cade1f41b5 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3477,6 +3477,56 @@ Outline mode sets this." | |||
| 3477 | (or (memq prop buffer-invisibility-spec) | 3477 | (or (memq prop buffer-invisibility-spec) |
| 3478 | (assq prop buffer-invisibility-spec))))) | 3478 | (assq prop buffer-invisibility-spec))))) |
| 3479 | 3479 | ||
| 3480 | ;; Returns non-nil if partial move was done. | ||
| 3481 | (defun line-move-partial (arg noerror to-end) | ||
| 3482 | (if (< arg 0) | ||
| 3483 | ;; Move backward (up). | ||
| 3484 | ;; If already vscrolled, reduce vscroll | ||
| 3485 | (let ((vs (window-vscroll nil t))) | ||
| 3486 | (when (> vs (frame-char-height)) | ||
| 3487 | (set-window-vscroll nil (- vs (frame-char-height)) t))) | ||
| 3488 | |||
| 3489 | ;; Move forward (down). | ||
| 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)))))) | ||
| 3528 | |||
| 3529 | |||
| 3480 | ;; This is like line-move-1 except that it also performs | 3530 | ;; This is like line-move-1 except that it also performs |
| 3481 | ;; vertical scrolling of tall images if appropriate. | 3531 | ;; vertical scrolling of tall images if appropriate. |
| 3482 | ;; That is not really a clean thing to do, since it mixes | 3532 | ;; That is not really a clean thing to do, since it mixes |
| @@ -3484,37 +3534,14 @@ Outline mode sets this." | |||
| 3484 | ;; a cleaner solution to the problem of making C-n do something | 3534 | ;; a cleaner solution to the problem of making C-n do something |
| 3485 | ;; useful given a tall image. | 3535 | ;; useful given a tall image. |
| 3486 | (defun line-move (arg &optional noerror to-end try-vscroll) | 3536 | (defun line-move (arg &optional noerror to-end try-vscroll) |
| 3487 | (if (and auto-window-vscroll try-vscroll | 3537 | (unless (and auto-window-vscroll try-vscroll |
| 3488 | ;; But don't vscroll in a keyboard macro. | 3538 | ;; Only vscroll for single line moves |
| 3489 | (not defining-kbd-macro) | 3539 | (= (abs arg) 1) |
| 3490 | (not executing-kbd-macro)) | 3540 | ;; But don't vscroll in a keyboard macro. |
| 3491 | (let ((forward (> arg 0)) | 3541 | (not defining-kbd-macro) |
| 3492 | (part (nth 2 (pos-visible-in-window-p (point) nil t)))) | 3542 | (not executing-kbd-macro) |
| 3493 | (if (and (consp part) | 3543 | (line-move-partial arg noerror to-end)) |
| 3494 | (> (if forward (cdr part) (car part)) 0)) | 3544 | (set-window-vscroll nil 0 t) |
| 3495 | (set-window-vscroll nil | ||
| 3496 | (if forward | ||
| 3497 | (+ (window-vscroll nil t) | ||
| 3498 | (min (cdr part) | ||
| 3499 | (* (frame-char-height) arg))) | ||
| 3500 | (max 0 | ||
| 3501 | (- (window-vscroll nil t) | ||
| 3502 | (min (car part) | ||
| 3503 | (* (frame-char-height) (- arg)))))) | ||
| 3504 | t) | ||
| 3505 | (set-window-vscroll nil 0) | ||
| 3506 | (when (line-move-1 arg noerror to-end) | ||
| 3507 | (when (not forward) | ||
| 3508 | ;; Update display before calling pos-visible-in-window-p, | ||
| 3509 | ;; because it depends on window-start being up-to-date. | ||
| 3510 | (sit-for 0) | ||
| 3511 | ;; If the current line is partly hidden at the bottom, | ||
| 3512 | ;; scroll it partially up so as to unhide the bottom. | ||
| 3513 | (if (and (setq part (nth 2 (pos-visible-in-window-p | ||
| 3514 | (line-beginning-position) nil t))) | ||
| 3515 | (> (cdr part) 0)) | ||
| 3516 | (set-window-vscroll nil (cdr part) t))) | ||
| 3517 | t))) | ||
| 3518 | (line-move-1 arg noerror to-end))) | 3545 | (line-move-1 arg noerror to-end))) |
| 3519 | 3546 | ||
| 3520 | ;; This is the guts of next-line and previous-line. | 3547 | ;; This is the guts of next-line and previous-line. |