From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Re: Looking for (fill-paragraph) Like Functions Date: Wed, 29 Nov 2006 09:00:00 -0600 Message-ID: References: <87d576msui.fsf@localhost.localdomain> <20061129163507.0ebf519d@litshi.luna.local> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1164812519 26381 80.91.229.2 (29 Nov 2006 15:01:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 29 Nov 2006 15:01:59 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 29 16:01:56 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GpQvv-0004Is-F5 for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Nov 2006 16:01:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GpQvv-0001YC-3D for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Nov 2006 10:01:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GpQuv-00010p-33 for help-gnu-emacs@gnu.org; Wed, 29 Nov 2006 10:00:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GpQuu-000107-9u for help-gnu-emacs@gnu.org; Wed, 29 Nov 2006 10:00:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GpQut-0000zr-FO for help-gnu-emacs@gnu.org; Wed, 29 Nov 2006 10:00:07 -0500 Original-Received: from [64.192.143.210] (helo=easeserver.easesoftware.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GpQut-0000rv-7c for help-gnu-emacs@gnu.org; Wed, 29 Nov 2006 10:00:07 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by easeserver.easesoftware.com (Postfix) with ESMTP id 41E97564EFD for ; Wed, 29 Nov 2006 09:00:06 -0600 (CST) Original-Received: from easeserver.easesoftware.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23286-01 for ; Wed, 29 Nov 2006 09:00:02 -0600 (CST) Original-Received: from [64.192.143.210] (easeserver.easesoftware.com [64.192.143.210]) by easeserver.easesoftware.com (Postfix) with ESMTP id 42F08564ED7 for ; Wed, 29 Nov 2006 09:00:01 -0600 (CST) In-Reply-To: <20061129163507.0ebf519d@litshi.luna.local> X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: by amavisd-new at easesoftware.net X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39097 Archived-At: On Nov 29, 2006, at 8:35 AM, Micha Feigin wrote: > On Wed, 29 Nov 2006 10:48:23 GMT > Passer By wrote: > >> >> >> >> My first learned function and loved function of emacs was the M-q but >> there are cases where M-q doesn't do exactly what i want and i would >> like to make an improved version or find one somewhere. >> >> >> Here is an example of what i would want my improved (fill-paragraph) >> to do. >> >> >> 1) this is a sentence >> 2) this is another sentence in a list >> 3) this is a sentence is long i would like to hit M-q now but >> emacs will not >> just rap this line it will rap all the lines and that makes me mad >> 4) this is >> another line M-q here would be good if it would make all the lines >> nice up to >> 1) >> > > The problem is with how do you recognize the end of a paragraph? > You can't use > the end of line symbol as that is the same symbol that is used to > break a line > in the middle of the paragraph and there is no end of paragraph > symbol for text > files (AFAIK, maybe unicode has something). > > The solution is to use the latex syntax and break lines with enter and > paragraph with an empty line. I think that that will solve your > problem. i.e: > > This is paragraph one > second line of paragraph one > > This is paragraph two. I think it is "do-able" but I don't want to volunteer to do it. From my perspective, the first task is to recognize that you are doing a list. The pattern would be something flexible broken into pieces (which you can do with regex). Starting with ^ as the anchor of the beginning of the line, the pattern to notice a list would be something like (I'll just use english to describe it) (which would match 1, 2, 3 or a, b, c. Maybe even i, ii, iii, iv,...) After having found the first of these, the start of the next time would match the same pattern but with the second item twiddled to be the next in the sequence. Again, all of this is "do-able" but rather tedious. To continue, this match would mark the start of the next item -- and the end of the previous item. Then narrow the region to be just the previous item, do a fill paragraph, restore to the original region, and continue. So, done correctly, it could actually cope with indented lists inside of lists. BUT... my guess is it would take me several days to come up with all this. I would guess it would take you at least that long. And, as this reply points out, most people just put a blank line between items and just avoid the problem. Perry Smith ( pedz@easesoftware.com ) Ease Software, Inc. ( http://www.easesoftware.com ) Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems