GNU bug report logs - #78561
[PATCH] Add semantic linefeed support for paragraph filling

Previous Next

Package: emacs;

Reported by: Roi Martin <jroi.martin <at> gmail.com>

Date: Fri, 23 May 2025 09:59:02 UTC

Severity: normal

Tags: patch

Full log


Message #32 received at 78561 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Roi Martin <jroi.martin <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Marcin Borkowski <mbork <at> mbork.pl>,
 78561 <at> debbugs.gnu.org
Subject: Re: bug#78561: [PATCH] Add semantic linefeed support for paragraph
 filling
Date: Tue, 27 May 2025 12:36:10 -0400
>> Yes, I've had this in my TODO for many years.  🙁
> I'll try to implement it :)

For some definition of "it".

>>> So, do we really want a specific `fill-region-semlf' function?
>> Actually, I think I want a `fill-region-as-paragraph-semlf'.
>> And maybe then some way to tell the `fill.el` code to use that instead
>> of the default `fill-region-as-paragraph`.
> OK, so here is my plan:

That plan has a much larger scope than semantic linefeed, so
I recommend you first finish the current patch and take on that
plan afterwards.
What I'm asking is a fairly small refactoring of the code you sent,
I think.

> First, I'll give a closer look to all the "fill" functions that Emacs
> currently provides to understand how every thing fits together and what
> is and what is not already supported.

Sounds good.  I can give you a quick summary of what I know.
`fill-paragraph-function`s usually serve as either:

- Some way for the major mode to teach the fill code how to stay within
  a major-mode-specific notion of paragraph (e.g. fill within comments
  or within strings).  This use has made somewhat obsolete by
  `fill-paragraph-forward-function` but it's still pretty common.

- Some way for the major mode to teach the fill code about special
  line-wrapping conventions (e.g. add a trailing \ on the previous line
  to fill C strings, add a leading SPC or TAB to fill rfc822 headers,
  ..) or to fine tune (adaptive-)fill-prefix.

- Actually change where we break lines for example to fill code in
  a "smart" way (like `smie-auto-fill` does).

- It can also be used to prevent filling in some parts
  (e.g. titles/headlines).

> Then, I'll send a new patch to support applying a
> `fill-paragraph-function' on a region "as-paragraph" (similar to the
> behavior of `fill-region-as-paragraph') and "per-paragraph" (similar to
> executing `fill-paragraph' for each paragraph within the region).

I think in general these are impossible because we don't know what the
`fill-paragraph-function` actually does.  My TODO is instead to provide
different hooks for the above different uses (some hooks already exist
such as `comment-line-break-function` but often they need to be
generalized) to try and make `fill-paragraph-function` effectively
obsolete (without necessarily marking it officially as obsolete).


        Stefan





This bug report was last modified 10 days ago.

Previous Next


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