From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#31240: 26.1; mouse-save-then-kill does not kill rectangles Date: Sat, 13 Oct 2018 10:18:49 +0200 Message-ID: <5BC1AA69.5010304@gmx.at> References: <5BB8EC23.1040303@gmx.at> <5BB9A4E5.3070308@gmx.at> <20181008.192544.1387561894315194511.tkk@misasa.okayama-u.ac.jp> <5BBC5C25.8080002@gmx.at> <5BBD9A08.3090707@gmx.at> <5BC05F09.40007@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1539418696 10719 195.159.176.226 (13 Oct 2018 08:18:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 13 Oct 2018 08:18:16 +0000 (UTC) Cc: 31240@debbugs.gnu.org, homeros.misasa@gmail.com, tkk@misasa.okayama-u.ac.jp, charles@aurox.ch To: Federico Tedin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 13 10:18:11 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBF7h-0002bh-0U for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Oct 2018 10:18:09 +0200 Original-Received: from localhost ([::1]:44145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBF9n-0005S4-9Y for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Oct 2018 04:20:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBF9b-0005Qo-DV for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2018 04:20:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBF9W-0000zi-ES for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2018 04:20:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBF9W-0000zW-9A for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2018 04:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gBF9V-0006of-SA for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2018 04:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Oct 2018 08:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31240 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31240-submit@debbugs.gnu.org id=B31240.153941875926147 (code B ref 31240); Sat, 13 Oct 2018 08:20:01 +0000 Original-Received: (at 31240) by debbugs.gnu.org; 13 Oct 2018 08:19:19 +0000 Original-Received: from localhost ([127.0.0.1]:47708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBF8p-0006nf-2H for submit@debbugs.gnu.org; Sat, 13 Oct 2018 04:19:19 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:41751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBF8m-0006nN-TW for 31240@debbugs.gnu.org; Sat, 13 Oct 2018 04:19:17 -0400 Original-Received: from [192.168.1.100] ([213.162.73.245]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MKYpv-1gCcZu06rP-001xla; Sat, 13 Oct 2018 10:18:53 +0200 Original-Received: from [192.168.1.100] ([213.162.73.245]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MKYpv-1gCcZu06rP-001xla; Sat, 13 Oct 2018 10:18:53 +0200 In-Reply-To: X-Provags-ID: V03:K1:Mypqmtqmj9cpvbUhhuLPupdqWqB+lquDOc7Wa9XLwRI0KMMu9e7 OUPb7t414sC5DgIU2vjtEB7TAYohLglRnhJ0sAF+oqisRtVG7Zf5sEBdxQsPVM0uMzsKvMv nr3tmv8utHX8wRkYfi4viKXtJcPJg6OaxoOBju3FQ/iol2ojsiZH7C+p7VxWWrI6z4y5Y2J N3Cg+r10Or9NLWXjLjMRw== X-UI-Out-Filterresults: notjunk:1;V01:K0:fBKXJxX28DY=:NYyl2BGRnVkJHeCYks1SvE nA+dHstLDTeoZyGbOOZFjVvd7UY2ikfd8E7yZoyiBn43bfGYqI/011yT0H2cnnANJ9heu4KLS 5PcxthEB1eRjTMM3gmFuaRtsWGLdsV+Hyj7/HJbvxr1miTjKtcgUZIzavYJg90Uhj1xDlfubU pdRsOUTp9cp2qDhzo3Q1hCRlpQuBaozc6q1s7mmtilkqbbykLwSvvtQegB2fGf5ycQlPzuHqi cWSEBmR9cjStqOqfYGdnwYCgQqnOQxvFdx5DkH2HlY01aUMP7aMH/AYJ401dkAMQzlzsYevnr KNbIfcIQkvKZZik++Vms5CO4V5Yy8xiq/exR2IvNhZmHpIiU6xdJFqAX6GgNA55qcbJT4BkaW tu0sTfhLTXC4mXmyg3xTCzZL1RDaDvk6ZgTMi8A/QP9mvh/9RqxpRfIII0cmsHhEWE9s0h9pZ zKTbRpu/ygQOf8cfhmWMygysvA1GxD9ZYx8ZaJMQUyA2Uy1Y/lfC/i00qEI+1/imKFz0rch8V 2ad9O4zFqLFp5k6uxQbfWESRX9o8cJSXKT0kTAcNmCkqLHV6udfEpm1Lufz/qBERph3yGiqe3 1RXeh8nQY+JcYfLnfJr8PTM8BaTLqEnCAwqUUrYNIxYbqHqC9tanAgfKH2ZaPuPQMsjuGY9jS ZnQK+kFYYuV/fBtS7fckr7zXFmNPY/YWG0BECSYYFQ/QjMlrMwJKKzlKxXrYi27ArpXnRX0Nm Euod1AH7K1nY6+FVQJeTGidg7lZ2v2LMA2Bi5xpYjUmijWkZrcLvcrMAzMZOS9s67Ji5sdVA 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:151198 Archived-At: > This is because after inserting the rectangle, the original rectangle > (which is to the left of the inserted one) is deleted. When it is > deleted, then the last 4 lines of the inserted rectangle are shifted > to the left: > > 1) Inserted new rectangle: > > ;;;;;;;;;;RECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECT;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; > > 2) Deleted the original one: > > ;;;;;;;;;;RECT;;;;;;;;; <--- this line isn't shifted > ;;;;;;RECT;;;;;;;;; > ;;;;;;RECT;;;;;;;;; > ;;;;;;RECT;;;;;;;;; > ;;;;;;RECT;;;;;;;;; > ;;;;;;;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; Thanks for the explanation. > I've thought up two ways of dealing with this problem: > > A) Forbid the user from dragging the rectangle to the right when the > new rectangle is *not* completly above or completly below the original > one. As an exception, allow the user to drag the rectangle purely to > the right (same line). In this option, the drag operation in your > example would not be permitted. I think this option would be a bit > confusing for users (and too restrictive). Agreed. > B) Add a variable mouse-drag-and-drop-rectangle-fill, initially set to > nil. When the variable's value is nil, the behaviour of dragging and > dropping rectangles is exactly the same as it is now. When it is set > to a non-nil value (for example, " "), then replace all characters of > the original rectangle with the variable's value. In this case, your > example would look like this: > > 1) M-: (setq mouse-drag-and-drop-rectangle-fill " ") > > 2) Inserted new rectangle: > > ;;;;;;;;;;RECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECTRECT;;;;;;;;; > ;;;;;;RECT;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; > > 3) Deleted the original one: > > ;;;;;;;;;;RECT;;;;;;;;; > ;;;;;; RECT;;;;;;;;; > ;;;;;; RECT;;;;;;;;; > ;;;;;; RECT;;;;;;;;; > ;;;;;; RECT;;;;;;;;; > ;;;;;; ;;;;;;;;; > ;;;;;;;;;;;;;;;;;;; > > I can't think of any other way of ensuring the inserted rectangle > retains its shape after being inserted, if there are pending delete > operations to its left. Let's keep B) in mind for the case that someone comes up with a real use case where this would be needed. Mine was just a constructed one that looked convincing to me to to be reported. The only remaining problem I have now is that we are far beyond the 80 columns limit for code. I came up with truncating the assignment to 'drag-but-negligible' as follows (setq drag-but-negligible (and (eq (overlay-buffer (car mouse-drag-and-drop-overlays)) buffer-to-paste) (if region-noncontiguous ;; If the region is rectangular, check if ;; the newly inserted rectangular text ;; would intersect the already selected ;; region. If it would, then set ;; "drag-but-negligible" to t. As a ;; special case, allow dragging the region ;; freely anywhere to the left, as this ;; will never trigger its contents to be ;; inserted into the overlays tracking it. (let ((size (cons region-width region-height)) (start-coordinates (rectangle-position-as-coordinates start)) (point-to-paste-coordinates (rectangle-position-as-coordinates point-to-paste))) (and (rectangle-intersect-p start-coordinates size point-to-paste-coordinates size) (not (<= (car point-to-paste-coordinates) (car start-coordinates))))) (and (<= (overlay-start (car mouse-drag-and-drop-overlays)) point-to-paste) (<= point-to-paste (overlay-end (car mouse-drag-and-drop-overlays)))))))) but that's ugly. If you have any ideas how to handle that better (for example, by moving the comment up by a few lines) I'll do that. Otherwise, I'll have to use that form above. Thanks, martin