changeset 10555:39e925f8beaa

(scroll-bar-drag-1): Set point-before-scroll properly. (scroll-bar-scroll-down, scroll-bar-scroll-up): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Thu, 26 Jan 1995 07:17:31 +0000
parents f5f5c52de2e4
children fda9e00240b0
files lisp/scroll-bar.el
diffstat 1 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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))))