From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#68418: refill-mode interferes with org-mode headlines Date: Sat, 13 Jan 2024 10:19:12 +0200 Message-ID: <83le8thchr.fsf@gnu.org> References: <87il3yqmkl.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1726"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68418@debbugs.gnu.org To: Lars Rustand , Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 13 09:20:28 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOZFj-0000Ar-F5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Jan 2024 09:20:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOZFN-0004KR-31; Sat, 13 Jan 2024 03:20:05 -0500 Original-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 ) id 1rOZFL-0004K5-Pa for bug-gnu-emacs@gnu.org; Sat, 13 Jan 2024 03:20:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOZFL-00045F-Dy for bug-gnu-emacs@gnu.org; Sat, 13 Jan 2024 03:20:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rOZFJ-0001AY-Kq for bug-gnu-emacs@gnu.org; Sat, 13 Jan 2024 03:20:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Jan 2024 08:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68418 X-GNU-PR-Package: emacs Original-Received: via spool by 68418-submit@debbugs.gnu.org id=B68418.17051339804453 (code B ref 68418); Sat, 13 Jan 2024 08:20:01 +0000 Original-Received: (at 68418) by debbugs.gnu.org; 13 Jan 2024 08:19:40 +0000 Original-Received: from localhost ([127.0.0.1]:38350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOZEy-00019j-9c for submit@debbugs.gnu.org; Sat, 13 Jan 2024 03:19:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48178) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOZEw-00019O-39; Sat, 13 Jan 2024 03:19:39 -0500 Original-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 ) 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==; In-Reply-To: <87il3yqmkl.fsf@gmail.com> (message from Lars Rustand on Fri, 12 Jan 2024 21:18:51 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278101 Archived-At: merge 68418 52778 thanks > From: Lars Rustand > 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.