[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for (fill-paragraph) Like Functions

From: Perry Smith
Subject: Re: Looking for (fill-paragraph) Like Functions
Date: Wed, 29 Nov 2006 09:00:00 -0600

On Nov 29, 2006, at 8:35 AM, Micha Feigin wrote:

On Wed, 29 Nov 2006 10:48:23 GMT
Passer By <address@hidden> 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

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)
<pattern to span white space>
<pattern to span numbering system> (which would match 1, 2, 3 or a, b, c. Maybe even i, ii, iii, iv,...)
<pattern to span ')' and other things that may be used at that point>

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 ( address@hidden )
Ease Software, Inc. ( )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems

reply via email to

[Prev in Thread] Current Thread [Next in Thread]