From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#55828: Add command to edit a rectangle arbitrarily in a separate buffer Date: Tue, 07 Jun 2022 21:24:30 +1200 Message-ID: <42925cc4927c79c1bf80ed4e3acf5581@webmail.orcon.net.nz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_73cb499baa95422a81fc547040b68254" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23139"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: Michael Heerdegen To: 55828@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 07 11:27:17 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyVUY-0005kz-G7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Jun 2022 11:27:14 +0200 Original-Received: from localhost ([::1]:43322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyVUW-0004CL-0M for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Jun 2022 05:27:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyVSQ-0004Af-Jr for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 05:25:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyVSQ-0003KY-0Q for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 05:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nyVSP-00066A-Tv for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 05:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Jun 2022 09:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55828 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165459388423409 (code B ref -1); Tue, 07 Jun 2022 09:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Jun 2022 09:24:44 +0000 Original-Received: from localhost ([127.0.0.1]:37662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyVS8-00065V-2X for submit@debbugs.gnu.org; Tue, 07 Jun 2022 05:24:44 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:50616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyVS6-00065O-Ia for submit@debbugs.gnu.org; Tue, 07 Jun 2022 05:24:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyVS5-000428-8h for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 05:24:42 -0400 Original-Received: from smtp-4.orcon.net.nz ([60.234.4.59]:52219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyVS2-0003Dh-N8 for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 05:24:40 -0400 Original-Received: from [10.253.37.70] (port=18128 helo=webmail.orcon.net.nz) by smtp-4.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1nyVRv-0000yq-0G; Tue, 07 Jun 2022 21:24:31 +1200 Original-Received: from ip-116-251-140-135.kinect.net.nz ([116.251.140.135]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Tue, 07 Jun 2022 21:24:30 +1200 X-Sender: psainty@orcon.net.nz X-GeoIP: -- Received-SPF: pass client-ip=60.234.4.59; envelope-from=psainty@orcon.net.nz; helo=smtp-4.orcon.net.nz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233843 Archived-At: --=_73cb499baa95422a81fc547040b68254 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed At https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55234#11 Michael Heerdegen wrote: > I implemented a command that lets me edit a rectangular region > in a separate buffer I've had one of those for years as well, and always intended to work on it some more and propose it as a standard feature. I bind it to "C-x r e", with "C-c C-c" to write the rectangle back to the original buffer after editing. There are a lot of special-purpose "do X to a rectangle" commands, but I think a command which lets you do *absolutely anything* to a rectangle is extremely useful, and a buffer with only that text gives you that ability pretty trivially. I think Emacs should have this in its standard rectangle toolkit; so here's a new feature request for that. For reference I've attached my version. It's old code which knows nothing of `rectangle-mark-mode' or other newer things, and it has the notable flaw of introducing trailing whitespace if the rectangular region had intersected any line endings (something I'd intended to address before suggesting this); but it's always done the job when I've needed it, so I'm attaching it as-is (aside from renaming it to `rectangle-edit' which seems to be an available name-space for such a feature). It sounds to me as if Michael's code does more than mine -- at minimum mine does not ask what to do with modified dimensions as described at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55234#17 (I just use the original dimensions), so I'd be interested to see that. -Phil --=_73cb499baa95422a81fc547040b68254 Content-Transfer-Encoding: base64 Content-Type: text/x-lisp; name=rectangle-edit.el Content-Disposition: attachment; filename=rectangle-edit.el; size=3536 KHJlcXVpcmUgJ3JlY3QpCgooZGVmaW5lLWRlcml2ZWQtbW9kZSByZWN0YW5nbGUtZWRpdC1tb2Rl IG5pbCAiUmVjdGFuZ2xlLUVkaXQiCiAgOzsgVGhlIHJlY3RhbmdsZSBidWZmZXIgY29udGVudHMg d2lsbCBsaWtlbHkgYmUgaW52YWxpZCBmb3IgdGhlCiAgOzsgbWFqb3IgbW9kZSBvZiB0aGUgc291 cmNlIGJ1ZmZlciwgc28gd2UgZGVyaXZlIGZyb20gZnVuZGFtZW50YWwtbW9kZQogIDs7IHRvIGF2 b2lkIHByb2JsZW1zLgogICJNYWpvciBtb2RlIGZvciAqZWRpdCByZWN0YW5nbGUqIGJ1ZmZlcnMu CgpcXHtyZWN0YW5nbGUtZWRpdC1tb2RlLW1hcH0iKQoKKGRlZmluZS1rZXkgcmVjdGFuZ2xlLWVk aXQtbW9kZS1tYXAgKGtiZCAiQy1jIEMtYyIpICdyZWN0YW5nbGUtZWRpdC1zdWJtaXQpCgooZGVm dmFyIHJlY3RhbmdsZS1lZGl0LWRhdGEpCgooZGVmdW4gcmVjdGFuZ2xlLWVkaXQgKHN0YXJ0IGVu ZCkKICAiRWRpdCB0aGUgcmVjdGFuZ2xlIGluIGEgdGVtcG9yYXJ5IGJ1ZmZlci4gQy1jIEMtYyBh cHBsaWVzIHRoZSBjaGFuZ2VzLiIKICAoaW50ZXJhY3RpdmUgIipyIikKICAobGV0KiAoKGNvbnRl bnQgKGV4dHJhY3QtcmVjdGFuZ2xlIHN0YXJ0IGVuZCkpCiAgICAgICAgICh3aWR0aCAobGVuZ3Ro IChjYXIgY29udGVudCkpKQogICAgICAgICAoaGVpZ2h0IChsZW5ndGggY29udGVudCkpCiAgICAg ICAgIChzb3VyY2UtYnVmZmVyIChjdXJyZW50LWJ1ZmZlcikpCiAgICAgICAgIChzb3VyY2Utc3lu dGF4IChzeW50YXgtdGFibGUpKQogICAgICAgICAoY29vcmRzLXBvaW50IChsaXN0IChsaW5lLW51 bWJlci1hdC1wb3MpIChjdXJyZW50LWNvbHVtbikpKQogICAgICAgICAoY29vcmRzLW1hcmsgKHNh dmUtZXhjdXJzaW9uCiAgICAgICAgICAgICAgICAgICAgICAgIChnb3RvLWNoYXIgKG1hcmspKQog ICAgICAgICAgICAgICAgICAgICAgICAobGlzdCAobGluZS1udW1iZXItYXQtcG9zKSAoY3VycmVu dC1jb2x1bW4pKSkpKQogICAgKHN3aXRjaC10by1idWZmZXIgKGdlbmVyYXRlLW5ldy1idWZmZXIg IiAqZWRpdCByZWN0YW5nbGUqIikpCiAgICAoaW5zZXJ0LXJlY3RhbmdsZSBjb250ZW50KQogICAg KHJlY3RhbmdsZS1lZGl0LW1vZGUpIDs7IG1vZGUgY2hhbmdlIGtpbGxzIGxvY2FsIHZhcmlhYmxl cy4KICAgIChzZXQtc3ludGF4LXRhYmxlIHNvdXJjZS1zeW50YXgpCiAgICAoc2V0cSBmaWxsLWNv bHVtbiB3aWR0aCkKICAgIChidWZmZXItZW5hYmxlLXVuZG8pCiAgICA7OyBTdG9yZSB0aGUgcmVj dGFuZ2xlIGRldGFpbHMgaW4gYSBidWZmZXItbG9jYWwgc3RydWN0dXJlLgogICAgKHNldCAobWFr ZS1sb2NhbC12YXJpYWJsZSAncmVjdG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