Subject: Re: bug#78561: [PATCH] Add semantic linefeed support for paragraph filling

From: Roi Martin <[email-masked]>
Date: Tue, 27 May 2025 17:47:14 +0200

Stefan Monnier <[email-masked]> writes:

>>> Please try and separate it into a `fill-region-semlf` function and then
>>> another one which applies it to a paragraph, so that it can also be used
>>> to fill a specific user-specified region (or the whole buffer).
>> I'm not sure about this one.  The idea is that `fill-paragraph-semlf'
>> can be assigned as a value for `fill-paragraph-function' (I also
>> included a mention to this in the doc string) or it can be called
>> directly.  The thing is that `fill-paragraph' docs say:
>
> Sadly, we don't currently have anything like a `fill-region-function`,
> but that's "a bug, not a feature", so we should write new code such that
> this misfeature is easier rather than harder to fix in the future.
>
>> I agree that it would be useful to apply `fill-paragraph-semlf' on
>> a region or the whole buffer.  But, the same could be said about any
>> other `fill-paragraph-function'.
>
> Yes, I've had this in my TODO for many years.  🙁

I'll try to implement it :)

>> So, do we really want a specific `fill-region-semlf' function?
>
> Actually, I think I want a `fill-region-as-paragraph-semlf'.
> And maybe then some way to tell the `fill.el` code to use that instead
> of the default `fill-region-as-paragraph`.

OK, so here is my plan:

First, I'll give a closer look to all the "fill" functions that Emacs
currently provides to understand how every thing fits together and what
is and what is not already supported.

Then, I'll send a new patch to support applying a
`fill-paragraph-function' on a region "as-paragraph" (similar to the
behavior of `fill-region-as-paragraph') and "per-paragraph" (similar to
executing `fill-paragraph' for each paragraph within the region).

Finally, if needed, I can update this patch.

Does it make sense?