Commit 46f2aa14 authored by Chong Yidong's avatar Chong Yidong
Browse files

(recenter-top-bottom): Determine top and bottom positions using

scroll-margin instead of scroll-conservatively.
parent 0444738f
...@@ -1436,26 +1436,25 @@ top, middle, or bottom on successive calls. ...@@ -1436,26 +1436,25 @@ top, middle, or bottom on successive calls.
The cycling order is: middle -> top -> bottom. The cycling order is: middle -> top -> bottom.
Top and bottom destinations are actually `scroll-conservatively' lines Top and bottom destinations are actually `scroll-margin' lines
from true window top and bottom." the from true window top and bottom."
(interactive "P") (interactive "P")
(cond (cond
(arg (recenter arg)) ; Always respect ARG. (arg (recenter arg)) ; Always respect ARG.
((not (eq this-command last-command)) ((or (not (eq this-command last-command))
;; First time - save mode and recenter. (eq recenter-last-op 'bottom))
(setq recenter-last-op 'middle) (setq recenter-last-op 'middle)
(recenter)) (recenter))
(t ;; repeat: loop through various options. (t
(setq recenter-last-op (let ((this-scroll-margin
(cond ((eq recenter-last-op 'middle) (min (max 0 scroll-margin)
(recenter scroll-conservatively) (truncate (/ (window-body-height) 4.0)))))
'top) (cond ((eq recenter-last-op 'middle)
((eq recenter-last-op 'top) (setq recenter-last-op 'top)
(recenter (1- (- scroll-conservatively))) (recenter this-scroll-margin))
'bottom) ((eq recenter-last-op 'top)
((eq recenter-last-op 'bottom) (setq recenter-last-op 'bottom)
(recenter) (recenter (- -1 this-scroll-margin))))))))
'middle))))))
(define-key global-map [?\C-l] 'recenter-top-bottom) (define-key global-map [?\C-l] 'recenter-top-bottom)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment