unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Passer By <sender@sender.send>
Subject: Re: Looking for (fill-paragraph) Like Functions
Date: Fri, 01 Dec 2006 10:29:39 GMT	[thread overview]
Message-ID: <87zma7lxil.fsf@localhost.localdomain> (raw)
In-Reply-To: mailman.1286.1164812410.2155.help-gnu-emacs@gnu.org

Perry Smith <pedz@easesoftware.com> writes:

> On Nov 29, 2006, at 8:35 AM, Micha Feigin wrote:
> 
> > On Wed, 29 Nov 2006 10:48:23 GMT
> > Passer By <sender@sender.send> 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)
> <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 ( pedz@easesoftware.com )
> Ease Software, Inc. ( http://www.easesoftware.com )
> 
> Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems

I guess to make a generic function would be harder than it has to be,
i mean i could make a function that was just for bullets.

The algorith would be something like



1) Got to beginning of paragraph

2) get mask of first "word" i.e. the first string before (ignoring
   leading white space, and followed by whitespace) In this list it
   would be "[0-9]+)" But it could be "-" "+", etc, etc

3) for each "bullet" open line above the next bullet 
       run M-q on bulleted line
      
4) erase lines that were opened.



Or basically, make every section between bullets a paragraph, run M-q
on the paragraphs, clean-up (erase the blank lines).


There might be some restrictions on the list, i.e. must have leading
newline to start and a newline/EOF to end.

  parent reply	other threads:[~2006-12-01 10:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-29 10:48 Looking for (fill-paragraph) Like Functions Passer By
2006-11-29 11:05 ` Mathias Dahl
2006-11-29 14:35 ` Micha Feigin
2006-11-29 15:00   ` Perry Smith
     [not found]   ` <mailman.1286.1164812410.2155.help-gnu-emacs@gnu.org>
2006-12-01 10:29     ` Passer By [this message]
2006-11-29 16:19 ` Floyd L. Davidson
2006-11-29 16:54   ` Markus Triska
2006-11-29 23:01     ` Floyd L. Davidson
2006-11-29 23:19       ` Markus Triska
2006-11-30  7:29         ` Floyd L. Davidson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zma7lxil.fsf@localhost.localdomain \
    --to=sender@sender.send \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).