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>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

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





This bug report was last modified 54 days ago.

Previous Next


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