From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#37700: 27.0.50; undo mouse-drag-and-drop-region ineffective Date: Mon, 28 Oct 2019 16:01:54 -0400 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="172744"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: tkk@misasa.okayama-u.ac.jp, 37700@debbugs.gnu.org, homeros.misasa@gmail.com To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 28 21:40:58 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 1iPBou-000ilw-7H for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Oct 2019 21:40:56 +0100 Original-Received: from localhost ([::1]:38678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPBos-0005A5-J9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Oct 2019 16:40:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47154) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPBEG-0002wo-9M for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 16:03:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPBEE-0005f5-Uv for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 16:03:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iPBEE-0005eZ-Qt for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 16:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iPBEE-0003OM-K4 for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 16:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Oct 2019 20:03: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.157229292512950 (code B ref 37700); Mon, 28 Oct 2019 20:03:02 +0000 Original-Received: (at 37700) by debbugs.gnu.org; 28 Oct 2019 20:02:05 +0000 Original-Received: from localhost ([127.0.0.1]:46396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPBDJ-0003Mo-1S for submit@debbugs.gnu.org; Mon, 28 Oct 2019 16:02:05 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53880) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iPBDH-0003MH-9h for 37700@debbugs.gnu.org; Mon, 28 Oct 2019 16:02:03 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B8DBD8126E; Mon, 28 Oct 2019 16:01:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5FA84806A2; Mon, 28 Oct 2019 16:01:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1572292916; bh=cXw9fPch80zzARCMrw+/7I45N8ODQe2fDzEnINiO91A=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CMylZ98yv2B9gAQ5rfXCAwUmZcMsItxT0VZUaAX8h6pMy25Z9KzMZbVgNNg9hvWvD iACO/IUgqZalpn4nqIb0tAhxbrTpyBhvnVztp6poarZ+sbgbbe58bomhNBrMItanoU uhw48oE9i9frlPQV9SzHGUFNl1oanEqeNXJHMoC05JbUXU4tvNZl0dw3X42Lr+tQ31 FelyVohW7EWCiq7t771u4X5hBlsea9QpEU6S8SHdwqrunVLXyyLXXFnqupL1wGpLok gan4I/WDvQlzgmU7x0JMmn+I+8EwvdUAr5TXgHyYNFZ9NPGpOknuqaUuL2nGGbUqQ8 oiGAvDr4HcV4A== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 14AFD12089A; Mon, 28 Oct 2019 16:01:56 -0400 (EDT) In-Reply-To: <37DDF48D-FC37-47A8-8CEC-C6EB66AB2BF7@acm.org> ("Mattias \=\?windows-1252\?Q\?Engdeg\=E5rd\=22's\?\= message of "Wed, 16 Oct 2019 17:27:05 +0200") 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:170328 Archived-At: > > On revision of writing, I often want to move a sentence around to fit > > into right place, without loosing the sentence from sight. Most of the > > time I cannot relocate the sentence to the best place by single > > drag-and-drop operation thus I want to maintain region active. > Thank you, very much my experience. Indeed, that's also my experience [ and as a result I stay away from text's drag-and-drop since I find C-w ... C-y to be easier since it avoids this trial-and-error problem ;-) ] > - (overlay-end overlay))))) > + (overlay-end overlay)))) > + ;; Since we will leave the destination text selected, > + ;; make sure an undo operation disregards the region > + ;; or the operation will only be partially undone. > + (when (consp buffer-undo-list) > + (push 'unconfined buffer-undo-list))) Rather than add a special new kind of entry you can use some version of (apply DELTA BEG END FUN-NAME . ARGS), presumably with DELTA=0 and BEG=END, so you don't need to modify the docstring of `buffer-undo-list` nor the implementation of primitive-undo. > @@ -2862,7 +2864,10 @@ undo-make-selective-list > ((null undo-elt) > ;; Don't put two nils together in the list > (when (car selective-list) > - (push nil selective-list))) > + (push nil selective-list)) > + (setq unconfined nil)) > + ((eq undo-elt 'unconfined) > + (setq unconfined t)) > ((and (consp undo-elt) (eq (car undo-elt) t)) > ;; This is a "was unmodified" element. Keep it > ;; if we have kept everything thus far. > @@ -2875,7 +2880,7 @@ undo-make-selective-list > (t > (let ((adjusted-undo-elt (undo-adjust-elt undo-elt > undo-deltas))) > - (if (undo-elt-in-region adjusted-undo-elt start end) > + (if (or (undo-elt-in-region adjusted-undo-elt start end) unconfined) > (progn > (setq end (+ end (cdr (undo-delta adjusted-undo-elt)))) > (push adjusted-undo-elt selective-list) As a user of undo-in-region, I think I'd be surprised if my undo started to modify parts of the buffer outside the region, so I think a better approach would be to only pay attention to the `unconfined' marker when it appears at the top of the `buffer-undo-list` (i.e. only if the drag-and-drop was the very last operation). Also I think it would deserve a message in the minibuffer explaining that the undo is not confined to the region. Stefan