GNU bug report logs - #68418
refill-mode interferes with org-mode headlines

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Lars Rustand <rustand.lars@HIDDEN>; merged with #52778; dated Sat, 13 Jan 2024 07:14:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 20:08:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 15:08:23 2024
Received: from localhost ([127.0.0.1]:41194 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOkIo-0004Pb-Oo
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 15:08:23 -0500
Received: from mout02.posteo.de ([185.67.36.66]:47477)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOkIm-0004PN-ED
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 15:08:21 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 7B3FD240101
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 21:08:15 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705176495; bh=E2L5X52n6OfHQks1LSIqt+uLj+JiouyflWHrgGXdKz8=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=G12rCrd1JGuCCHMJqrS5ey03xTnWaESrcgTWZxJaFnP1UAG2d8qk7vu7AxCrOjgFa
 YWEV1FUg7fAuvsReanmMW3JaK5h52+oYAr6XZ1yz3syjCuUyO2YOCZVdiAmAHiaDkL
 RZGnR0edZ+L7OVSTd2SI4EbV6yB/ggSmZaI8PJhGitWPecizCILawNUeDeNvgARww7
 UABAWaPKRBIY9QOzvr9aA4xEQfD3aPKyatjHMgTc4aqe6uuysoWECHH351dGEgICLb
 o+uGKnFPhsWZpm9GC/L5UaxhdsS2hEFCs15iyj4rO3+QG+vO3YbRRt7y0vMqCa4GPr
 EATLaWCAxfejg==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC8bf5fJHz6tvh;
 Sat, 13 Jan 2024 21:08:14 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <83o7dpf1lm.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
 <87wmsdt6zg.fsf@localhost> <83v87xf47s.fsf@HIDDEN>
 <87r0ilt5aj.fsf@localhost> <83ply5f38w.fsf@HIDDEN>
 <87o7dpt4d8.fsf@localhost> <83o7dpf1lm.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 20:11:28 +0000
Message-ID: <87cyu5t2mn.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> `fill-region-as-paragraph' itself is not a problem.
>> The problem is that calling `fill-region-as-paragraph' directly does not
>> make sense in Org buffers - it will break the markup.
>
> You are basically saying that refill-mode makes no sense in Org
> buffers, right?  If fill-region-as-paragraph cannot be factored and/or
> provide hooks for Org to customize it, then Org users should be told
> not to use refill-mode in Org buffers.

No. refill-mode could make use of `fill-paragraph-function' rather than
calling `fill-region-as-paragraph' directly.

Look at the docstring:

(defun refill-fill-paragraph-at (pos &optional arg)
  "Like `fill-paragraph' at POS, but don't delete whitespace at paragraph end."

If `refill-fill-paragraph-at' is "like fill-paragraph", how come it does
not respect `fill-paragraph-function'?
If the goal is to preserve the whitespace at paragraph end, that
whitespace could be stored and re-applied after calling `fill-paragraph'.

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 19:57:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 14:57:51 2024
Received: from localhost ([127.0.0.1]:41177 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOk8d-0001T9-Gd
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:57:51 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:56688)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOk8b-0001Sw-OR
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:57:50 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOk8X-0005nS-8v; Sat, 13 Jan 2024 14:57:45 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ENSTQybyGl809rMbylKETrRsijfIKSQEjm1LFeNy39k=; b=WHZevECuFW/5
 YNkYCDw8ipPDdlT5atLdDFwrc+WXpvtotxeO+AuF5ETtwOwCqRC+eA9saaRHx70V6wTwN0OxRgeJo
 j6lQJGQqGEVQ0KrS+KVNcud/EDoqVQmHv8RghjHE06oZCEOMJcPF9R46NYgNjL7RaSCAe3je57GJg
 5UVpYxrG0noXrh1gkaSD3bhUAoRTqM+o5gaCGYELZibbGwih8ABUn0L8nRrQMdQA6yXosdXJ/vPj2
 y2BoRhzkZWigEZFkzNeeHSlV1PP7GjMLx4FT1Z1MTJm3zRh8I/5mIqTV/0C9qjlPXUD0MEAP6vJaL
 HhYOenLHvZkfMiZcFOH5dg==;
Date: Sat, 13 Jan 2024 21:57:25 +0200
Message-Id: <83o7dpf1lm.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87o7dpt4d8.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 19:33:55 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
 <87wmsdt6zg.fsf@localhost> <83v87xf47s.fsf@HIDDEN>
 <87r0ilt5aj.fsf@localhost> <83ply5f38w.fsf@HIDDEN> <87o7dpt4d8.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
> Date: Sat, 13 Jan 2024 19:33:55 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > 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.)
> 
> `fill-region-as-paragraph' itself is not a problem.
> The problem is that calling `fill-region-as-paragraph' directly does not
> make sense in Org buffers - it will break the markup.

You are basically saying that refill-mode makes no sense in Org
buffers, right?  If fill-region-as-paragraph cannot be factored and/or
provide hooks for Org to customize it, then Org users should be told
not to use refill-mode in Org buffers.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 19:30:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 14:30:53 2024
Received: from localhost ([127.0.0.1]:41170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOjiW-0005b5-UL
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:30:53 -0500
Received: from mout02.posteo.de ([185.67.36.66]:51267)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOjiV-0005PQ-AS
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:30:52 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id D25CB240103
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 20:30:46 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705174246; bh=oeak9ENW9C0MvbxtaxHONr76Y+8vGS+IE9Z2u2Mms+c=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=MbKyOKA1t+xJOHH1Fl7B7LESlpQlHceo5Wb5OPW2AQBlrW6xdkNXQc7XhXCr0omNv
 /VJ5gXwOmZ7Do63ZAiX6VvIRJmPkGQPyPuJftHbiyBu1m56i5Mx0+mB6whoOTzg1Vm
 rsl4bTBhfkfeEAhqpCKnRSoDh7LgYi1pmEqE2fjb/Ale4NrDeMmzwETfApKLdo40RW
 MQt2KJXjsMZNpDMUU+7w94mey7g3bBtwYjAD7STMOaY7r+h3INvqr/PKYSnATrqZE5
 BiqorvaxOslFVIqPlNyLextsAdor9kXZfCoSZKIBPmWwpPttx/kRvWYMyg4YR19P6m
 bs0KvQ+8C8jyA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC7mQ0W6hz6trs;
 Sat, 13 Jan 2024 20:30:45 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <83ply5f38w.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
 <87wmsdt6zg.fsf@localhost> <83v87xf47s.fsf@HIDDEN>
 <87r0ilt5aj.fsf@localhost> <83ply5f38w.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 19:33:55 +0000
Message-ID: <87o7dpt4d8.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

> 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.)

`fill-region-as-paragraph' itself is not a problem.
The problem is that calling `fill-region-as-paragraph' directly does not
make sense in Org buffers - it will break the markup.

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 19:22:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 14:22:19 2024
Received: from localhost ([127.0.0.1]:41159 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOjaF-0003eW-8A
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:22:19 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48070)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOjaD-0003eJ-7j
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:22:18 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOja8-0002hP-Gh; Sat, 13 Jan 2024 14:22:12 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=fsx4K4lebAqHAyEL8WDQyGODZkj9zDfTiC8nIuugZOc=; b=MEIqUCL6lLx/
 ZuGtDWMZmmt2ReZGxwUOZGl4FGud/Ab2hzkFqt4zvlZYExww2SbdemgciJ3OfX0Au1p6p+3uIJoED
 06Aqg7ZrH8wuUxnD3ErQNhqBLwXU0GiiDbvfK7iDfyU339ax/HH3kSQWBJRAxSHHfLGI2q2i8H/jj
 7fLBSRSVqVFDroN4rvdfJZKiPrlDhBSo56K/V8/qd/l8UUqj5H5MAwni/KKlDgwioccFRyPEr1GZg
 kD9oC4ppjVBXosWoGAPxg7AW0BvLuLYlbEwhk/cXIqy07+aAMOZp+2FCbSIIgmi1Jj7Y9xqHvgEk9
 XAbHHn8wjJg9o7ef49fefw==;
Date: Sat, 13 Jan 2024 21:21:51 +0200
Message-Id: <83ply5f38w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87r0ilt5aj.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 19:13:56 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
 <87wmsdt6zg.fsf@localhost> <83v87xf47s.fsf@HIDDEN> <87r0ilt5aj.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
> Date: Sat, 13 Jan 2024 19:13:56 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> 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.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 19:10:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 14:10:57 2024
Received: from localhost ([127.0.0.1]:41128 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOjPF-0000gY-4W
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:10:57 -0500
Received: from mout01.posteo.de ([185.67.36.65]:50035)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOjPA-0000g8-3B
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:10:55 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 66D1524002A
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 20:10:47 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705173047; bh=2izME+7ioQxOR+tgVMO6QyGeDsXxZXduvKhZaLqTSDg=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=LOQLH7efqbJiVnWrqO7jcvLLAMvObRsfpKUktGvPxzJAJum2Z2JBzi5twNQUo5ycM
 wtl599hEACsCDcmtYyynelLaVla7KlK++0p95dmzTruiii5nA2ijKdH8tl/Nuf8vCi
 UC2ftN9Kp4ZwL9ZddjVsaPH57zEU+4IAvcUApx8G4oBxSG4lahiLqy9GoabXSNRVAm
 FrnLmvUNaaqy0Rqr6CB5lCF2p6MDCKzgEDTloVVORlNOS8K90bEGGNReRZg7rOOsmA
 7QXpVuFAyloOmFwQ1xFLqTc21McLrNukfk7ato9IFGjQACpHcmzVSyF5kI3oF67VE0
 Gy3Omv65vfTYw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC7KL48LTz6tn4;
 Sat, 13 Jan 2024 20:10:46 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <83v87xf47s.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
 <87wmsdt6zg.fsf@localhost> <83v87xf47s.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 19:13:56 +0000
Message-ID: <87r0ilt5aj.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> > 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.
>
> 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.

`fill-region-as-paragraph' does not respect it as per docstring and
refill mode should probably not call `fill-region-as-paragraph'. The
branching for `use-hard-newlines' should belong to text-mode, IMHO.

`fill-region' does not respect `fill-paragraph-function' for the reasons
I do not understand.

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 19:01:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 14:01:22 2024
Received: from localhost ([127.0.0.1]:41095 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOjFy-00007v-F7
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:01:22 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:55480)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOjFw-0008QJ-CF
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 14:01:21 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOjFs-0007Za-4W; Sat, 13 Jan 2024 14:01:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=5wKgkPCRUw542TxPLKBxZS/P564ynCkjTxlMoLRJFyg=; b=PMgrSXFDJy7o
 fcLv/UeGROJk4BGBZR3237xiSowuL3Nqskq9DYqv5VvDthr9zswgB/yCQnGUXLzhsalekOd9Z5Le/
 6f0PrInLQUbF7URD/Z4J/WVZ4qVKThuHjExG4nYomhtHK5m1CVYXYG2o0eCRMUTUN72cJsskMjeDn
 goYqcb2F+LhgaBtTapYc8sfRzrqEHxVe/dlGbhzu9ywkan1mBZ6XfPEt39LqEL0ueWCt0n3Yve1gJ
 PfkZb8dZhnCOgfbKmt6FI8lcpB4jYqCGJc4v2VozZqOWKfDpAq5XDr3xC5p5FE2/DTcNDuTdG4xcN
 gtx3zjjdJcF9qihvnWQ0mw==;
Date: Sat, 13 Jan 2024 21:00:55 +0200
Message-Id: <83v87xf47s.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87wmsdt6zg.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 18:37:23 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN> <87wmsdt6zg.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
> Date: Sat, 13 Jan 2024 18:37:23 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> 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.

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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 18:34:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 13:34:17 2024
Received: from localhost ([127.0.0.1]:41060 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOipk-0002en-N8
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 13:34:17 -0500
Received: from mout01.posteo.de ([185.67.36.65]:41201)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOipi-0002eX-Rx
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 13:34:15 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id E6114240027
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 19:34:09 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705170849; bh=mT45aUU0LV/zJ20wbuka6zlSOb8Rf91P+y4Y6tAaVg4=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=SJluPlbsg1vZH7eaFG54prmIatL8fM9FeAe4G/2hFxLNW6a18hkFtbTRhjDqE2yH9
 aKgVTYu+I07uMZD6u/mhT60svej4Ymp6w4opd3RdhrDEmHSfvmIb2tA/af/3kU6BXB
 yrHNZAlLCQ1I3uZGMyOlJNfFKzx7QVcoqXD2ps4rBlqB1O9r+bHLtihmId9IpydwTD
 rcve71LsnTCmxhoMTIZWPOnK2S8oRNH9eOtnAHXl1eGQs8cPswc3EFwhphRTtnT46b
 QUDMq2Z6m+A9XbYNagyA6x3iBUysWALeEMCMUNsjzI7DFBahkEIaaJTEgqKn1SS9/A
 dilJgrecOestA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC6W50Q07z6twG;
 Sat, 13 Jan 2024 19:34:08 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <8334v1grai.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
 <877ckduudh.fsf@localhost> <8334v1grai.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 18:37:23 +0000
Message-ID: <87wmsdt6zg.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: rustand.lars@HIDDEN, 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> 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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 15:57:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 10:57:39 2024
Received: from localhost ([127.0.0.1]:40870 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOgOB-0002D5-2V
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:57:39 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:46246)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOgO9-0002Cp-9e
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:57:38 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOgO4-0007Zd-Gv; Sat, 13 Jan 2024 10:57:32 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=pdOrIQnqHbqNVcNGtBivhur+flB1PIY+SIDVR2QLEgM=; b=P1XYf19tkEfw
 0atGcmWY7KPJIgdSpqWd6V+fNQIn9scVeHbOIjWD5eWsYS68AmC6+zhG6gENgl8ldDi4Dev6Df8eN
 g4ytYa1RwgMCz3qf8GZbe+HTGPB3bMh1CbkdcihRiT4OM9ngE6SGeRf4O20gNVPdUGXlm/JSn1h3/
 y78UZnL69nPpYb9Qjc0HwW6wbcTMVvPh4NiaZCBXmyIiefeS9D3CjExzYGDpOXJ0jicWJhq30r8T8
 jaCSt9iQt1f8ht7euTvlZrYGKZCVIINqCEI4wmw12/XBlhawEIygmtlxhveLlThWziuXaky3+8prn
 dWOwXdBQkn0fMeqs+3i5DA==;
Date: Sat, 13 Jan 2024 17:57:09 +0200
Message-Id: <8334v1grai.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <877ckduudh.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 15:26:50 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN> <877ckduudh.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: rustand.lars@HIDDEN, salutis@HIDDEN, 68418 <at> debbugs.gnu.org
> Date: Sat, 13 Jan 2024 15:26:50 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > Is it possible that Org's fill-forward-paragraph-function needs some
> > improvements, btw?
> 
> May you please elaborate?
> Some improvements can be made most of the time, but you seem to have
> something specific in mind.

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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 15:23:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 10:23:44 2024
Received: from localhost ([127.0.0.1]:40848 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOfrM-0004C7-2r
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:23:44 -0500
Received: from mout02.posteo.de ([185.67.36.66]:55911)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOfrK-0004Br-E6
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:23:42 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id A0E43240105
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 16:23:37 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705159417; bh=9bXe/uxLZ0aJvRGoiiWERyaL3I2W05M4ZJFLZnH+a08=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=MvXNnbyWi8Yop++rCfIGmDNKFgyjfefvSKPVJvLIvThgZ5LmnJhwNfIPrtM8HFVK/
 gx5Im1pdSrfcEFWpMtmYe62iqTn6OUe6bYEBuxlkJ/c/ygJ9085YHXfj8bN7B3WBVv
 TcasRq+C/4/kuUlzY9l0LzkHYinjLEfQtAo1uS0rPxD++BThiYcW34gm+0P3QGcwvG
 i/wtqdz8lFVM946jx7cVCY011CiM+zhI3/jJt1xpcJlUKefKe+q/IpRrcSLpgCvHRe
 kk4eZkeGZx3SgNr9V0KCCY6pdHiV7pOvfXGeX2MqB/nrINhEWKZoxfvc8Frfv00sd3
 DKhh6AqNiO4fg==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC2HD6Jckz6tx7;
 Sat, 13 Jan 2024 16:23:36 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <834jfhgtb5.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
 <87frz1uyki.fsf@localhost> <834jfhgtb5.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 15:26:50 +0000
Message-ID: <877ckduudh.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> I believe that your patch is good - it improves the situation and makes
>> refill-mode more consistent with fill.el (by honouring
>> `fill-forward-paragraph-function').
>
> OK.
>
> Is it possible that Org's fill-forward-paragraph-function needs some
> improvements, btw?

May you please elaborate?
Some improvements can be made most of the time, but you seem to have
something specific in mind.

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 15:14:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 10:14:02 2024
Received: from localhost ([127.0.0.1]:40840 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOfhx-0001GO-LO
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:14:01 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48854)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOfhv-0001Ft-GH
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 10:14:00 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOfhr-000857-F8; Sat, 13 Jan 2024 10:13:55 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=UKjSbLOwipXrl5I7z7zn0W+GrnXffr7R5kbcdHNSstw=; b=OzGdD14pxzg3
 avlh6+o2DvtKbHCf1RFYc7ASoiYss7Ti70ZSzLe240wg26vB54097X7idQS4a8s538O3F7wwSffY0
 HzPQZOP/XKwpldhXukG0EA6VTE0av+9SD+AfO3PSf8VyRRIyiEd6lDUx+qTfj8JdNP5ug5PMZ1XDh
 q99MJrf8nlansr3/MkzYepj8uJX6su9layx6dFjMzVD5RhwX+TPQBjPro5EqSYX3BSU1zYMGPG0/a
 7lirK+nTyZDo2lQFXcUV8kKPY9h+RE7ybjQiDNLwUinHHHwVs9EkhcNGA29BBgwAv/SiMF5EtQrx2
 tBsvH86zce8zNtNcBFXzlA==;
Date: Sat, 13 Jan 2024 17:13:34 +0200
Message-Id: <834jfhgtb5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87frz1uyki.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 13:56:13 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN> <87frz1uyki.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: rustand.lars@HIDDEN, salutis@HIDDEN, 68418 <at> debbugs.gnu.org
> Date: Sat, 13 Jan 2024 13:56:13 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> 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:
> > ...
> > So you think the patch I posted should not be installed, and we should
> > wait for a more thorough solution?
> 
> I believe that your patch is good - it improves the situation and makes
> refill-mode more consistent with fill.el (by honouring
> `fill-forward-paragraph-function').

OK.

Is it possible that Org's fill-forward-paragraph-function needs some
improvements, btw?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 13:53:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 08:53:09 2024
Received: from localhost ([127.0.0.1]:38764 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOeRg-0002Ec-PT
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:53:09 -0500
Received: from mout01.posteo.de ([185.67.36.65]:38159)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOeRe-0002E6-5O
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:53:07 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 6F542240029
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 14:53:01 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705153981; bh=gne6E3UQ/NdDlfV0CdxDJxcBoNvhg5Ka716Ozauwth8=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=D/IXL+k9QSvAW/23PkH5QCUtm4gmEcIMY+kO2Nx3UBSjUDQB3xKsAzgIll78gh/7W
 ADiauJGFwFG99uCLBQ4vE7yjUoEzFcX3ASh82yoiqjOPwLncAHh1+Gy/ANqzy6+n9s
 hNVIf7CguFNj1rgwB3wkWqXhPDg2Ub6Mqp8MSLGJIVbA2yFgACeAazKgPVvlWBXZhF
 ia55CA1eDMguNNWSOOaRtid3BpdALiTKiSFIPYH7Et+UVUHffIGx+TuCnxQg2tBO2g
 9GYAojyyjyrqlx2AFDYHpjSpZlRk0D9QD1X40egYbNcwXNDqy7TjWcBaPVG2JduGQ7
 j9QIrWYW+uoEg==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TC0Gh4cvLz6tvl;
 Sat, 13 Jan 2024 14:53:00 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <835xzxgxhh.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost> <835xzxgxhh.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 13:56:13 +0000
Message-ID: <87frz1uyki.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> 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:
> ...
> So you think the patch I posted should not be installed, and we should
> wait for a more thorough solution?

I believe that your patch is good - it improves the situation and makes
refill-mode more consistent with fill.el (by honouring
`fill-forward-paragraph-function').

However, more general problem with fill.el design will remain. Although,
emacs-devel might be more suitable place to discuss the Emacs design -
see my other email - https://yhetil.org/emacs-devel/87frz5kux7.fsf@localhost/

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 13:44:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 08:44:09 2024
Received: from localhost ([127.0.0.1]:38755 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOeIz-0007iB-1K
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:44:09 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:33136)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOeIw-0007ha-J0
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:44:07 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOeIr-00033s-4F; Sat, 13 Jan 2024 08:44:01 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=GaqyxvTBSxfMa7lFXROmQFO0+kuXujxU9M6vjcGRm/Y=; b=MxWW+zpPfQiu6TiuzRTI
 dWdNdyv+i3HmXSZ8wKLwKdqLzoQfiSj/TlIjAM6GcoDkm97jsPVVRdgqAYpE5qCig4AUpRM4g2Xeb
 QH6ZG0NrOHaz4Yn6fMWklSls5jlETnhIB8D/MejUK7BR84XbZyzUH5Rq80lNZ1OVL9XMslFBA/pnC
 umcZm+hA2vk89T5ptxqkb98DsKDzvvCLdrtX7za7n/I3DBjYLysf049zichSYAK6do/8HibVxGH0z
 Pk6wVQLbuzF50TEE4MgD+Oldr75TYMWanpvnMAhtCN8sEwOU4dHr2mZp33+PbnYWTLsoh1rCc2oRb
 VvW5V0mBFHlpmg==;
Date: Sat, 13 Jan 2024 15:43:22 +0200
Message-Id: <835xzxgxhh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87mst9uzv3.fsf@localhost> (message from Ihor Radchenko on Sat,
 13 Jan 2024 13:28:16 +0000)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87mst9uzv3.fsf@localhost>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: salutis@HIDDEN, 68418 <at> debbugs.gnu.org, rustand.lars@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: Lars Rustand <rustand.lars@HIDDEN>, Rudolf Adamkovič
>  <salutis@HIDDEN>, 68418 <at> debbugs.gnu.org
> 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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 13:25:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 08:25:12 2024
Received: from localhost ([127.0.0.1]:38730 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOe0d-0004Z3-KH
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:25:12 -0500
Received: from mout01.posteo.de ([185.67.36.65]:46977)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1rOe0b-0004Yo-P1
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:25:10 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id C9B13240027
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 14:25:04 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705152304; bh=6NA5do6yWMLSznrHVuKbPnimNyKmIXr6O8h122hZ8i0=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=Bw620/QSQNFPoTdKcxLcmiBTMr3476qPqy09EH2NhbbFPvCYaAL8fka4oHMhp+7py
 FEJDkkvAaq00Dli4dtPkGSu8yOtc+mkebZ/HwCDWS/f/GmD0SUSr9Gpbxrr9LyGleS
 uEjbtajdsPIptDoB8zdNHN1Gl91hf1/guYlBj6FZu4vY432kMwkFtFBV4NC7qecusa
 nE0K9CMOLY71Vike99CWfK9PCHBdwJKP8kT1IyA1DWr2O9ZcjTmT2v4K2Pmj7aPFek
 AMjrA3Lqg6OQjOsliLQfmzKXfkP3hI+SBC1iOPJ+43KhxBlzfA/CdErtq9OEukpXyc
 21K/zUbeaO/lg==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TBzfS0Jzdz6txT;
 Sat, 13 Jan 2024 14:25:03 +0100 (CET)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
In-Reply-To: <83le8thchr.fsf@HIDDEN>
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
Date: Sat, 13 Jan 2024 13:28:16 +0000
Message-ID: <87mst9uzv3.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= <salutis@HIDDEN>, 68418 <at> debbugs.gnu.org,
 Lars Rustand <rustand.lars@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> > I did some debugging for refill-mode in Org.
>> > `refill-post-command-function' calls `refill-fill-paragraph-at', which
>> > not only ignores `fill-paragraph-function', but even
>> > `fill-forward-paragraph-function'. `forward-paragraph' is hard-coded,
>> > I consider to be a bug.
>> 
>> Let me bump this bug report.
>> AFAIU, it belongs to emacs.
>
> I now have second thoughts about this.  fill-paragraph-function is
> used by fill-paragraph, whereas refill.el calls
> fill-region-as-paragraph.  fill-region-as-paragraph cannot possibly
> call fill-paragraph-function, because the latter is not supposed to be
> able to fill more than a single paragraph.  The doc string of
> fill-paragraph-function actually says so:
>
>   (defvar fill-paragraph-function nil
>     "Mode-specific function to fill a paragraph, or nil if there is none.
>   If the function returns nil, then `fill-paragraph' does its normal work.
>   A value of t means explicitly \"do nothing special\".
>   Note: This only affects `fill-paragraph' and not `fill-region'
>   nor `auto-fill-mode', so it is often better to use some other hook,
>   such as `fill-forward-paragraph-function'.")
>
> Am I missing something?

No. This indeed makes sense.
`fill-paragraph-function' is not even passed the region to fill, so it
has no way to know what it is supposed to fill and should determine the
paragraph boundaries by itself.

> If my analysis is correct, then to move forward with this bug, we
> could either:
>
>   . add a fill-region-function, make fill-region-as-paragraph call it,
>     and then make Org set this function to something appropriate

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?

>   . modify refill.el to use fill-forward-paragraph-function instead of
>     a literal forward-paragraph
>
> I tried the latter (patch below), but I don't know if that gives
> good-enough results, as I don't use Org intensively enough, and
> certainly don't use refill-mode.  Can you try the patch below and
> report back?
>
> diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
> index 937a8ed..22f67bc 100644
> --- a/lisp/textmodes/refill.el
> +++ b/lisp/textmodes/refill.el
> @@ -106,10 +106,10 @@ refill-fill-paragraph-at
>      ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
>      ;; leading to excessive refilling and wrong choice of fill-prefix.
>      ;; might be a bug in my paragraphs.el.
> -    (forward-paragraph)
> +    (fill-forward-paragraph 1)
>      (skip-syntax-backward "-")
>      (let ((end (point))
> -	  (beg (progn (backward-paragraph) (point)))
> +	  (beg (progn (fill-forward-paragraph -1) (point)))

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'.

-- 
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>




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 09:16:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 04:16:56 2024
Received: from localhost ([127.0.0.1]:38384 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOa8N-0004vU-OF
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 04:16:56 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:55436)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rOa8M-0004ub-Ix
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 04:16:55 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOa8I-0000DN-PX; Sat, 13 Jan 2024 04:16:50 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=GzOqq+kKuLaP34Hmc/vyYpxFY77zMikV22c9KH7X0ok=; b=Jd38h7PtFItu3r9qzs6x
 9ZBiPGu+C7dGpk07cGX2VnrTkfSqYCdFTMPNVaswhJsJA5cZlNx86fjr6P8W30XDoTkk6eUnAel7H
 3P3jkkaBx4kjZb77E4nsyseQ5Qpi7emCXiy4nMjd00c1cpPMux+58guTSBGdHPDk/naS7EuMtdyH1
 vXJXuDv+JIykvYduTsMs8XOXLRgCHd0taxEGTigwzwXJJeodnllqyPP6U7m5cW0v9FssAOMlpn/+s
 Rwd3V/yaNTZ0ImOfo2R8o6fT3F1xDHMTcGPfJ1daJlg5bHd5hBp93yKCC3Z+9y1Iq5r56oPyikrdc
 JbAmN5g5rN2Otw==;
Date: Sat, 13 Jan 2024 11:16:14 +0200
Message-Id: <83h6jhh9up.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Lars Rustand <rustand.lars@HIDDEN>
In-Reply-To: <87edelr497.fsf@HIDDEN> (message from Lars Rustand on Sat, 13
 Jan 2024 10:01:27 +0100)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
 <87edelr497.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: 68418 <at> debbugs.gnu.org, salutis@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Lars Rustand <rustand.lars@HIDDEN>
> Cc: Rudolf Adamkovič <salutis@HIDDEN>
> Date: Sat, 13 Jan 2024 10:01:27 +0100
> 
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > I tried the latter (patch below), but I don't know if that gives
> > good-enough results, as I don't use Org intensively enough, and
> > certainly don't use refill-mode.  Can you try the patch below and
> > report back?
> 
> Thanks for the patch! This does indeed seem to have fixed the problems I
> was having. I don't really use Org very intensely myself, so there could
> be cases that I have missed.

Thanks for testing.  I will wait for Rudolf to chime in, and will
install this if no problems are reported with the patch.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 09:07:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 04:07:14 2024
Received: from localhost ([127.0.0.1]:38370 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOZyz-00020S-Vd
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 04:07:14 -0500
Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:56359)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rustand.lars@HIDDEN>) id 1rOZyw-00020C-7J
 for 68418 <at> debbugs.gnu.org; Sat, 13 Jan 2024 04:07:12 -0500
Received: by mail-lf1-x132.google.com with SMTP id
 2adb3069b0e04-50e9e5c97e1so9036978e87.0
 for <68418 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 01:07:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705136825; x=1705741625; darn=debbugs.gnu.org;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:from:to:cc:subject:date:message-id:reply-to;
 bh=NbOZFFP8eaysyzfWsmrD+fo2iTZwgfT5foE+ElR4GMA=;
 b=V1/LwXcuHGdD5C3+B5ebI34fhDyu+8EPLhbiUUS5BJ+SMf3urP1qfc2410xP/UI7FF
 PBB/oBOSJ88XVioeUrEyMrTetT6XQNDUGvXDy5TZJYyQbajXRkkleMjZHGyeRpf2b/kn
 /qw9m7RCi+QPEpbJxdjOO/swh6/7fHk2La7SC/U9PTbU8pOPHXIQBSkuxsEk8E65Db4g
 ktJqoyxEemb5A0yhj/Mghjmlnfc2LzXkGtjXw8nLXNrgR83Z1E/uXSmz6tSpe3XZr6VB
 TDasUfXyTlvVLwjV6BuJi5qWR6T9xvjkA9d9frDQkDKR2DboIYMI5UJvJDBU/tu2HQs6
 5mmQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705136825; x=1705741625;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=NbOZFFP8eaysyzfWsmrD+fo2iTZwgfT5foE+ElR4GMA=;
 b=ncCa/fBYXlWTlsjV8odb6Re0hWWEmsHdOP4pN4y4aLMcfgp6SFh3uRlOL24LOIvy9I
 KXuTJQJSeVHUkGFgwvZv5Q/oCVrIRydACayPgLrYGf6SkN3V6y2WGBtlGcq6FYfbgI4r
 S0hAu4bgVfIBgJarVcCLqA8m11f6AG296/uOW3JBocaJ4rZzZ6MDcirEXu+nAo4/Y0bu
 60/ucqSOfyFKRBY2FXr7oTu1a8c002T1mOcHfYKqOLnGJG6Soj3CNG/X5VYDit4VHPVa
 vIakzTKv0MLfujzW/lKTBUy8d4uI2U9tHzJqi0B/wg25yLdNgy0tOi2HAqjkbXDSvBnE
 Yjcg==
X-Gm-Message-State: AOJu0YwsArMTqbTyzKjPSLEJPi4G4Lla4PHgUPlpHYOktXsgU5pQT3Xh
 33CURYU2kydCvmyG3OBS15k=
X-Google-Smtp-Source: AGHT+IEW/mN/2n6RRvO/R8eolKZs7PDYKg7CXq+nC9zDDwl4mnmp9d82vjIWVX7CGQ/JHfF2z8ExBw==
X-Received: by 2002:a19:2d4a:0:b0:50e:6b1e:ff9d with SMTP id
 t10-20020a192d4a000000b0050e6b1eff9dmr1126841lft.30.1705136825275; 
 Sat, 13 Jan 2024 01:07:05 -0800 (PST)
Received: from localhost (78.79-160-60.customer.lyse.net. [79.160.60.78])
 by smtp.gmail.com with ESMTPSA id
 q30-20020ac2511e000000b0050e74317194sm771301lfb.146.2024.01.13.01.07.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 13 Jan 2024 01:07:04 -0800 (PST)
References: <87il3yqmkl.fsf@HIDDEN> <83le8thchr.fsf@HIDDEN>
User-agent: mu4e 1.10.8; emacs 30.0.50
From: Lars Rustand <rustand.lars@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, 68418 <at> debbugs.gnu.org
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
Date: Sat, 13 Jan 2024 10:01:27 +0100
In-reply-to: <83le8thchr.fsf@HIDDEN>
Message-ID: <87edelr497.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68418
Cc: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= <salutis@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Eli Zaretskii <eliz@HIDDEN> writes:

> I tried the latter (patch below), but I don't know if that gives
> good-enough results, as I don't use Org intensively enough, and
> certainly don't use refill-mode.  Can you try the patch below and
> report back?

Thanks for the patch! This does indeed seem to have fixed the problems I
was having. I don't really use Org very intensely myself, so there could
be cases that I have missed.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.
Merged 52778 68418. Request was from Eli Zaretskii <eliz@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 68418 <at> debbugs.gnu.org:


Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 08:19:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 03:19:40 2024
Received: from localhost ([127.0.0.1]:38350 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOZEy-00019j-9c
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 03:19:40 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48178)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>)
 id 1rOZEw-00019O-39; Sat, 13 Jan 2024 03:19:39 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rOZEs-0003kq-9f; Sat, 13 Jan 2024 03:19:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=iyatbh8FcedObEnmdpMp9bcQJUgTxkXn+FwINlBKOzw=; b=H8TWab/Pz6ZMrPR4BMXF
 oIvP52vDJIE0EdtQMMkhfgwV1wTUEr9S9Zhb7HBc57okNHAjetLMPznIAU+6QmBkX7XG3AwGFgJLk
 8miUz3ZSXLywWMhxscNnqYtVI346ATF48R5aDe2jxyfnIzfPVVn8UyVORFOqdPo6UK8AU7qEqq8ae
 jMFqWBVmgE3v65GnBbVouMA2OwzT8APB78hLQxgXPDg55bxHDnAvgd+jxq/AW57rxckZ/0QhxRYgL
 vs5AlWqmrgsp1RAyM/BH4qrdrByBVemYMCrFE9ztqdeYpvhel4Xc3+iRsyfh80FaOsCyBChcAE3pI
 LYTtecnrjPlstw==;
Date: Sat, 13 Jan 2024 10:19:12 +0200
Message-Id: <83le8thchr.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Lars Rustand <rustand.lars@HIDDEN>, Rudolf =?utf-8?Q?Adamkovi=C4=8D?=
 <salutis@HIDDEN>
In-Reply-To: <87il3yqmkl.fsf@HIDDEN> (message from Lars Rustand on Fri, 12
 Jan 2024 21:18:51 +0100)
Subject: Re: bug#68418: refill-mode interferes with org-mode headlines
References: <87il3yqmkl.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68418
Cc: 68418 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

merge 68418 52778
thanks

> From: Lars Rustand <rustand.lars@HIDDEN>
> Date: Fri, 12 Jan 2024 21:18:51 +0100
> 
> 
> Enabling refill-mode in an org-mode buffer results in unwanted behaviour
> that interferes with headlines, list items, and possibly other types of
> line breaks.
> 
> I won't go too deeply into describing it here as it has been described
> well in the following bug report on the org-mode mailing list. In that
> thread it was suggested that the bug is actually not in org-mode, but
> instead in refill-mode.
> 
> See the original bug report on the org-mode list here:
> 
> https://list.orgmode.org/orgmode/3715730.BJ41AJB0qc@yksi/
> 
> 
> I also found a previous thread on this list where it has been discussed:
> 
> https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-12/msg01854.html
> 
> It seems that the bug was located and the cause was identified, but
> nothing more came out of it.

If a bug isn't picked up by someone who wants or is capable of working
on it, and has time for that, that bug will not be fixed, indeed.
That's one of the downsides of a community-driven project that is
based on volunteers.

> The thread derailed quickly and it seems the problem was ignored because
> of personal problems against the author. The fact that some of his
> previous bug reports were done to the wrong list does not mean that this
> bug should be ignored.
> 
> I hope the issue can be taken seriously this time, because it renders
> refill-mode unusable in org-mode buffers.

This is at least inaccurate, and quite a bit unfair, I'd say: the
thread didn't "derail".  Once the nature of the original report was
established and seemed to point to a problem in refill.el, the
discussion indeed went to a tangent, but no one said that the original
report was invalid or incorrect, or that we don't want to take it
seriously, let alone because the OP had some problems.  It's just a
bug that no one kept working on it.  Which is unfortunate, but it does
happen, since we don't have a way of assigning bugs to developers and
making sure they do fix them.

Anyway, with these tangents aside, coming back to the original report
and its initial analysis by Ihor in bug#52778, viz.:

> > I did some debugging for refill-mode in Org.
> > `refill-post-command-function' calls `refill-fill-paragraph-at', which
> > not only ignores `fill-paragraph-function', but even
> > `fill-forward-paragraph-function'. `forward-paragraph' is hard-coded,
> > I consider to be a bug.
> 
> Let me bump this bug report.
> AFAIU, it belongs to emacs.

I now have second thoughts about this.  fill-paragraph-function is
used by fill-paragraph, whereas refill.el calls
fill-region-as-paragraph.  fill-region-as-paragraph cannot possibly
call fill-paragraph-function, because the latter is not supposed to be
able to fill more than a single paragraph.  The doc string of
fill-paragraph-function actually says so:

  (defvar fill-paragraph-function nil
    "Mode-specific function to fill a paragraph, or nil if there is none.
  If the function returns nil, then `fill-paragraph' does its normal work.
  A value of t means explicitly \"do nothing special\".
  Note: This only affects `fill-paragraph' and not `fill-region'
  nor `auto-fill-mode', so it is often better to use some other hook,
  such as `fill-forward-paragraph-function'.")

Am I missing something?

If my analysis is correct, then to move forward with this bug, we
could either:

  . add a fill-region-function, make fill-region-as-paragraph call it,
    and then make Org set this function to something appropriate
  . modify refill.el to use fill-forward-paragraph-function instead of
    a literal forward-paragraph

I tried the latter (patch below), but I don't know if that gives
good-enough results, as I don't use Org intensively enough, and
certainly don't use refill-mode.  Can you try the patch below and
report back?

diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
index 937a8ed..22f67bc 100644
--- a/lisp/textmodes/refill.el
+++ b/lisp/textmodes/refill.el
@@ -106,10 +106,10 @@ refill-fill-paragraph-at
     ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
     ;; leading to excessive refilling and wrong choice of fill-prefix.
     ;; might be a bug in my paragraphs.el.
-    (forward-paragraph)
+    (fill-forward-paragraph 1)
     (skip-syntax-backward "-")
     (let ((end (point))
-	  (beg (progn (backward-paragraph) (point)))
+	  (beg (progn (fill-forward-paragraph -1) (point)))
 	  (obeg (overlay-start refill-ignorable-overlay))
 	  (oend (overlay-end refill-ignorable-overlay)))
       (unless (> beg pos)      ;Don't fill if point is outside the paragraph.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Jan 2024 07:13:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 02:13:09 2024
Received: from localhost ([127.0.0.1]:38251 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOYCb-0002pd-1X
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 02:13:09 -0500
Received: from lists.gnu.org ([2001:470:142::17]:47748)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rustand.lars@HIDDEN>) id 1rOOtj-00015f-1l
 for submit <at> debbugs.gnu.org; Fri, 12 Jan 2024 16:17:04 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rustand.lars@HIDDEN>)
 id 1rOOte-0006ya-WD
 for bug-gnu-emacs@HIDDEN; Fri, 12 Jan 2024 16:16:59 -0500
Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <rustand.lars@HIDDEN>)
 id 1rOOtX-0001gN-LS
 for bug-gnu-emacs@HIDDEN; Fri, 12 Jan 2024 16:16:57 -0500
Received: by mail-lj1-x22a.google.com with SMTP id
 38308e7fff4ca-2cd5b467209so64794121fa.3
 for <bug-gnu-emacs@HIDDEN>; Fri, 12 Jan 2024 13:16:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705094207; x=1705699007; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:user-agent:from:to:cc
 :subject:date:message-id:reply-to;
 bh=V+wFiUs+iTN4qOW+MmxS1RpGU2nZyNPWQuQrCiBGo2I=;
 b=jQavRNU3G2pa5m1QFEzP2zVbebjn9ayDZUP0DiUcen/nUipprWD1v805JYng3rn1KQ
 nWj30jeYjtXtDP42VC5+MYU6LpXPGG8Kgiu3iiWbRA+2Gsla4ZwbuIrm2CK9n7n3sUH1
 8zZf052bNmDJVpljokRR++9UEXMz9YusOVQqxlaqMGFnzi+3ZIhn2v6kqCQ44mJflM/9
 VeyNW7ndGSjvx5b5O3lFT2pSV8+ztU/5xZwe4e7ZY11Ga5WmO7zYyGG9TVjNBlVnCrhi
 SWFbwBYLqKFI7GJFVk2qQI8arVy8RZUz7rxFSyhECtVXfYYLuh4JHRHajxfXoblRBE2u
 uyLg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705094207; x=1705699007;
 h=mime-version:message-id:date:subject:to:from:user-agent
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=V+wFiUs+iTN4qOW+MmxS1RpGU2nZyNPWQuQrCiBGo2I=;
 b=FOXrDCIEZy8vY/vIaLFz5Gf0ag++8r1z72HQfBclJlJGDmuhctwfXcliOggYPWL00E
 3Vug26i0zd8ltX3b4cG5paeqvQcVmXwtsnqvu+oG1Dinz0tZyCgR3w5m3NG2KsSv/00O
 Y/9/EpuvNpSACbUb+1o1nK8AP77k6VY4+fzhdu/4bgzOzBv0fx6qloEhkIF/FUr7XyUX
 mwVQDVITrNyWwoCOUIo+A0qF3Hg7jyjeiHiyrdrHDcAPNy/eboUbfoveqUGSFOu+Qp69
 9k3KVtBajcLmpveSkxY+Kp1l5Wrttdv+Z5+uMOXbxPwDRtGPklyXEYFQmnswiHTt+zoY
 M7EA==
X-Gm-Message-State: AOJu0YxLJU3vgAun0yinJrpa+mx8QYBNr+8hNFCtR04pTXbaZ7hnG1Pe
 uFnsaBtr440jouAq3bTQkTIXMBYWeFg=
X-Google-Smtp-Source: AGHT+IGl2jsamGKGDuJn7rQVDvN3CyYanql2Mtu8TannjahptxYryKokpFPb2SE/nx5MgkmV0A8zkQ==
X-Received: by 2002:a2e:9cc1:0:b0:2cd:7831:3ca2 with SMTP id
 g1-20020a2e9cc1000000b002cd78313ca2mr953463ljj.84.1705094207481; 
 Fri, 12 Jan 2024 13:16:47 -0800 (PST)
Received: from localhost (78.79-160-60.customer.lyse.net. [79.160.60.78])
 by smtp.gmail.com with ESMTPSA id
 m14-20020a2ea58e000000b002cd51dfe317sm574563ljp.117.2024.01.12.13.16.46
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 12 Jan 2024 13:16:47 -0800 (PST)
User-agent: mu4e 1.10.8; emacs 30.0.50
From: Lars Rustand <rustand.lars@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: refill-mode interferes with org-mode headlines
Date: Fri, 12 Jan 2024 21:18:51 +0100
Message-ID: <87il3yqmkl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2a00:1450:4864:20::22a;
 envelope-from=rustand.lars@HIDDEN; helo=mail-lj1-x22a.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 13 Jan 2024 02:13:05 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Enabling refill-mode in an org-mode buffer results in unwanted behaviour
that interferes with headlines, list items, and possibly other types of
line breaks.

I won't go too deeply into describing it here as it has been described
well in the following bug report on the org-mode mailing list. In that
thread it was suggested that the bug is actually not in org-mode, but
instead in refill-mode.

See the original bug report on the org-mode list here:

https://list.orgmode.org/orgmode/3715730.BJ41AJB0qc@yksi/


I also found a previous thread on this list where it has been discussed:

https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-12/msg01854.html

It seems that the bug was located and the cause was identified, but
nothing more came out of it.

The thread derailed quickly and it seems the problem was ignored because
of personal problems against the author. The fact that some of his
previous bug reports were done to the wrong list does not mean that this
bug should be ignored.

I hope the issue can be taken seriously this time, because it renders
refill-mode unusable in org-mode buffers.




Acknowledgement sent to Lars Rustand <rustand.lars@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#68418; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.