help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Looking for (fill-paragraph) Like Functions


From: Floyd L. Davidson
Subject: Re: Looking for (fill-paragraph) Like Functions
Date: Wed, 29 Nov 2006 07:19:13 -0900
User-agent: gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.17-11

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)
>
>I would like my M-q to work for any "bulleted" list like this

Between marking the "bullet" pattern, the indent, and the end of
the item, there are so many varieties of bulleted lists that a
simple generic function cannot suffice.  Instead one would need
to either restrict it to certain constructs or provide an
extensive pre-configuration list.  Which probably means it just
isn't practical to use such a function.  For example, if you
make an error or otherwise decide to change the configuration,
editing the results will be far more painful than not.

Likewise there are a few tricks one can learn that make doing it
manually an easy enough task.  One is to enable "text-mode" and
(if it is not by default) set adaptive-fill-mode to true.

To reformat your list above, items 1) and 2) need only a proper
indent, and 3) is the interesting one.  So I'll describe doing
that one step by step (assuming that basic commands, like
navigation and how to insert blank lines, are second nature and
need not be mentioned).

First separate that line from the line above and below it:

    2) this is another sentence in a list

    3) this is a sentence is long i would like to hit M-q ...

    4) this is another line M-q here would be good if it ...

Now, work on item 3 alone.  Start by reformatting it, and it
will look like this (in this case the fill column is 55):

    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

Then separate the top line for the other lines:

    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

Now indent the second line to the appropriate column:

    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

Now use M-q to reformat the second and third lines:

    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

And obviously at that point simply deleting the excess blank
lines provides the desired result.

-- 
Floyd L. Davidson            <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@apaflo.com


reply via email to

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