--- emacs-sar-xplat/lisp/mwheel.el 2009-10-10 03:49:47.000000000 +0100 +++ emacs/lisp/mwheel.el 2009-11-15 14:21:52.000000000 +0000 @@ -190,6 +190,14 @@ (buffer (window-buffer curwin)) (opoint (with-current-buffer buffer (when (eq (car-safe transient-mark-mode) 'only) + ;; temporarily "freeze off" an active region as string if + ;; necessary, to avoid confusingly propagating + ;; region to system if the point is moved by scrolling + ;; causing a deactivation below. + (and interprogram-region-function + (funcall interprogram-region-function + (buffer-substring-no-properties + (region-beginning) (region-end)) nil)) (point)))) (mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) @@ -228,10 +236,16 @@ (if curwin (select-window curwin))) ;; If there is a temporarily active region, deactivate it iff ;; scrolling moves point. + ;; Don't propagate deactivating region to system if scrolling moved point, + ;; however if scrolling did not move point, set active region back + ;; to buffer as we temporarily froze off string above. (when opoint (with-current-buffer buffer - (when (/= opoint (point)) - (deactivate-mark))))) + (if (/= opoint (point)) + (let ((interprogram-region-function nil)) + (deactivate-mark)) + (and interprogram-region-function + (funcall interprogram-region-function buffer nil)))))) (when (and mouse-wheel-click-event mouse-wheel-inhibit-click-time) (if mwheel-inhibit-click-event-timer (cancel-timer mwheel-inhibit-click-event-timer)