From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: map-file-lines Date: Wed, 04 Feb 2009 09:38:08 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86fxiuw6u7.fsf@lifelogs.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233762258 5418 80.91.229.12 (4 Feb 2009 15:44:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Feb 2009 15:44:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 04 16:45:32 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LUjwR-00067Y-S0 for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2009 16:45:32 +0100 Original-Received: from localhost ([127.0.0.1]:55393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUjv9-0006Ev-13 for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2009 10:44:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUjny-0008Et-0H for emacs-devel@gnu.org; Wed, 04 Feb 2009 10:36:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUjnv-0008DL-0K for emacs-devel@gnu.org; Wed, 04 Feb 2009 10:36:45 -0500 Original-Received: from [199.232.76.173] (port=51790 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUjnu-0008DE-Rr for emacs-devel@gnu.org; Wed, 04 Feb 2009 10:36:42 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:37556 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LUjnu-0008CD-EZ for emacs-devel@gnu.org; Wed, 04 Feb 2009 10:36:42 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LUjno-00079b-9U for emacs-devel@gnu.org; Wed, 04 Feb 2009 15:36:36 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Feb 2009 15:36:36 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Feb 2009 15:36:36 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:Re6zMvLTlAr2jltuCJE9VE8kfUw= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108739 Archived-At: On Wed, 04 Feb 2009 02:04:32 -0500 Richard M Stallman wrote: RMS> Here's an idea for a UI for editing big files. First you run M-x grep on RMS> the file, and display the matches for whatever regexp. In the *grep* RMS> buffer you specify a region, which is a way of choosing two matches, RMS> the ones whose entries contain point and mark. Then you give a command to edit RMS> the file from one of the matches to the other. It marks these matches RMS> (and the lines containing them) as read-only so that you can't RMS> spoil the correspondance with the file. Thus, you can always save this RMS> partial-file buffer. RMS> The beginning and end of the *grep* buffer can be used to specify RMS> that the portion to edit starts or ends at bof or eof. RMS> It would be easy to adapt this to variants such as RMS> (1) using hexl-mode to visit the file, RMS> (2) using methods other than grep to subdivide the file, RMS> (3) providing more friendly front ends to grep. This is essentially mapping byte offsets to line positions, with extra calculations. As Stefan suggested, it's better to just use byte offsets. Your approach requires a lot of tracking of the grep lines, whereas just using byte offsets requires remembering the two current offsets and nothing else. Otherwise I think your suggestions are similar to mine: set up a special mode where the buffer is a window[1] into the file instead of the whole file, and create special commands to move the window back and forth. Saving would only save the buffer contents; the window won't be moveable until changes are saved (another approach is to remember modifications outside the window, but that gets hairy with undo). Ted [1] I know "window" has meaning in Emacs already, but I can't think of a better term.