Subject: bug#68418: refill-mode interferes with org-mode headlines

From: Eli Zaretskii <[email-masked]>
Date: Sat, 13 Jan 2024 15:43:22 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: Lars Rustand <[email-masked]>, Rudolf Adamkovič
>  <[email-masked]>, [email-masked]
> Date: Sat, 13 Jan 2024 13:28:16 +0000
> 
> This is a bit tangent, but the current design of filling feels chaotic -
> we have configurable fill-paragraph-function and
> fill-forward-paragraph-function, while `fill-region-as-paragraph' is
> hard-coded.  And forward-paragraph relies upon regexps...
> 
> It looks like the notion of paragraph when filling is designed to be
> different compared to the notion of paragraph in `forward-paragraph'.
> Is there any reason for such difference?

I don't know.

> This looks like an improvement. Also, it appears to fix the original
> reproducer.
> 
> However, there will still be a problem, even with the proposed patch, in
> the following scenario:
> 
> 1. emacs -Q
> 2. Open a new org file
> * Heading <point> :tag:
> 3. M-x refill-mode
> 4. Keep typing
> * Heading alksjd alkjasd asldkj asdlkj aslldkj aslkdj asldkj
>   asldkj <point>:tag:
> 
> See how the heading is split into multiple lines.
> 
> This happens because refill-mode uses `fill-region-as-paragraph', which
> is impossible to configure by major modes.
> As the above example demonstrates, not everything is safe to fill
> without breaking the markup.
> 
> A similar problem appears in `fill-region' - it completely disregards
> `fill-paragraph-function' and always calls `fill-region-as-paragraph'.

So you think the patch I posted should not be installed, and we should
wait for a more thorough solution?