GNU bug report logs - #78927
[PATCH] Update `fill-region-as-paragraph-semlf' to follow fill.el protocols

Previous Next

Package: emacs;

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

Date: Mon, 30 Jun 2025 11:11:01 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

To reply to this bug, email your comments to 78927 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Mon, 30 Jun 2025 11:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Roi Martin <jroi.martin <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Mon, 30 Jun 2025 11:11:02 GMT) Full text and rfc822 format available.

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

From: Roi Martin <jroi.martin <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Update `fill-region-as-paragraph-semlf' to follow fill.el
 protocols
Date: Mon, 30 Jun 2025 13:09:57 +0200
[Message part 1 (text/plain, inline)]
Tags: patch

This patch updates the `fill-region-as-paragraph-semlf' function to
follow the `fill-region-as-paragraph-function' protocol.  This allows to
delete the `fill-paragraph-semlf' function, which is replaced by
`fill-paragraph' combined with assigning
`fill-region-as-paragraph-semlf' to `fill-region-as-paragraph-function'.

Stefan, I also took the opportunity to remove the `with-restriction'
call from `fill-region-as-paragraph-semlf', as discussed in:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78561#47

Given that `fill-paragraph-semlf' is not part of any stable release of
GNU Emacs, I guess it is fine to remove it.  Is this a fair assumption?

        Roi

[0001-Update-fill-region-as-paragraph-semlf-to-follow-fill.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Mon, 30 Jun 2025 14:43:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Roi Martin <jroi.martin <at> gmail.com>
Cc: 78927 <at> debbugs.gnu.org, eliz <at> gnu.org
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Mon, 30 Jun 2025 10:42:34 -0400
> This patch updates the `fill-region-as-paragraph-semlf' function to
> follow the `fill-region-as-paragraph-function' protocol.  This allows to
> delete the `fill-paragraph-semlf' function, which is replaced by
> `fill-paragraph' combined with assigning
> `fill-region-as-paragraph-semlf' to `fill-region-as-paragraph-function'.
>
> Stefan, I also took the opportunity to remove the `with-restriction'
> call from `fill-region-as-paragraph-semlf', as discussed in:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78561#47
>
> Given that `fill-paragraph-semlf' is not part of any stable release of
> GNU Emacs, I guess it is fine to remove it.  Is this a fair assumption?

Thanks.  This looks good to me.  See minor comments below.
Eli?


        Stefan


> `fill-region-as-paragraph-function' protocol.  This allows to delete the
> `fill-paragraph-semlf' function, which is replaced by `fill-paragraph'

[ I was taught that `allow` is a transitive verb so the above is
  apparently grammatically incorrect.  You need "This allows *us* ...",
  "This allows deleting ...", or ...  ]

> Remove call to `with-restriction'.

"Avoid narrowing"?

> +    (let ((fill-column (point-max)))
> +      (setq pfx (or (save-excursion
> +                      (fill-region-as-paragraph-default (point)
> +                                                        (marker-position to)
> +                                                        nil
> +                                                        nosqueeze
> +                                                        squeeze-after))
> +                    "")))
> +    (while (< (point) (marker-position to))
> +      (let ((fill-prefix pfx))
> +	(fill-region-as-paragraph-default (point)
> +				          (min (marker-position to)
> +                                               (save-excursion
> +                                                 (forward-sentence)
> +                                                 (point)))
> +				          justify
> +                                          t))
> +      (when (and (> (point) (line-beginning-position))
> +		 (< (point) (line-end-position))
> +                 (< (point) (marker-position to)))
> +	(delete-horizontal-space)
> +	(insert "\n")
> +	(insert pfx)))
>      pfx))

I believe you can remove all the `marker-position` calls above since
markers are automatically coerced to integers when needed.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Mon, 30 Jun 2025 15:52:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Roi Martin <jroi.martin <at> gmail.com>
Cc: 78927 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Mon, 30 Jun 2025 18:50:28 +0300
> Cc: monnier <at> iro.umontreal.ca, eliz <at> gnu.org
> From: Roi Martin <jroi.martin <at> gmail.com>
> Date: Mon, 30 Jun 2025 13:09:57 +0200
> 
> This patch updates the `fill-region-as-paragraph-semlf' function to
> follow the `fill-region-as-paragraph-function' protocol.  This allows to
> delete the `fill-paragraph-semlf' function, which is replaced by
> `fill-paragraph' combined with assigning
> `fill-region-as-paragraph-semlf' to `fill-region-as-paragraph-function'.

fill-paragraph-semlf is a command.  Removing it means that there will
be no way for users to fill a paragraph interactively using semantic
linefeeds.  How much time will pass, do you think, before someone asks
for such a command?

The changes in this patch allow you to make fill-paragraph-semlf a
very thin wrapper around fill-paragraph, but that is still many times
more convenient than asking users to assign obscure values to obscure
variables.

