From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective Date: Thu, 31 Oct 2019 12:00:08 +0100 Message-ID: <41286005-259E-4B78-A1FF-746E7A753FB4@acm.org> References: <3311689D-B1DF-4BAC-86BA-E3D2C6D2ECF1@acm.org> <94D2DE0C-8BD0-4CCF-B77D-5606A1D227DD@acm.org> <5be797bb-9d6b-cebe-edf4-21b4a5944595@gmx.at> <60b5bfa7-0aaf-40c0-3a1d-d0c0c5c662c6@gmx.at> <354ABF35-C5D0-4045-B9F0-5615A64408E6@acm.org> <83k199nasx.fsf@gnu.org> <83ftjxn94q.fsf@gnu.org> <37DDF48D-FC37-47A8-8CEC-C6EB66AB2BF7@acm.org> <9FE0E2D6-E4EA-4D7C-871C-3483AC53B295@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_E8D8FF12-557E-47AB-8541-070984B8223E" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="110837"; mail-complaints-to="usenet@blaine.gmane.org" Cc: tkk@misasa.okayama-u.ac.jp, 37700@debbugs.gnu.org, homeros.misasa@gmail.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 31 12:02:45 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iQ8E1-000SXh-3b for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Oct 2019 12:02:45 +0100 Original-Received: from localhost ([::1]:48482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ8Ds-0006EB-Vt for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Oct 2019 07:02:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ8CR-0004Ka-MT for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2019 07:01:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQ8CN-000350-KM for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2019 07:01:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43353) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQ8CM-00032c-Gu for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2019 07:01:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iQ8CM-0002j2-Bf for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2019 07:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2019 11:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37700 X-GNU-PR-Package: emacs Original-Received: via spool by 37700-submit@debbugs.gnu.org id=B37700.157251962010394 (code B ref 37700); Thu, 31 Oct 2019 11:01:02 +0000 Original-Received: (at 37700) by debbugs.gnu.org; 31 Oct 2019 11:00:20 +0000 Original-Received: from localhost ([127.0.0.1]:52174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQ8Bf-0002hZ-6X for submit@debbugs.gnu.org; Thu, 31 Oct 2019 07:00:20 -0400 Original-Received: from mail214c50.megamailservers.eu ([91.136.10.224]:35890 helo=mail193c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQ8Bb-0002hK-Sv for 37700@debbugs.gnu.org; Thu, 31 Oct 2019 07:00:17 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1572519613; bh=X91cLoZYqiYQ5bvb4u2dDwmwrf/2lgG2GCix6Db2cKU=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=UWGMWjItZsC8xoO5rUx8z7eFZfAKrUjZBwCgzrVWf5mn/YgTHk7CLtUt5DDtqBDuE 6USlI1OI8auOQ27BqsTaasDtJM32RIlEMO/C+3YX0tqQERGnHffr5SHXf6+wApj2zd iTYn6P5s3UFMr7GxeIIeLZlpRWdw3TTAEfclfxww= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x9VB09Fw003612; Thu, 31 Oct 2019 11:00:11 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0203.5DBABEBD.0022, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=E6OzWpVl c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=YmJ1QbaXYM7_DmfyeRkA:9 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=CjuIK1q_8ugA:10 a=3oNa4d-4bLNXx0iRRUUA:9 a=B2y7HmGcmWMA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 a=pHzHmUro8NiASowvMSCR:22 a=xoEH_sTeL_Rfw54TyV31:22 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: 209.51.188.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:170503 Archived-At: --Apple-Mail=_E8D8FF12-557E-47AB-8541-070984B8223E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 30 okt. 2019 kl. 20.56 skrev Stefan Monnier : >=20 >> Unfortunately, even with the patch, undoing a drag-and-drop does not = leave >> the region active the way it was before the undo, so the user has to >> reselect the text in order to try again. >=20 > If the undo-list is built right, reselecting the text should be just > `C-x C-x`, which isn't that bad. Right, second nature to the Emacs user, but it would still be nice not = having to go through that step. kill-region and delete-selection-mode = are similarly affected. > But now that I think about it, maybe a better option would be to check >=20 > (when (symbolp last-command) > (get last-command 'undo-inhibit-region)) >=20 > and then put the `undo-inhibit-region` property on > `mouse-drag-and-drop-region`. Thank you, this looks like the best idea so far. A very simple change, = yet effective in practice. Not perfect --- last-command is not = buffer-local, and even switching to a different frame and back will = change it --- but good enough. Patch attached. --Apple-Mail=_E8D8FF12-557E-47AB-8541-070984B8223E Content-Disposition: attachment; filename=0001-Inhibit-undo-in-region-for-mouse-drag-region-bug-377.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Inhibit-undo-in-region-for-mouse-drag-region-bug-377.patch" Content-Transfer-Encoding: quoted-printable =46rom=207cf5f680ab1d933fe1cecb862afa3b0976045f1d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Thu,=2031=20Oct=202019=2010:31:27=20+0100=0A= Subject:=20[PATCH]=20Inhibit=20undo-in-region=20for=20mouse-drag-region=20= (bug#37700)=0A=0A'mouse-drag-region'=20leaves=20the=20region=20active=20= around=20the=20dragged=20text,=0Aso=20a=20straight=20undo=20did=20not=20= revert=20the=20entire=20operation.=20=20To=20remedy=0Athis,=20inhibit=20= undo-in-region=20when=20the=20last=20command=20was=0Amouse-drag-region.=20= =20(Method=20suggested=20by=20Stefan=20Monnier.)=0A=0A*=20lisp/mouse.el=20= (undo-drag-region):=20Set=20the=20undo-inhibit-region=20property.=0A*=20= lisp/simple.el=20(undo):=20Inhibit=20undo-in-region=20if=20the=20last=20= command=0Ahad=20the=20undo-inhibit-region=20property=20set.=0A---=0A=20= lisp/mouse.el=20=20|=206=20++++++=0A=20lisp/simple.el=20|=207=20++++++-=0A= =202=20files=20changed,=2012=20insertions(+),=201=20deletion(-)=0A=0A= diff=20--git=20a/lisp/mouse.el=20b/lisp/mouse.el=0Aindex=20= 76fec507e7..4a351f7be2=20100644=0A---=20a/lisp/mouse.el=0A+++=20= b/lisp/mouse.el=0A@@=20-1104,6=20+1104,12=20@@=20mouse-drag-region=0A=20=20= =20=20=20(run-hooks=20'mouse-leave-buffer-hook)=0A=20=20=20=20=20= (mouse-drag-track=20start-event)))=0A=20=0A+;;=20Inhibit=20the=20= region-confinement=20when=20undoing=20mouse-drag-region=0A+;;=20= immediately=20after=20the=20command.=20=20Otherwise,=20the=20selection=20= left=0A+;;=20active=20around=20the=20dragged=20text=20would=20prevent=20= an=20undo=20of=20the=20whole=0A+;;=20operation.=0A+(put=20= 'mouse-drag-region=20'undo-inhibit-region=20t)=0A+=0A=20(defun=20= mouse-posn-property=20(pos=20property)=0A=20=20=20"Look=20for=20a=20= property=20at=20click=20position.=0A=20POS=20may=20be=20either=20a=20= buffer=20position=20or=20a=20click=20position=20like=0Adiff=20--git=20= a/lisp/simple.el=20b/lisp/simple.el=0Aindex=2029e195bca6..10aecd651f=20= 100644=0A---=20a/lisp/simple.el=0A+++=20b/lisp/simple.el=0A@@=20-2508,6=20= +2508,10=20@@=20undo=0A=20=09=20(base-buffer=20(or=20= (buffer-base-buffer)=20(current-buffer)))=0A=20=09=20(recent-save=20= (with-current-buffer=20base-buffer=0A=20=09=09=09(recent-auto-save-p)))=0A= +=20=20=20=20=20=20=20=20=20;;=20Allow=20certain=20commands=20to=20= inhibit=20an=20immediately=20following=0A+=20=20=20=20=20=20=20=20=20;;=20= undo-in-region.=0A+=20=20=20=20=20=20=20=20=20(inhibit-region=20(and=20= (symbolp=20last-command)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(get=20last-command=20= 'undo-inhibit-region)))=0A=20=09=20message)=0A=20=20=20=20=20;;=20If=20= we=20get=20an=20error=20in=20undo-start,=0A=20=20=20=20=20;;=20the=20= next=20command=20should=20not=20be=20a=20"consecutive=20undo".=0A@@=20= -2525,7=20+2529,8=20@@=20undo=0A=20=09=09=20=20=20=20=20=20=20;;=20it=20= shows=20nothing=20else=20happened=20in=20between.=0A=20=09=09=20=20=20=20= =20=20=20(gethash=20list=20undo-equiv-table))))=0A=20=20=20=20=20=20=20= (setq=20undo-in-region=0A-=09=20=20=20=20(or=20(region-active-p)=20(and=20= arg=20(not=20(numberp=20arg)))))=0A+=09=20=20=20=20(and=20(or=20= (region-active-p)=20(and=20arg=20(not=20(numberp=20arg))))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(not=20inhibit-region)))=0A=20=20=20= =20=20=20=20(if=20undo-in-region=0A=20=09=20=20(undo-start=20= (region-beginning)=20(region-end))=0A=20=09(undo-start))=0A--=20=0A= 2.21.0=20(Apple=20Git-122)=0A=0A= --Apple-Mail=_E8D8FF12-557E-47AB-8541-070984B8223E--