From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: proposal: edit-rectangle Date: Thu, 06 Oct 2016 10:08:19 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1475773733 21103 195.159.176.226 (6 Oct 2016 17:08:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Oct 2016 17:08:53 +0000 (UTC) User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (darwin) To: Emacs Development Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 06 19:08:49 2016 Return-path: Envelope-to: ged-emacs-devel@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 1bsC9y-00049H-7h for ged-emacs-devel@m.gmane.org; Thu, 06 Oct 2016 19:08:42 +0200 Original-Received: from localhost ([::1]:58220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsC9w-0007ll-N8 for ged-emacs-devel@m.gmane.org; Thu, 06 Oct 2016 13:08:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsC9n-0007g9-DK for emacs-devel@gnu.org; Thu, 06 Oct 2016 13:08:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsC9i-0005jn-63 for emacs-devel@gnu.org; Thu, 06 Oct 2016 13:08:31 -0400 Original-Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:33284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsC9h-0005jE-TD for emacs-devel@gnu.org; Thu, 06 Oct 2016 13:08:26 -0400 Original-Received: by mail-pf0-x22c.google.com with SMTP id 190so11968420pfv.0 for ; Thu, 06 Oct 2016 10:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mail-followup-to :mime-version; bh=58c9G89YnA7SueXHsF1KhaS1+a10xO2zyvm/Th7u4cI=; b=QUN1Xo07HV4bBjVjc0laP4Yrvn7GpnXtBtO97jdsLNlQQjnefakCokDv45+NW5Ff1J C1FpM8WuQVM248OgD4uaM1aHzAS+KxUsGpKVpDAa4ckmsrI7kV1WmJbPd7X8pV1YDtAP m5q8aCWnIXiimt5ZPwqJCrbmXbN1mBw3p4g5kFiC9a0V/poGbVOkXmNsZlz2Xx/Jkq4/ EGFZNSy6XaZ885nIg6LtLMMVD75sj3RUreP30ZzEiESTOjHlOS4AC3br7w2EJMJ7qAAx XcoiVKsSSnnJXBQ33foN/DPpNCkZBgFVzQEp+AJZmKoK971sckXT+xHuisJD25TqDRVZ 9IzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mail-followup-to:mime-version; bh=58c9G89YnA7SueXHsF1KhaS1+a10xO2zyvm/Th7u4cI=; b=mSj8eKcGmsBBCLbofPSvfZJ0kx+8bP0PsA+nuF2LCo3vKKw3fvQYBEt+nLVkcpVOkj bG9X+tneNXJbcGyuJBQoWEayWRA5J+V3VEzyQjxpVsNzY2kuckqNqOEDVzYdgrc0YjCE lrRmvIjHmi5JE8MXsshfRj6IxbSN7Z2lRKy04vhDtoQXyF1KviZduiXNKmKt3ZLCyKmk kyEAcaYBeEVwlDoYwdl1lakAVOAppyLpfquEncdkxbTztI+fwnyBfBDmAI2KBBCE4CII 4gkma1/KLeAZMcTRKAMrj3jEmO4zjHZbpzZik5jai4Pg0B32Pe0PL70a9Xqm20Baulit gTWg== X-Gm-Message-State: AA6/9RmfBAaviwO/uBgdLOcUCHdCXQFKOfM/n1dUGirCeH2t47RHg1hfu9rgdqGPMN4u1Q== X-Received: by 10.98.106.65 with SMTP id f62mr9946283pfc.107.1475773704241; Thu, 06 Oct 2016 10:08:24 -0700 (PDT) Original-Received: from Vulcan.local (76-234-69-149.lightspeed.frokca.sbcglobal.net. [76.234.69.149]) by smtp.gmail.com with ESMTPSA id l84sm7195636pfi.14.2016.10.06.10.08.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 06 Oct 2016 10:08:23 -0700 (PDT) X-Google-Original-From: "John Wiegley" Original-Received: by Vulcan.local (Postfix, from userid 501) id D37982A69552; Thu, 6 Oct 2016 10:08:22 -0700 (PDT) Mail-Followup-To: Emacs Development X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208034 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable This is functionality I'd like to add to rect.el. It allows you to specify a rectangular region, and then edit just the contents of that rectangle in a separate buffer. When finished (C-c C-c), it replaces the old rectangle usi= ng insert-rectangle with the new contents. I'd appreciate comments on usability, fitness, etc. =2D-8<---------------cut here---------------start------------->8--- (defvar edit-rectangle-origin) (defvar edit-rectangle-saved-window-config) (defun edit-rectangle (&optional start end) (interactive "r") (let ((strs (delete-extract-rectangle start end)) (mode major-mode) (here (copy-marker (min (mark) (point)) t)) (config (current-window-configuration))) (with-current-buffer (generate-new-buffer "*Rectangle*") (funcall mode) (set (make-local-variable 'edit-rectangle-origin) here) (set (make-local-variable 'edit-rectangle-saved-window-config) config) (local-set-key (kbd "C-c C-c") #'restore-rectangle) (mapc #'(lambda (x) (insert x ?\n)) strs) (goto-char (point-min)) (pop-to-buffer (current-buffer))))) (defun restore-rectangle () (interactive) (let ((content (split-string (buffer-string) "\n")) (origin edit-rectangle-origin) (config edit-rectangle-saved-window-config)) (with-current-buffer (marker-buffer origin) (goto-char origin) (insert-rectangle content)) (kill-buffer (current-buffer)) (set-window-configuration config))) =2D-8<---------------cut here---------------end--------------->8--- =2D-=20 John Wiegley GPG fingerprint =3D 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGcBAEBCgAGBQJX9oUDAAoJEMFE2PTxn+YwCaUL/1Zm889ER2JRX+ObJ9jVaIeT GYz/RtXlvMLN6Es10YO6gJfsgVJUHoVXmy2h16ynZpX1Q6fp97vKXh/pK5493qjh XNv+QA7VEtB8mIezUgvm9XwfR7zIy/xpHsOAhEZvZA2E7Q+eBa1Fvn1DMrjn8wCm cETofpLNood4uOLojB0/qnIgbqlODtlJ+mYXpBi/9KEjBqy7dMsuAEGWv4LqgkgY e8WaQ5IXcr31DSBg3oj6Sq0Cnx/QT5jz7CR6ZlZ3o7Uv+XNBMkMk+5IZVqBFesgj erkY3WKLp2q1GlmF2uHHDLCDsMOErp1mC9u0/qQKzy8UgVs2ta+cwhtQYRP6LcOR gZLKcQ/a4V2EIgmt6t/y4uWFUjEVvyzkOhqQIDNZHtI1mq+ALJFwtTjdFS/V6W76 RDSQh967oKwK+AidINngaLCvY+QHHojCVk4BQmZEm+egavl5RMJ7Y1d/RF77XC2T qtLC3LUoMLvsyFvw6VL2tFmdrQSIZvGRjc6lg6VVeQ== =Vhgh -----END PGP SIGNATURE----- --=-=-=--