]> code.delx.au - gnu-emacs/commitdiff
Fix mouse wheel scrolling in Follow mode.
authorChong Yidong <cyd@gnu.org>
Tue, 1 May 2012 14:00:16 +0000 (22:00 +0800)
committerChong Yidong <cyd@gnu.org>
Tue, 1 May 2012 14:00:16 +0000 (22:00 +0800)
* lisp/follow.el (follow-mwheel-scroll): New function.
(follow-redraw-after-event): Fix last change.

Fixes: debbugs:4112
lisp/ChangeLog
lisp/follow.el

index 31fda48df48a30654bfb5c28e8a58f449f21d89d..cb7e1377c92a1a89191fece65b2475018a93fbf7 100644 (file)
@@ -27,6 +27,7 @@
        (follow-scroll-bar-toolkit-scroll, follow-scroll-bar-drag)
        (follow-scroll-bar-scroll-up, follow-scroll-bar-scroll-down): New
        functions, replacing advice on scroll-bar-* commands.
+       (follow-mwheel-scroll): New function (Bug#4112).
 
        * comint.el (comint-adjust-point): New function.
        (comint-postoutput-scroll-to-bottom): Use it.  Call
index 53dd4c2c3540e8e13c285f1f163d06770f09016d..4c76b43da2df08b3af16191d43f35a555c39f080 100644 (file)
@@ -258,6 +258,7 @@ After that, changing the prefix key requires manipulating keymaps."
     (define-key mainmap [remap scroll-bar-drag] 'follow-scroll-bar-drag)
     (define-key mainmap [remap scroll-bar-scroll-up] 'follow-scroll-bar-scroll-up)
     (define-key mainmap [remap scroll-bar-scroll-down] 'follow-scroll-bar-scroll-down)
+    (define-key mainmap [remap mwheel-scroll] 'follow-mwheel-scroll)
 
     mainmap)
   "Minor mode keymap for Follow mode.")
@@ -1315,17 +1316,24 @@ non-first windows in Follow mode."
   (scroll-bar-scroll-down event)
   (follow-redraw-after-event event))
 
+(defun follow-mwheel-scroll (event)
+  (interactive "e")
+  (mwheel-scroll event)
+  (follow-redraw-after-event event))
+
 (defun follow-redraw-after-event (event)
-  "Re-align the Follow mode windows acted on by EVENT."
-  (let ((window (nth 0 (event-end event)))
-       (orig-win (selected-window)))
-    (when (and (buffer-local-value 'follow-mode (window-buffer window))
+  "Re-align the Follow mode windows affected by EVENT."
+  (let* ((window (nth 0 (event-end event)))
+        (buffer (window-buffer window))
+        (orig-win (selected-window)))
+    (when (and (buffer-local-value 'follow-mode buffer)
               ;; Ignore the case where we scroll the selected window;
               ;; that is handled by the post-command hook function.
               (not (eq window (selected-window))))
       (select-window window)
       (follow-redisplay)
-      (select-window orig-win))))
+      (unless (eq (window-buffer orig-win) buffer)
+       (select-window orig-win)))))
 
 ;;; Window size change