aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-08-18 03:46:51 +0000
committerChong Yidong2008-08-18 03:46:51 +0000
commit46f2aa14ba58b5607a224e81693ba5610040eb99 (patch)
treed0f0e0c08c37effa4aaa842fed3163841e3cc413
parent0444738fa23791885958d10612f4381122d7e936 (diff)
downloademacs-46f2aa14ba58b5607a224e81693ba5610040eb99.tar.gz
emacs-46f2aa14ba58b5607a224e81693ba5610040eb99.zip
(recenter-top-bottom): Determine top and bottom positions using
scroll-margin instead of scroll-conservatively.
-rw-r--r--lisp/window.el29
1 files changed, 14 insertions, 15 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 5490f7bd293..2439c9f8c6b 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1436,26 +1436,25 @@ top, middle, or bottom on successive calls.
1436 1436
1437The cycling order is: middle -> top -> bottom. 1437The cycling order is: middle -> top -> bottom.
1438 1438
1439Top and bottom destinations are actually `scroll-conservatively' lines 1439Top and bottom destinations are actually `scroll-margin' lines
1440from true window top and bottom." 1440the from true window top and bottom."
1441 (interactive "P") 1441 (interactive "P")
1442 (cond 1442 (cond
1443 (arg (recenter arg)) ; Always respect ARG. 1443 (arg (recenter arg)) ; Always respect ARG.
1444 ((not (eq this-command last-command)) 1444 ((or (not (eq this-command last-command))
1445 ;; First time - save mode and recenter. 1445 (eq recenter-last-op 'bottom))
1446 (setq recenter-last-op 'middle) 1446 (setq recenter-last-op 'middle)
1447 (recenter)) 1447 (recenter))
1448 (t ;; repeat: loop through various options. 1448 (t
1449 (setq recenter-last-op 1449 (let ((this-scroll-margin
1450 (cond ((eq recenter-last-op 'middle) 1450 (min (max 0 scroll-margin)
1451 (recenter scroll-conservatively) 1451 (truncate (/ (window-body-height) 4.0)))))
1452 'top) 1452 (cond ((eq recenter-last-op 'middle)
1453 ((eq recenter-last-op 'top) 1453 (setq recenter-last-op 'top)
1454 (recenter (1- (- scroll-conservatively))) 1454 (recenter this-scroll-margin))
1455 'bottom) 1455 ((eq recenter-last-op 'top)
1456 ((eq recenter-last-op 'bottom) 1456 (setq recenter-last-op 'bottom)
1457 (recenter) 1457 (recenter (- -1 this-scroll-margin))))))))
1458 'middle))))))
1459 1458
1460(define-key global-map [?\C-l] 'recenter-top-bottom) 1459(define-key global-map [?\C-l] 'recenter-top-bottom)
1461 1460