From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: narrow-to-region for a rectangle Date: Wed, 05 Jun 2013 12:20:30 +0530 Message-ID: <874nddkq4p.fsf@gmail.com> References: <87k3ma6ocm.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1370415029 28183 80.91.229.3 (5 Jun 2013 06:50:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Jun 2013 06:50:29 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: C K Kashyap Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 05 08:50:29 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uk7YD-0003eP-CQ for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Jun 2013 08:50:29 +0200 Original-Received: from localhost ([::1]:42574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk7YD-0002yf-0g for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Jun 2013 02:50:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk7Y2-0002xv-C2 for help-gnu-emacs@gnu.org; Wed, 05 Jun 2013 02:50:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uk7Xy-0007Uy-Dr for help-gnu-emacs@gnu.org; Wed, 05 Jun 2013 02:50:18 -0400 Original-Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:35857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk7Xy-0007Uo-7j for help-gnu-emacs@gnu.org; Wed, 05 Jun 2013 02:50:14 -0400 Original-Received: by mail-pa0-f45.google.com with SMTP id bi5so796238pad.4 for ; Tue, 04 Jun 2013 23:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=vkrT4etedbXTGRl8knOcDz/2saDLlJbDcE7ee0KVAh4=; b=oiixkfc9fBDS/PJguAhyzmdSrcbVHJstCR0EhQMVSkHo3xhbb3at9LnKBLPFV6bh1S nituw03hMUZ39mGkFYtRmsiwlmvAF8TGdIUihtnae603kqLKCCexvLXC4teU3uuGSEMX /KnCCJosuM0ppPP0LX1sh2enW0j2KQF6e20Wqcyi2B9AlrzWCfBtMU1e5RFEjFfGhRR/ 1t11OdqPL/Dw1FsEv9bLmZk/uLLou53IJtZBymLwrVlfmgfNkvLE0HYOwa1tvRD0Pls9 LF8Z83N0CSMckKLzF7IwnFPJ1aETNZfxhJPOEsqIzrEXqm8ySVvnDlMnOUQKxlqRp8oC eUVQ== X-Received: by 10.66.154.225 with SMTP id vr1mr33238337pab.85.1370415013156; Tue, 04 Jun 2013 23:50:13 -0700 (PDT) Original-Received: from debian-6.05 ([115.241.93.81]) by mx.google.com with ESMTPSA id p2sm2581117pag.22.2013.06.04.23.50.10 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 04 Jun 2013 23:50:12 -0700 (PDT) In-Reply-To: (C. K. Kashyap's message of "Wed, 5 Jun 2013 12:04:30 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22d X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91314 Archived-At: C K Kashyap writes: > This is what I've come up with. I'd really appreciate some feedback. Others have provided feedback and they are all good. If it gets the job done, you should bother (yourself and others) no more. If one is interested in working with rectangles - edit text (with filling, justification, what not), narrow it (and have regexp matchers ^, $ do the expected) then one can look at table.el and extract portions of it to the Emacs "core". Remember, rectangle is but a table cell (possibly with no "geometric rectangle" surrounding it.) ,---- From commentary section of table.el | | ;; The most difficult part of dealing with table editing in Emacs | ;; probably is how to realize localized rectangular editing effect. | ;; Emacs has no rectangular narrowing mechanism. Existing rect package | ;; provides basically kill, delete and yank operations of a rectangle, | ;; which internally is a mere list of strings. | | ;; A simple approach for realizing the localized virtual rectangular | ;; operation is combining rect package capability with a temporary | ;; buffer. Insertion and deletion of a character to a table cell can be | ;; trapped by a function that copies the cell rectangle to a temporary | ;; buffer then apply the insertion/deletion to the temporary contents. | ;; Then it formats the contents by filling the paragraphs in order to | ;; fit it into the original rectangular area and finally copy it back to | ;; the original buffer. | | ;; This simplistic approach has to bear with significant performance | ;; hit. As cell grows larger the copying rectangle back and forth | ;; between the original buffer and the temporary buffer becomes | ;; expensive and unbearably slow. It was completely impractical and an | ;; obvious failure. | | ;; An idea has been borrowed from the original Emacs design to overcome | ;; this shortcoming. When the terminal screen update was slow and | ;; expensive Emacs employed a clever algorithm to reduce actual screen | ;; update by removing redundant redrawing operations. Also the actual | ;; redrawing was done only when there was enough idling time. This | ;; technique significantly improved the previously mentioned undesirable | ;; situation. Now the original buffer's rectangle is copied into a | ;; cache buffer only once. Any cell editing operation is done only to | ;; the cache contents. When there is enough idling time the original | ;; buffer's rectangle is updated with the current cache contents. This | ;; delayed operation is implemented by using Emacs's timer function. To | ;; reduce the visual awkwardness introduced by the delayed effect the | ;; cursor location is updated in real-time as a user types while the | ;; cell contents remains the same until the next idling time. A key to | ;; the success of this approach is how to maintain cache coherency. As | ;; a user moves point in and out of a cell the table buffer contents and | ;; the cache buffer contents must be synchronized without a mistake. By | ;; observing user action carefully this is possible however not easy. | ;; Once this mechanism is firmly implemented the rest of table features | ;; grew in relatively painless progression. | | ;; Those users who are familiar with Emacs internals appreciate this | ;; table package more. Because it demonstrates how extensible Emacs is | ;; by showing something that appears like a magic. It lets you | ;; re-discover the potential of Emacs. | `----