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

From: Stefan Monnier <[email-masked]>
Date: Tue, 24 Jun 2025 15:30:16 -0400

>>> I think that `fill-region-as-paragraph-function' is a step in the right
>>> direction. What is left is handling `use-hard-newlines'. Currently, Org
>>> mode ignores it as the concept of hard newlines is not compatible with
>>> Org mode syntax and its notion of paragraphs. So, we probably need to
>>> have a way to bypass that branch in `fill-paragraph' or find some way to
>>> handle hard newlines that is compatible with Org mode and then Emacs
>>> introduce a new customization for Org to plug into.
>>
>> I don't understand: `use-hard-newlines` is nil by default and org mode
>> doesn't seem to set it, so those users who set it ... get what they deserve?
>
> "what they deserve" is not nice to users. There is some usefulness to a
> proper Org-specific hard newline support. See
> https://list.orgmode.org/orgmode/[email-masked]/
> (specifically, item 2).

I think I'm missing something.  I'm probably thinking too simplistically.
In the first paragraph of yours above when you say "we probably need to
have a way to bypass that branch in `fill-paragraph'", I understand it
to mean that you need some way to tell the fill code to ignore
hard-newlines.  And my reply was basically saying "well, there's
`use-hard-newline` for that".

If you want to pay attention to hard-newlines, yet also pay attention to
other "paragraph separator hints", then hopefully
`fill-paragraph-forward-function` can do the trick.  E.g. I can't see
any reason why Org couldn't set `fill-paragraph-forward-function` to
a function which uses both regexps and the `hard` text-property to
determine paragraph boundaries.

[ I'm personally not convinced of the usefulness of hard-newlines by the
  post above, but that OK: you don't need to convince me; I already
  fully agree that the code should be flexible enough to let users use
  hard-newlines (or any other trick they feel like using to indicate
  that something should be treated as a paragraph boundary).  I just
  won't be one of those users.  ]

        Stefan