unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* understanding fill-region, paragraph-separate, and paragraph-start
@ 2018-12-11 21:47 Eric Abrahamsen
  2018-12-11 22:47 ` Stephen Berman
  2018-12-12  2:16 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2018-12-11 21:47 UTC (permalink / raw)
  To: help-gnu-emacs

In EBDB I've been using a manual function to correctly format record
fields. Briefly, the output looks just like BBDB:

John Doe
   mail: email1@address.com, email2@address.com, email3@address.com
  notes: This is John Doe, a guy I met in blah blah blah blah blah

In narrow windows, I want the above two lines to fill/wrap like so:

John Doe
   mail: email1@address.com, email2@address.com,
         email3@address.com
  notes: This is John Doe, a guy I met in blah blah
         blah blah blah

So each line has an overhanging label, and subsequent lines are filled
to the beginning of the text on the first line.

Right now this is done "manually" with a function that just goes in and
sticks in spaces.

In the interest of Doing the Right Thing (and learning how filling
works), I'm trying to accomplish the same thing by setting the correct
values of `fill-column', `paragraph-separate', and `paragraph-start',
and then calling `fill-region' on all the lines at once.

I haven't been able to get this right. I think the regexp I want is
"[^:]+: ", meaning a paragraph starts with some stuff that's not a
colon, then a colon and a space. But if I use that as the value of
`paragraph-start', nothing happens (the lines still look like example
one above), if I use it as the value of `paragraph-separate' the region
is turned into a single line (but wrapped to `fill-column'), and if I
use it as the value of both the region is turned into a single long line
that isn't filled.

I'll worry about the underhang later -- how is this meant to work? I
also thought `paragraph-separate' might be a "\n", but that goes back to
doing nothing.

And hints much appreciated!

Eric




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-11 21:47 understanding fill-region, paragraph-separate, and paragraph-start Eric Abrahamsen
@ 2018-12-11 22:47 ` Stephen Berman
  2018-12-12  0:15   ` Eric Abrahamsen
  2018-12-12  2:16 ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2018-12-11 22:47 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs

On Tue, 11 Dec 2018 13:47:01 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> In EBDB I've been using a manual function to correctly format record
> fields. Briefly, the output looks just like BBDB:
>
> John Doe
>    mail: email1@address.com, email2@address.com, email3@address.com
>   notes: This is John Doe, a guy I met in blah blah blah blah blah
>
> In narrow windows, I want the above two lines to fill/wrap like so:
>
> John Doe
>    mail: email1@address.com, email2@address.com,
>          email3@address.com
>   notes: This is John Doe, a guy I met in blah blah
>          blah blah blah
>
> So each line has an overhanging label, and subsequent lines are filled
> to the beginning of the text on the first line.
>
> Right now this is done "manually" with a function that just goes in and
> sticks in spaces.
>
> In the interest of Doing the Right Thing (and learning how filling
> works), I'm trying to accomplish the same thing by setting the correct
> values of `fill-column', `paragraph-separate', and `paragraph-start',
> and then calling `fill-region' on all the lines at once.
>
> I haven't been able to get this right. I think the regexp I want is
> "[^:]+: ", meaning a paragraph starts with some stuff that's not a
> colon, then a colon and a space. But if I use that as the value of
> `paragraph-start', nothing happens (the lines still look like example
> one above), if I use it as the value of `paragraph-separate' the region
> is turned into a single line (but wrapped to `fill-column'), and if I
> use it as the value of both the region is turned into a single long line
> that isn't filled.
>
> I'll worry about the underhang later -- how is this meant to work? I
> also thought `paragraph-separate' might be a "\n", but that goes back to
> doing nothing.
>
> And hints much appreciated!

I can't help with paragraph-separate, fill-region etc., but FWIW you can
get the visual effect of the above by using a combination of
visual-line-mode and wrap-prefix.

Steve Berman



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-11 22:47 ` Stephen Berman
@ 2018-12-12  0:15   ` Eric Abrahamsen
  2018-12-12 11:07     ` Stephen Berman
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2018-12-12  0:15 UTC (permalink / raw)
  To: Stephen Berman; +Cc: help-gnu-emacs

Stephen Berman <stephen.berman@gmx.net> writes:

