# HG changeset patch # User Richard M. Stallman # Date 791104651 0 # Node ID 39e925f8beaa7e06ca8f1cebd0622b18fd4aafa2 # Parent f5f5c52de2e46ea819f38b0db10c7d0498161cad (scroll-bar-drag-1): Set point-before-scroll properly. (scroll-bar-scroll-down, scroll-bar-scroll-up): Likewise. diff -r f5f5c52de2e4 -r 39e925f8beaa lisp/scroll-bar.el --- a/lisp/scroll-bar.el Thu Jan 26 03:18:45 1995 +0000 +++ b/lisp/scroll-bar.el Thu Jan 26 07:17:31 1995 +0000 @@ -133,17 +133,20 @@ If you click outside the slider, the window scrolls to bring the slider there." (interactive "e") (let* (done) + (or point-before-scroll + (setq point-before-scroll (point))) (scroll-bar-drag-1 event) - (track-mouse - (while (not done) - (setq event (read-event)) - (if (eq (car-safe event) 'mouse-movement) - (setq event (read-event))) - (cond ((eq (car-safe event) 'scroll-bar-movement) - (scroll-bar-drag-1 event)) - (t - ;; Exit when we get the drag event; ignore that event. - (setq done t))))))) + (let (point-before-scroll) + (track-mouse + (while (not done) + (setq event (read-event)) + (if (eq (car-safe event) 'mouse-movement) + (setq event (read-event))) + (cond ((eq (car-safe event) 'scroll-bar-movement) + (scroll-bar-drag-1 event)) + (t + ;; Exit when we get the drag event; ignore that event. + (setq done t)))))))) (defun scroll-bar-scroll-down (event) "Scroll the window's top line down to the location of the scroll bar click. @@ -155,9 +158,13 @@ (let* ((end-position (event-end event)) (window (nth 0 end-position)) (portion-whole (nth 2 end-position))) - (select-window window) - (scroll-down - (scroll-bar-scale portion-whole (1- (window-height)))))) + (let (point-before-scroll) + (select-window window)) + (or point-before-scroll + (setq point-before-scroll (point))) + (let (point-before-scroll) + (scroll-down + (scroll-bar-scale portion-whole (1- (window-height))))))) (select-window old-selected-window)))) (defun scroll-bar-scroll-up (event) @@ -170,9 +177,13 @@ (let* ((end-position (event-end event)) (window (nth 0 end-position)) (portion-whole (nth 2 end-position))) - (select-window window) - (scroll-up - (scroll-bar-scale portion-whole (1- (window-height)))))) + (let (point-before-scroll) + (select-window window)) + (or point-before-scroll + (setq point-before-scroll (point))) + (let (point-before-scroll) + (scroll-up + (scroll-bar-scale portion-whole (1- (window-height))))))) (select-window old-selected-window))))