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

From: Ihor Radchenko <[email-masked]>
Date: Sat, 13 Jan 2024 18:37:23 +0000

Eli Zaretskii <[email-masked]> writes:

> I mean the problem with refill-mode that you described in
>
>   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68418#19
>
> Is it possible to fix that by some improvements to
> fill-forward-paragraph-function used by Org?

I doubt so. The only idea that is coming to my mind is to make Org
mode's `fill-forward-paragraph-function' not move anywhere when not on
paragraph - this will prevent refill-mode from filling anything but Org
paragraphs.

However, this idea will not work because:
1. It will cause infinite loop in `fill-region' that is also using
   `fill-forward-paragraph-function', but expects it to move somewhere.

2. Make it impossible to implement custom filling for non-paragraphs, as
   we do for source blocks (by delegating to source block major mode),
   tables, and comments.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>