From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#24030: 25.0.95; mouse-drag-region regression Date: Sun, 24 Jul 2016 17:12:16 +0300 Message-ID: <83zip7t9a7.fsf@gnu.org> References: <87y44x2s7v.fsf@gmail.com> <83wpkgz83a.fsf@gnu.org> <871t2mw6el.fsf@gmail.com> <83twfgv76y.fsf@gnu.org> <83d1m4utkc.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1469369607 25164 80.91.229.3 (24 Jul 2016 14:13:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Jul 2016 14:13:27 +0000 (UTC) Cc: 24030@debbugs.gnu.org, agrambot@gmail.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 24 16:13:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bRK9Z-0007XU-RC for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jul 2016 16:13:14 +0200 Original-Received: from localhost ([::1]:56183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRK9Y-0006FZ-Ns for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jul 2016 10:13:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRK9S-0006EB-MG for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 10:13:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRK9O-0006JJ-1u for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 10:13:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRK9N-0006JF-V0 for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 10:13:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bRK9N-0003mR-R4 for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2016 10:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jul 2016 14:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24030 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24030-submit@debbugs.gnu.org id=B24030.146936953814482 (code B ref 24030); Sun, 24 Jul 2016 14:13:01 +0000 Original-Received: (at 24030) by debbugs.gnu.org; 24 Jul 2016 14:12:18 +0000 Original-Received: from localhost ([127.0.0.1]:35931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRK8f-0003lW-K7 for submit@debbugs.gnu.org; Sun, 24 Jul 2016 10:12:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35901) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bRK8c-0003lI-RK for 24030@debbugs.gnu.org; Sun, 24 Jul 2016 10:12:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRK8T-0006EK-2x for 24030@debbugs.gnu.org; Sun, 24 Jul 2016 10:12:09 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRK8S-0006EG-W9; Sun, 24 Jul 2016 10:12:05 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3380 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bRK8S-0004Fu-5j; Sun, 24 Jul 2016 10:12:04 -0400 In-reply-to: (message from Stefan Monnier on Sat, 23 Jul 2016 17:16:37 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121481 Archived-At: > From: Stefan Monnier > Cc: agrambot@gmail.com, 24030@debbugs.gnu.org > Date: Sat, 23 Jul 2016 17:16:37 -0400 > > > that creates a buffer-local binding for it. That is why select-window > > gives deactivate-mark a non-nil value: select-window makes the > > window's buffer the current one, which assigns buffer-local values to > > all of it variables, including deactivate-mark. Then this > > buffer-local value is being examined by mouse-drag-region. > > Indeed, this is a problem here because of have a "stale" setting of > deactivate-mark. > > Maybe something like the patch below will do? It didn't solve the problem here. Did it work for you? > Another option is to make the deactivate-mark function reset > deactivate-mark to nil (which would seem to make a lot of sense in > itself) and then to call deactivate-mark at that point or to move the > earlier deactivate-mark to after mouse-set-point. Neither of these seems to solve the problem. What do you think about the alternative patch below? It does seem to solve the problem here. > Of course, maybe there should be a more thorough handling of stale > deactivate-mark settings. IOW change all places that set > deactivate-mark to non-nil so they also record the affected buffer and > then change the command loop so that it calls deactivate-mark in all > those buffers where deactivate-mark was set as non-nil. I envision complications with this when recursive-edit is used. > > How did it become stale, though? It was supposed to be reset by the > > command loop when the "C-h f" command returned. Why wasn't it? > > Because it wasn't the current-buffer when the command ended. But that means the whole handling of deactivate-mark is now quite fragile, isn't it? A command can change the current buffer any number of times, touching several buffers, and change back before it returns to the command loop, and Emacs will be none the wiser. Here's the proposed patch: --- lisp/mouse.el~ 2016-07-20 09:52:16.559875700 +0300 +++ lisp/mouse.el 2016-07-24 17:14:34.469052800 +0300 @@ -815,14 +815,16 @@ The region will be defined with mark and (setq mouse-selection-click-count-buffer (current-buffer)) (deactivate-mark) (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541). + (start-posn (event-start start-event)) + (start-point (posn-point start-posn)) + (start-window (posn-window start-posn)) + (_ (with-selected-window start-window + (setq deactivate-mark nil))) ;; We've recorded what we needed from the current buffer and ;; window, now let's jump to the place of the event, where things ;; are happening. (_ (mouse-set-point start-event)) (echo-keystrokes 0) - (start-posn (event-start start-event)) - (start-point (posn-point start-posn)) - (start-window (posn-window start-posn)) (bounds (window-edges start-window)) (make-cursor-line-fully-visible nil) (top (nth 1 bounds))