Subject: Re: bug#56796: 29.0.50; Hard newlines not respected in code comments?

From: Eli Zaretskii <[email-masked]>
Date: Thu, 28 Jul 2022 10:26:46 +0300

> From: Visuwesh <[email-masked]>
> Date: Wed, 27 Jul 2022 21:19:29 +0530
> 
> Are hard newlines supposed to be respected when they are in code
> comments?

The answer is "it depends", AFAICS.

The main problem is that fill-comment-paragraph doesn't seem to honor
use-hard-newlines.  So any major mode whose fill-paragraph-function
uses that for filling comments will fail to pay attention to hard
newlines in comments.  In your scenario, if I set both
fill-paragraph-function and fill-paragraph-handle-comment to nil, hard
newlines in comments are honored as expected.

use-hard-newlines is weird: it is documented only for Enriched mode,
but that is at least incomplete, because we call functions from
fill.el high and low in many major modes, so at least some of them
inherit the use-hard-newlines-specific code when they call functions
which do.  For example, AFAICT use-hard-newlines is supported in Lisp
doc strings.

Adding Stefan to CC, who write fill-comment-paragraph.  If we want
use-hard-newlines to be supported in comments, we should modify
fill-comment-paragraph to honor it in some way, perhaps simply
deferring to fill-region in that case.