So I suggest to leave the command, just reimplement it using
fill-region-as-paragraph-function.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Mon, 30 Jun 2025 15:53:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 78927 <at> debbugs.gnu.org, jroi.martin <at> gmail.com
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Mon, 30 Jun 2025 18:51:49 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: 78927 <at> debbugs.gnu.org,  eliz <at> gnu.org
> Date: Mon, 30 Jun 2025 10:42:34 -0400
> 
> > This patch updates the `fill-region-as-paragraph-semlf' function to
> > follow the `fill-region-as-paragraph-function' protocol.  This allows to
> > delete the `fill-paragraph-semlf' function, which is replaced by
> > `fill-paragraph' combined with assigning
> > `fill-region-as-paragraph-semlf' to `fill-region-as-paragraph-function'.
> >
> > Stefan, I also took the opportunity to remove the `with-restriction'
> > call from `fill-region-as-paragraph-semlf', as discussed in:
> >
> > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78561#47
> >
> > Given that `fill-paragraph-semlf' is not part of any stable release of
> > GNU Emacs, I guess it is fine to remove it.  Is this a fair assumption?
> 
> Thanks.  This looks good to me.  See minor comments below.
> Eli?

I'm okay with this, but I think we should not delete the command, see
my other message.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Mon, 30 Jun 2025 18:39:01 GMT) Full text and rfc822 format available.

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

From: Roi Martin <jroi.martin <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 78927 <at> debbugs.gnu.org
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Mon, 30 Jun 2025 20:38:06 +0200
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Thanks.  This looks good to me.  See minor comments below.
>> Eli?
>
> I'm okay with this, but I think we should not delete the command, see
> my other message.

I've attached a new version of the patch.  It addresses Stefan's
comments and reimplements the `fill-paragraph-semlf' function using
`fill-paragraph' and `fill-region-as-paragraph-function'.

        Roi

[0001-Update-fill-region-as-paragraph-semlf-to-follow-fill.patch (text/x-patch, attachment)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 30 Jun 2025 21:35:02 GMT) Full text and rfc822 format available.

Notification sent to Roi Martin <jroi.martin <at> gmail.com>:
bug acknowledged by developer. (Mon, 30 Jun 2025 21:35:02 GMT) Full text and rfc822 format available.

Message #22 received at 78927-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Roi Martin <jroi.martin <at> gmail.com>
Cc: 78927-done <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Mon, 30 Jun 2025 17:34:06 -0400
> I've attached a new version of the patch.  It addresses Stefan's
> comments and reimplements the `fill-paragraph-semlf' function using
> `fill-paragraph' and `fill-region-as-paragraph-function'.

Thanks, pushed,


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Tue, 01 Jul 2025 07:06:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Roi Martin <jroi.martin <at> gmail.com>
Cc: 78927 <at> debbugs.gnu.org, eliz <at> gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Tue, 01 Jul 2025 09:57:07 +0300
> Given that `fill-paragraph-semlf' is not part of any stable release of
> GNU Emacs, I guess it is fine to remove it.  Is this a fair assumption?

Thanks, now I tried to change this setting in .dir-locals.el:

  (fill-paragraph-function . fill-paragraph-semlf)

to

  (fill-region-as-paragraph-function . fill-region-as-paragraph-semlf)

and everything works nicely with the default keybinding 'M-q'.

Shouldn't this way of enabling the new feature be mentioned in etc/NEWS?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Tue, 01 Jul 2025 08:45:03 GMT) Full text and rfc822 format available.

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

From: Roi Martin <jroi.martin <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78927 <at> debbugs.gnu.org, eliz <at> gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Tue, 01 Jul 2025 10:44:11 +0200
Juri Linkov <juri <at> linkov.net> writes:

> Thanks, now I tried to change this setting in .dir-locals.el:
>
>   (fill-paragraph-function . fill-paragraph-semlf)
>
> to
>
>   (fill-region-as-paragraph-function . fill-region-as-paragraph-semlf)
>
> and everything works nicely with the default keybinding 'M-q'.

I'm glad to hear that!

> Shouldn't this way of enabling the new feature be mentioned in etc/NEWS?

I think so.  I plan to send a new patch that updates the etc/NEWS file
and also adds a small section about semantic-linefeed filling to the GNU
Emacs manual.  Something similar to what is described here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78561#5

But also explaining how to do it in Emacs.  That will allow us to use
the manual as reference in the doc strings of the semlf functions.

        Roi




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78927; Package emacs. (Thu, 03 Jul 2025 06:53:03 GMT) Full text and rfc822 format available.

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

From: Roi Martin <jroi.martin <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78927 <at> debbugs.gnu.org, eliz <at> gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#78927: [PATCH] Update `fill-region-as-paragraph-semlf' to
 follow fill.el protocols
Date: Thu, 03 Jul 2025 08:51:58 +0200
Roi Martin <jroi.martin <at> gmail.com> writes:

>> Shouldn't this way of enabling the new feature be mentioned in etc/NEWS?
>
> I think so.  I plan to send a new patch that updates the etc/NEWS file
> and also adds a small section about semantic-linefeed filling to the GNU
> Emacs manual.

For now I created Bug#78949 that updates etc/NEWS.

        Roi




This bug report was last modified 3 days ago.

Previous Next


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