From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David De La Harpe Golden Newsgroups: gmane.emacs.devel Subject: select-active-regions mouse wheel scroll bug fix Date: Sun, 15 Nov 2009 14:23:08 +0000 Message-ID: <4B000ECC.5030405@harpegolden.net> References: <4AFF5E16.9080908@harpegolden.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020903050409050902020404" X-Trace: ger.gmane.org 1258295013 2502 80.91.229.12 (15 Nov 2009 14:23:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Nov 2009 14:23:33 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 15 15:23:26 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N9g0i-0006Qg-GH for ged-emacs-devel@m.gmane.org; Sun, 15 Nov 2009 15:23:24 +0100 Original-Received: from localhost ([127.0.0.1]:42878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N9g0h-0003p3-S4 for ged-emacs-devel@m.gmane.org; Sun, 15 Nov 2009 09:23:23 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N9g0c-0003oq-GL for emacs-devel@gnu.org; Sun, 15 Nov 2009 09:23:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N9g0X-0003mI-PM for emacs-devel@gnu.org; Sun, 15 Nov 2009 09:23:17 -0500 Original-Received: from [199.232.76.173] (port=52126 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N9g0X-0003mA-Im for emacs-devel@gnu.org; Sun, 15 Nov 2009 09:23:13 -0500 Original-Received: from harpegolden.net ([65.99.215.13]:33795) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N9g0W-0000Ti-0t for emacs-devel@gnu.org; Sun, 15 Nov 2009 09:23:13 -0500 Original-Received: from [87.198.54.207] (87-198-54-207.ptr.magnet.ie [87.198.54.207]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "David De La Harpe Golden", Issuer "David De La Harpe Golden Personal CA rev 3" (verified OK)) by harpegolden.net (Postfix) with ESMTP id E8BDD81CB for ; Sun, 15 Nov 2009 14:23:10 +0000 (GMT) User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) In-Reply-To: <4AFF5E16.9080908@harpegolden.net> X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117002 Archived-At: This is a multi-part message in MIME format. --------------020903050409050902020404 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This is dependent on preceding cross-platform clean-up patch (It could be recast not to depend I suppose, but that would then necessarily involve embedding similar X11isms in mwheel.el to the ones banished by the clean-up patch, and be messier looking - the extra abstraction provided by interprogram-region-function proves useful in the fix) Didn't spot this for ages as I don't mouse wheel normally (have a gfx tablet). Without this patch, when you have a 'only active region (i.e. shift-cursor or mouse generated) and select-active-regions enabled, when you wheel scroll enough to trigger the mark-deactivation path in mwheel-scroll, the system selection will end up set to a surprising region not corresponding to the last visibly active region, which is irritating, especially if you were scrolling somewhere precisely to insert somewhere else. --------------020903050409050902020404 Content-Type: text/x-patch; name="select-active-regions_fixwheel_r1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="select-active-regions_fixwheel_r1.diff" --- 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) --------------020903050409050902020404--