Subject: bug#78561: [PATCH] Add semantic linefeed support for paragraph filling

From: Roi Martin <[email-masked]>
Date: Sat, 24 May 2025 14:15:37 +0200

Eli Zaretskii <[email-masked]> writes:

>> +(defun fill-paragraph-semlf (&optional justify)
>> +  "Fill paragraph at or after point using semantic linefeeds.
>> +
>> +This function ensures that a newline character follows every
>> +sentence, as punctuated by a period (.), exclamation mark (!), or
>> +question mark (?).
>
> This explanation of what is "semantic linefeeds" is a good starting
> point, but it is not enough.  For starters, "ensures" hints but
> doesn't say explicitly that if there's no newline there, it is
> inserted.  Also, I think a URL to at least one site explaining what
> "semantic linefeeds" are should be in the doc string.

I would prefer to avoid depending on external URLs to explain the
concept.  I'd link to an external reference if, for instance, this
feature was backed by an standard located in a well-known site
(e.g. IETF RFCs).  In this case, the concept is quite simple and I agree
with Stefan in that we can provide our own interpretation in the manual
and link to the Info node from the doc string.  If you prefer to avoid
changing the manual until this is well tested, then we can provide a
more detailed explanation in the doc string itself.  What do you think?

>> +	  (when (and (> (point) (line-beginning-position))
>> +		     (< (point) (line-end-position)))
>> +	    (delete-horizontal-space)
>> +	    (newline)
>
> Are you sure 'newline' is the right function to call here?  It doesn't
> just insert the newline character, at least not in all the cases.
> Perhaps inserting a literal newline character is better?

The reason behind using 'newline' is to support documents that follow
other conventions to represent newlines (e.g. '\r\n' or '\r').  Does it
make sense?  Is this the right approach?