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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 13 Jan 2024 21:21:51 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> Date: Sat, 13 Jan 2024 19:13:56 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Is the problem in your example what fill-forward-paragraph-function
> > does, or is the problem elsewhere in refill-fill-paragraph-at and/or
> > refill-post-command-function?  IOW, can you tell which part(s) of
> > refill.el fail to DTRT in an Org buffer?  I don't know enough about
> > all the peculiarities of the Org format to tell what should be fixed
> > in that case, let alone how.
> 
> AFAIU, the problem is in
> 
> (if use-hard-newlines
> 		    (fill-region oend end arg)
> 		  (fill-region-as-paragraph oend end arg))
> 
> Both `fill-region' and `fill-region-as-paragraph' do not respect
> `fill-paragraph-function' and always act the same once the region
> boundaries are identified regardless of the major mode.

We already agreed that fill-region-as-paragraph cannot use
fill-paragraph-function, right?  So what should
fill-region-as-paragraph do in order to behave more correctly in Org
buffers?  IOW, what are the specific problems in
fill-region-as-paragraph that break it in Org buffers?  (I presume
that use-hard-newlines is nil in these cases, so fill-paragraph is
currently not relevant.)