From 87233a14e07a61981e3ce51350efb8b7ee5adcd2 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Tue, 1 May 2012 22:00:16 +0800 Subject: [PATCH] Fix mouse wheel scrolling in Follow mode. * lisp/follow.el (follow-mwheel-scroll): New function. (follow-redraw-after-event): Fix last change. Fixes: debbugs:4112 --- lisp/ChangeLog | 1 + lisp/follow.el | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 31fda48df4..cb7e1377c9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 diff --git a/lisp/follow.el b/lisp/follow.el index 53dd4c2c35..4c76b43da2 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -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 -- 2.39.2