> On Tue, 11 Dec 2018 13:47:01 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
>> In EBDB I've been using a manual function to correctly format record
>> fields. Briefly, the output looks just like BBDB:
>>
>> John Doe
>>    mail: email1@address.com, email2@address.com, email3@address.com
>>   notes: This is John Doe, a guy I met in blah blah blah blah blah
>>
>> In narrow windows, I want the above two lines to fill/wrap like so:
>>
>> John Doe
>>    mail: email1@address.com, email2@address.com,
>>          email3@address.com
>>   notes: This is John Doe, a guy I met in blah blah
>>          blah blah blah
>>
>> So each line has an overhanging label, and subsequent lines are filled
>> to the beginning of the text on the first line.
>>
>> Right now this is done "manually" with a function that just goes in and
>> sticks in spaces.
>>
>> In the interest of Doing the Right Thing (and learning how filling
>> works), I'm trying to accomplish the same thing by setting the correct
>> values of `fill-column', `paragraph-separate', and `paragraph-start',
>> and then calling `fill-region' on all the lines at once.
>>
>> I haven't been able to get this right. I think the regexp I want is
>> "[^:]+: ", meaning a paragraph starts with some stuff that's not a
>> colon, then a colon and a space. But if I use that as the value of
>> `paragraph-start', nothing happens (the lines still look like example
>> one above), if I use it as the value of `paragraph-separate' the region
>> is turned into a single line (but wrapped to `fill-column'), and if I
>> use it as the value of both the region is turned into a single long line
>> that isn't filled.
>>
>> I'll worry about the underhang later -- how is this meant to work? I
>> also thought `paragraph-separate' might be a "\n", but that goes back to
>> doing nothing.
>>
>> And hints much appreciated!
>
> I can't help with paragraph-separate, fill-region etc., but FWIW you can
> get the visual effect of the above by using a combination of
> visual-line-mode and wrap-prefix.

That's an interesting idea, thanks. This is a read-only special-mode
buffer, but maybe that doesn't preclude the use of visual-line-mode.
I'll take a look!

Thanks,
Eric



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-11 21:47 understanding fill-region, paragraph-separate, and paragraph-start Eric Abrahamsen
  2018-12-11 22:47 ` Stephen Berman
@ 2018-12-12  2:16 ` Stefan Monnier
  2018-12-13 21:48   ` Eric Abrahamsen
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2018-12-12  2:16 UTC (permalink / raw)
  To: help-gnu-emacs

> I haven't been able to get this right. I think the regexp I want is
> "[^:]+: ",

That looks right for paragraph-start, except you want to stay within a line:

    "[^:\n]+: "

You probably want it to be even more restrictive, as in

    "[ \t]*[[:alpha:]]+: "


-- Stefan




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-12  0:15   ` Eric Abrahamsen
@ 2018-12-12 11:07     ` Stephen Berman
  2018-12-12 19:18       ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2018-12-12 11:07 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs

On Tue, 11 Dec 2018 16:15:41 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> On Tue, 11 Dec 2018 13:47:01 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>>
[...]
>>> I'll worry about the underhang later -- how is this meant to work? I
>>> also thought `paragraph-separate' might be a "\n", but that goes back to
>>> doing nothing.
>>>
>>> And hints much appreciated!
>>
>> I can't help with paragraph-separate, fill-region etc., but FWIW you can
>> get the visual effect of the above by using a combination of
>> visual-line-mode and wrap-prefix.
>
> That's an interesting idea, thanks. This is a read-only special-mode
> buffer, but maybe that doesn't preclude the use of visual-line-mode.

It definitely doesn't; e.g. it's the way todo-mode (also read-only and
derived from special-mode) works by default.

Steve Berman



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-12 11:07     ` Stephen Berman
@ 2018-12-12 19:18       ` Eric Abrahamsen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2018-12-12 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

Stephen Berman <stephen.berman@gmx.net> writes:

> On Tue, 11 Dec 2018 16:15:41 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
>> Stephen Berman <stephen.berman@gmx.net> writes:
>>
>>> On Tue, 11 Dec 2018 13:47:01 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>>>
> [...]
>>>> I'll worry about the underhang later -- how is this meant to work? I
>>>> also thought `paragraph-separate' might be a "\n", but that goes back to
>>>> doing nothing.
>>>>
>>>> And hints much appreciated!
>>>
>>> I can't help with paragraph-separate, fill-region etc., but FWIW you can
>>> get the visual effect of the above by using a combination of
>>> visual-line-mode and wrap-prefix.
>>
>> That's an interesting idea, thanks. This is a read-only special-mode
>> buffer, but maybe that doesn't preclude the use of visual-line-mode.
>
> It definitely doesn't; e.g. it's the way todo-mode (also read-only and
> derived from special-mode) works by default.

Okay, thanks -- I'll give that a shot, though I'm discovering that the
effect I'm trying to create might be a little too complicated for the
built-in mechanisms. wrap-prefix does look promising, though...




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: understanding fill-region, paragraph-separate, and paragraph-start
  2018-12-12  2:16 ` Stefan Monnier
@ 2018-12-13 21:48   ` Eric Abrahamsen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2018-12-13 21:48 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I haven't been able to get this right. I think the regexp I want is
>> "[^:]+: ",
>
> That looks right for paragraph-start, except you want to stay within a line:
>
>     "[^:\n]+: "
>
> You probably want it to be even more restrictive, as in
>
>     "[ \t]*[[:alpha:]]+: "

That got me to the point where my experiments started to make sense,
thank you! I am currently fooling around with fill-prefix vs
adaptive-fill-regexp, and will probably still end up with some amount of
manual man-handling, but this should end up significantly cleaner.

Thanks,
Eric




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-13 21:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-11 21:47 understanding fill-region, paragraph-separate, and paragraph-start Eric Abrahamsen
2018-12-11 22:47 ` Stephen Berman
2018-12-12  0:15   ` Eric Abrahamsen
2018-12-12 11:07     ` Stephen Berman
2018-12-12 19:18       ` Eric Abrahamsen
2018-12-12  2:16 ` Stefan Monnier
2018-12-13 21:48   ` Eric Abrahamsen

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).