summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2006-09-06 07:30:39 +0000
committerMiles Bader <miles@gnu.org>2006-09-06 07:30:39 +0000
commitfae22cbf7f66b7adc732e46a27b821114c812fdd (patch)
treea1c7545e4579d1da9d7d00d98287b1bff4dd0c26 /lisp/simple.el
parentaf6ea8ad8d62810d901561ae4a56d89f22ebacf0 (diff)
parent04e28558df772845d83d5e870300b755b2528b57 (diff)
downloademacs-fae22cbf7f66b7adc732e46a27b821114c812fdd.tar.gz
emacs-fae22cbf7f66b7adc732e46a27b821114c812fdd.tar.bz2
emacs-fae22cbf7f66b7adc732e46a27b821114c812fdd.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 423-426) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 131-133) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-109
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el89
1 files changed, 58 insertions, 31 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index e53cb1fb3e8..a9684ce85e6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3477,6 +3477,56 @@ Outline mode sets this."
(or (memq prop buffer-invisibility-spec)
(assq prop buffer-invisibility-spec)))))
+;; Returns non-nil if partial move was done.
+(defun line-move-partial (arg noerror to-end)
+ (if (< arg 0)
+ ;; Move backward (up).
+ ;; If already vscrolled, reduce vscroll
+ (let ((vs (window-vscroll nil t)))
+ (when (> vs (frame-char-height))
+ (set-window-vscroll nil (- vs (frame-char-height)) t)))
+
+ ;; Move forward (down).
+ (let* ((ppos (posn-at-point))
+ (py (cdr (or (posn-actual-col-row ppos)
+ (posn-col-row ppos))))
+ (vs (window-vscroll nil t))
+ (evis (or (pos-visible-in-window-p (window-end nil t) nil t)
+ (pos-visible-in-window-p (1- (window-end nil t)) nil t)))
+ (rbot (nth 3 evis))
+ (vpos (nth 5 evis)))
+ (cond
+ ;; (0) Last window line should be visible - fail if not.
+ ((null evis)
+ nil)
+ ;; If last line of window is fully visible, move forward.
+ ((null rbot)
+ nil)
+ ;; If cursor is not in the bottom scroll margin, move forward.
+ ((< py (min (- (window-text-height) scroll-margin 1)
+ (1- vpos)))
+ nil)
+ ;; When already vscrolled, we vscroll some more if we can,
+ ;; or clear vscroll and move forward at end of tall image.
+ ((> vs 0)
+ (when (> rbot 0)
+ (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t)))
+ ;; If cursor just entered the bottom scroll margin, move forward,
+ ;; but also vscroll one line so redisplay wont recenter.
+ ((= py (min (- (window-text-height) scroll-margin 1)
+ (1- vpos)))
+ (set-window-vscroll nil (frame-char-height) t)
+ (line-move-1 arg noerror to-end)
+ t)
+ ;; If there are lines above the last line, scroll-up one line.
+ ((> vpos 0)
+ (scroll-up 1)
+ t)
+ ;; Finally, start vscroll.
+ (t
+ (set-window-vscroll nil (frame-char-height) t))))))
+
+
;; This is like line-move-1 except that it also performs
;; vertical scrolling of tall images if appropriate.
;; That is not really a clean thing to do, since it mixes
@@ -3484,37 +3534,14 @@ Outline mode sets this."
;; a cleaner solution to the problem of making C-n do something
;; useful given a tall image.
(defun line-move (arg &optional noerror to-end try-vscroll)
- (if (and auto-window-vscroll try-vscroll
- ;; But don't vscroll in a keyboard macro.
- (not defining-kbd-macro)
- (not executing-kbd-macro))
- (let ((forward (> arg 0))
- (part (nth 2 (pos-visible-in-window-p (point) nil t))))
- (if (and (consp part)
- (> (if forward (cdr part) (car part)) 0))
- (set-window-vscroll nil
- (if forward
- (+ (window-vscroll nil t)
- (min (cdr part)
- (* (frame-char-height) arg)))
- (max 0
- (- (window-vscroll nil t)
- (min (car part)
- (* (frame-char-height) (- arg))))))
- t)
- (set-window-vscroll nil 0)
- (when (line-move-1 arg noerror to-end)
- (when (not forward)
- ;; Update display before calling pos-visible-in-window-p,
- ;; because it depends on window-start being up-to-date.
- (sit-for 0)
- ;; If the current line is partly hidden at the bottom,
- ;; scroll it partially up so as to unhide the bottom.
- (if (and (setq part (nth 2 (pos-visible-in-window-p
- (line-beginning-position) nil t)))
- (> (cdr part) 0))
- (set-window-vscroll nil (cdr part) t)))
- t)))
+ (unless (and auto-window-vscroll try-vscroll
+ ;; Only vscroll for single line moves
+ (= (abs arg) 1)
+ ;; But don't vscroll in a keyboard macro.
+ (not defining-kbd-macro)
+ (not executing-kbd-macro)
+ (line-move-partial arg noerror to-end))
+ (set-window-vscroll nil 0 t)
(line-move-1 arg noerror to-end)))
;; This is the guts of next-line and previous-line.