GNU bug report logs - #50840
28.0.50; Support GNU style of multiline comments in C source code

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Eli Zaretskii <eliz@HIDDEN>; dated Mon, 27 Sep 2021 07:57:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 50840 <at> debbugs.gnu.org:


Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 17:30:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 29 13:30:47 2021
Received: from localhost ([127.0.0.1]:50106 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mVdPq-00069J-MR
	for submit <at> debbugs.gnu.org; Wed, 29 Sep 2021 13:30:47 -0400
Received: from colin.muc.de ([193.149.48.1]:51416 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1mVdPo-000615-DL
 for 50840 <at> debbugs.gnu.org; Wed, 29 Sep 2021 13:30:45 -0400
Received: (qmail 47827 invoked by uid 3782); 29 Sep 2021 17:30:37 -0000
Received: from acm.muc.de (p4fe15c83.dip0.t-ipconnect.de [79.225.92.131])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 29 Sep 2021 19:30:37 +0200
Received: (qmail 20858 invoked by uid 1000); 29 Sep 2021 17:30:37 -0000
Date: Wed, 29 Sep 2021 17:30:37 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code
Message-ID: <YVSivQuhqgPOmZ56@ACM>
References: <837df2moym.fsf@HIDDEN> <YVIPButhDTcjBE1S@ACM>
 <83ee99lum6.fsf@HIDDEN> <YVRILZZbAVhD6pby@ACM>
 <jwvsfxnvb44.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <jwvsfxnvb44.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50840
Cc: Eli Zaretskii <eliz@HIDDEN>, 50840 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Wed, Sep 29, 2021 at 08:08:43 -0400, Stefan Monnier wrote:
> > OK.  Here's a provisional patch to lisp/newcomment.el that tries to fix
> > the two spaces at the end of a sentence issue.  I haven't got anywhere
> > with the main bug, yet.

> Thanks, Alan.  This looks good.
> Only one request: could you put the bulk of the new code into a separate function?
> I'll see about the "main bug" ASAP,

How about the patch below?  It's not perfect - the move-to-column might
insert a tab at EOL, which will then be the Wrong Thing after the
function inserts the comment opener at the left margin.  Or something
like that.  Maybe we should bind indent-tabs-mode to nil around  the
move-to-column.

I'll leave the "main bug" to you, then.



diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index b458f0356d..5e8691890d 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1124,6 +1124,27 @@ comment-add
       (* comment-add 1)
     (1- (prefix-numeric-value arg))))
 
+(defun comment--sentence-spaces (c-end)
+  "Add spaces at EOL in a comment if needed for an end of sentence.
+C-END, a string, is the comment ender for the current line.  When
+called, point must be at the end of the line, and will be left
+at the possibly changed EOL at the end of this function."
+  (let (extra-spaces eos-col)
+    (setq extra-spaces
+          (and (save-excursion
+                 (skip-chars-backward "  \t")
+                 (setq eos-col (current-column))
+                 (or (bolp) (backward-char))
+                 (looking-at (sentence-end)))
+               (max (- (if sentence-end-double-space 2 1)
+                       (- (current-column) eos-col)
+                       (progn
+                         (string-match "^[  \t]*" c-end)
+                         (match-end 0))) ; # spaces in ce/cce.
+                    0)))
+  (when (and extra-spaces (> extra-spaces 0))
+    (move-to-column (+ (current-column) extra-spaces) t))))
+
 (defun comment-region-internal (beg end cs ce
                                 &optional ccs cce block lines indent)
   "Comment region BEG .. END.
@@ -1174,6 +1195,8 @@ comment-region-internal
 		(unless (looking-at "[ \t]*$")
 		  (setq min-indent (min min-indent (current-indentation))))
 		(end-of-line)
+                (let ((c-end (if (eobp) ce cce)))
+                  (if c-end (comment--sentence-spaces c-end)))
 		(setq max-indent (max max-indent (current-column)))
 		(not (or (eobp) (progn (forward-line) nil)))))



>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.

Message received at 50840 <at> debbugs.gnu.org:


Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 12:08:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 29 08:08:53 2021
Received: from localhost ([127.0.0.1]:48017 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mVYOL-0006Sz-Fl
	for submit <at> debbugs.gnu.org; Wed, 29 Sep 2021 08:08:53 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45964)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1mVYOJ-0006Sf-Hs
 for 50840 <at> debbugs.gnu.org; Wed, 29 Sep 2021 08:08:52 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1B7CA440615;
 Wed, 29 Sep 2021 08:08:46 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0C6DA4406CB;
 Wed, 29 Sep 2021 08:08:45 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1632917325;
 bh=aZaWTWnScKfKe5gFebqx0He8PUNvFj6TCeF7EXhuLWQ=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=iY6nOQXSUUskN1fCNcblA8htVoXAGMR5jw++Qv3zqL+A/zNrg4rjziij7xoDb92RL
 Itui/QZJTK2/foXTatqS7kYak2dH9F5C/6f3+wSeizF7qCsmKQZ0I4VLB98/u9cCYJ
 jL3BNSgECfyvw3bLVuk/0gl78insqE+glWZTx7wduYAxr6Whhes05T7l7RWMpmiIIO
 Dx6Q8T/jA/zsA2nzwx28s+379Mh/1dBh7j5wHFmHw3VGMm2YpbUFqv+1IFcsE+Dfm/
 MDnKxCaolnsEmTVSCM+KPHx8xfuYh2TrTcuM/hRAqctk99KHYn682N9KYTheI+W6Mp
 +hS7GlvmyPEOg==
Received: from milanesa (unknown [45.72.241.23])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C6DF512001E;
 Wed, 29 Sep 2021 08:08:44 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code
Message-ID: <jwvsfxnvb44.fsf-monnier+emacs@HIDDEN>
References: <837df2moym.fsf@HIDDEN> <YVIPButhDTcjBE1S@ACM>
 <83ee99lum6.fsf@HIDDEN> <YVRILZZbAVhD6pby@ACM>
Date: Wed, 29 Sep 2021 08:08:43 -0400
In-Reply-To: <YVRILZZbAVhD6pby@ACM> (Alan Mackenzie's message of "Wed, 29 Sep
 2021 11:04:13 +0000")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.004 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50840
Cc: Eli Zaretskii <eliz@HIDDEN>, 50840 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> OK.  Here's a provisional patch to lisp/newcomment.el that tries to fix
> the two spaces at the end of a sentence issue.  I haven't got anywhere
> with the main bug, yet.

Thanks, Alan.  This looks good.
Only one request: could you put the bulk of the new code into a separate function?
I'll see about the "main bug" ASAP,


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.

Message received at 50840 <at> debbugs.gnu.org:


Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 11:04:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 29 07:04:24 2021
Received: from localhost ([127.0.0.1]:47868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mVXNw-0006eA-11
	for submit <at> debbugs.gnu.org; Wed, 29 Sep 2021 07:04:24 -0400
Received: from colin.muc.de ([193.149.48.1]:41797 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1mVXNt-0006dt-D2
 for 50840 <at> debbugs.gnu.org; Wed, 29 Sep 2021 07:04:22 -0400
Received: (qmail 79922 invoked by uid 3782); 29 Sep 2021 11:04:14 -0000
Received: from acm.muc.de (p4fe15c83.dip0.t-ipconnect.de [79.225.92.131])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 29 Sep 2021 13:04:14 +0200
Received: (qmail 18862 invoked by uid 1000); 29 Sep 2021 11:04:13 -0000
Date: Wed, 29 Sep 2021 11:04:13 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code
Message-ID: <YVRILZZbAVhD6pby@ACM>
References: <837df2moym.fsf@HIDDEN> <YVIPButhDTcjBE1S@ACM>
 <83ee99lum6.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <83ee99lum6.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50840
Cc: monnier@HIDDEN, 50840 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Mon, Sep 27, 2021 at 21:51:45 +0300, Eli Zaretskii wrote:
> > Date: Mon, 27 Sep 2021 18:35:50 +0000
> > Cc: 50840 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>,
> >   acm@HIDDEN
> > From: Alan Mackenzie <acm@HIDDEN>

> > > Is this true?  If so, a feature request: add a style to support that.
> > > If such a style already exists, please clarify the documentation so that
> > > users could understand which style does that.

> > > And one more nit: Can the 'comment-end' inserted after the end of a
> > > comment please keep _two_ spaces after the period that ends the last
> > > line of a comment?  Or at least heed the setting of
> > > 'sentence-end-double-space'?

> > Are we talking about C-c C-c (aka M-x comment-region) here?

> Yes, my use case, and the context in which I filed the bug report, was
> "C-c C-c".  Not only for the 2 spaces issue, but also for the comment
> style.

> > This command currently inserts comment-end (in C Mode, " */") at the
> > end of each line being commented, which will leave a single space
> > between what was the last "." on the line and the "*/".

> > We could surely check for an end of sentence character at EOL here, and
> > if we've got one, check that at least two spaces are left.  This again
> > would be something for lisp/newcomment.el.

> Probably.  That''s why Stefan was CC'ed as well.

OK.  Here's a provisional patch to lisp/newcomment.el that tries to fix
the two spaces at the end of a sentence issue.  I haven't got anywhere
with the main bug, yet.



diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index b458f0356d..8865613383 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1162,7 +1162,8 @@ comment-region-internal
       (unless (or ce-sanitized (eolp)) (insert "\n") (indent-according-to-mode))
       (comment-with-narrowing beg end
 	(let ((min-indent (point-max))
-	      (max-indent 0))
+	      (max-indent 0)
+              ceeee extra-spaces eos-col)
 	  (goto-char (point-min))
 	  ;; Quote any nested comment marker
 	  (comment-quote-nested comment-start comment-end nil)
@@ -1174,6 +1175,25 @@ comment-region-internal
 		(unless (looking-at "[ \t]*$")
 		  (setq min-indent (min min-indent (current-indentation))))
 		(end-of-line)
+                ;; Do we need extra spaces at an end of sentence?
+                (setq ceeee (if (eobp) ce cce))
+                (setq extra-spaces
+                      (and ceeee
+                           (save-excursion
+                             (skip-chars-backward "  \t")
+                             (setq eos-col (current-column))
+                             (or (bolp) (backward-char))
+                             (looking-at (sentence-end)))
+                           (max (- (if sentence-end-double-space 2 1)
+                                   (- (current-column) eos-col)
+                                   (if ceeee
+                                       (progn
+                                         (string-match "^[  \t]*" ceeee)
+                                         (match-end 0)) ; # spaces in ce/cce.
+                                     0))
+                                0)))
+                (when (and extra-spaces (> extra-spaces 0))
+                  (move-to-column (+ (current-column) extra-spaces) t))
 		(setq max-indent (max max-indent (current-column)))
 		(not (or (eobp) (progn (forward-line) nil)))))
 

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.

Message received at 50840 <at> debbugs.gnu.org:


Received: (at 50840) by debbugs.gnu.org; 27 Sep 2021 18:51:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 14:51:51 2021
Received: from localhost ([127.0.0.1]:42862 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mUvjD-0001Dg-5k
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2021 14:51:51 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43884)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mUvjB-0001DT-I3
 for 50840 <at> debbugs.gnu.org; Mon, 27 Sep 2021 14:51:50 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38964)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1mUvj5-0001jd-4Q; Mon, 27 Sep 2021 14:51:43 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4797
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mUvj3-0000LX-EA; Mon, 27 Sep 2021 14:51:43 -0400
Date: Mon, 27 Sep 2021 21:51:45 +0300
Message-Id: <83ee99lum6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <YVIPButhDTcjBE1S@ACM> (message from Alan Mackenzie on Mon, 27
 Sep 2021 18:35:50 +0000)
Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code
References: <837df2moym.fsf@HIDDEN> <YVIPButhDTcjBE1S@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50840
Cc: acm@HIDDEN, monnier@HIDDEN, 50840 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 27 Sep 2021 18:35:50 +0000
> Cc: 50840 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>,
>   acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > Is this true?  If so, a feature request: add a style to support that.
> > If such a style already exists, please clarify the documentation so that
> > users could understand which style does that.
> 
> > And one more nit: Can the 'comment-end' inserted after the end of a
> > comment please keep _two_ spaces after the period that ends the last
> > line of a comment?  Or at least heed the setting of
> > 'sentence-end-double-space'?
> 
> Are we talking about C-c C-c (aka M-x comment-region) here?

Yes, my use case, and the context in which I filed the bug report, was
"C-c C-c".  Not only for the 2 spaces issue, but also for the comment
style.

> This command currently inserts comment-end (in C Mode, " */") at the
> end of each line being commented, which will leave a single space
> between what was the last "." on the line and the "*/".
> 
> We could surely check for an end of sentence character at EOL here, and
> if we've got one, check that at least two spaces are left.  This again
> would be something for lisp/newcomment.el.

Probably.  That''s why Stefan was CC'ed as well.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.

Message received at 50840 <at> debbugs.gnu.org:


Received: (at 50840) by debbugs.gnu.org; 27 Sep 2021 18:36:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 14:36:19 2021
Received: from localhost ([127.0.0.1]:42816 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mUvUB-0000lJ-J8
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2021 14:36:19 -0400
Received: from colin.muc.de ([193.149.48.1]:36696 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1mUvUA-0000l7-Bu
 for 50840 <at> debbugs.gnu.org; Mon, 27 Sep 2021 14:36:18 -0400
Received: (qmail 40151 invoked by uid 3782); 27 Sep 2021 18:36:12 -0000
Received: from acm.muc.de (p4fe15c58.dip0.t-ipconnect.de [79.225.92.88])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Mon, 27 Sep 2021 20:36:11 +0200
Received: (qmail 8895 invoked by uid 1000); 27 Sep 2021 18:35:50 -0000
Date: Mon, 27 Sep 2021 18:35:50 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code
Message-ID: <YVIPButhDTcjBE1S@ACM>
References: <837df2moym.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <837df2moym.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50840
Cc: acm@HIDDEN, Stefan Monnier <monnier@HIDDEN>,
 50840 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Mon, Sep 27, 2021 at 10:56:17 +0300, Eli Zaretskii wrote:

> It sounds like none of the comment styles in 'comment-styles' can
> produce the style of C code comments that we use in Emacs, i.e.

>     /* This is the first line of a multi-line comment.
>        This is the final line of a multi-line comment.  */

> And I don't see anything in the CC Mode manual to augment that,
> either.

On pressing M-; in gnu style in C Mode, you get

    /*  */

, with two spaces between the asterisks.

With an existing comment, and point in the middle of the comment:

   /* foobar barfoo */
            ^
	  point

, on pressing CR, you get

  /* foobar
     barfoo */

If auto-fill-mode is enabled, and one types past fill-column, the new
comment line produced by auto-fill is indented to the desired column.

Thus far, this produces Emacs style C comments.

#########################################################################

However, if point is at the end of the first line of a comment and CR is
pressed:

   /* foobar foobar foobar foobar */
                                 ^
			       point

,  you get

   /* foobar foobar foobar foobar
   */
   ^
 point

..  This seems reasonable for a commenting style that ends with */ alone
on the last line.  But it is inconvenient for the second/subsequent line
of an Emacs style comment.  Is this what you mean by "none of the
comment styles ... produce the ... comments that we use in Emacs"?

If so, we could enhance auto-fill-mode to refill when a space is typed
immediately before a comment closer.  But that somehow doesn't feel
quite right.

Ideally, we want some sort of electric indentation immediately on typing
any character before a comment closer alone on a line:

  /* foobar
  */
  ^
point

, on typing an f should go to

  /* foobar
     f*/

, or possibly even to

  /* foobar
     f */

..  I would be in favour of implementing this as a new feature, but
strictly restricted to the exact scenario above, namely:
(i) point is directly at the comment closer.
(ii) point is in the same column as the comment opener above.
This should minimise irritation to people typing in spaces to draw
pictures in comments, e.g. with |, \, -, /, and suchlike.

This should probably be coded inside lisp/newcomment.el, somehow.  Maybe
we could introduce a new component into the elements of comment-styles
meaning "re-indent bare comment-ender line on typing a self-insert
character".


> Is this true?  If so, a feature request: add a style to support that.
> If such a style already exists, please clarify the documentation so that
> users could understand which style does that.

> And one more nit: Can the 'comment-end' inserted after the end of a
> comment please keep _two_ spaces after the period that ends the last
> line of a comment?  Or at least heed the setting of
> 'sentence-end-double-space'?

Are we talking about C-c C-c (aka M-x comment-region) here?  This
command currently inserts comment-end (in C Mode, " */") at the end of
each line being commented, which will leave a single space between what
was the last "." on the line and the "*/".

We could surely check for an end of sentence character at EOL here, and
if we've got one, check that at least two spaces are left.  This again
would be something for lisp/newcomment.el.

> Thanks.

> In GNU Emacs 28.0.50 (build 1891, i686-pc-mingw32)
>  of 2021-09-27 built on HOME-C4E4A596F7
> Repository revision: d45b3e03c96813e10f8de3c375a5310c01623dab
> Repository branch: master
> Windowing system distributor 'Microsoft Corp.', version 5.1.2600
> System Description: Microsoft Windows XP Service Pack 3 (v5.1.0.2600)

> Configured using:
>  'configure -C --prefix=/d/usr --with-wide-int --with-modules
>  --enable-checking=yes,glyphs 'CFLAGS=-O0 -gdwarf-4 -g3''

> Configured features:
> ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
> W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XPM
> ZLIB

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Sep 2021 07:56:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 03:56:25 2021
Received: from localhost ([127.0.0.1]:39577 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mUlUu-0006M3-NU
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2021 03:56:25 -0400
Received: from lists.gnu.org ([209.51.188.17]:44362)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mUlUp-0006Lq-DA
 for submit <at> debbugs.gnu.org; Mon, 27 Sep 2021 03:56:23 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35004)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1mUlUp-00030r-3Q
 for bug-gnu-emacs@HIDDEN; Mon, 27 Sep 2021 03:56:19 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:46390)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1mUlUn-0007jL-7l; Mon, 27 Sep 2021 03:56:17 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4251
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mUlUm-0002mh-6M; Mon, 27 Sep 2021 03:56:16 -0400
Date: Mon, 27 Sep 2021 10:56:17 +0300
Message-Id: <837df2moym.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.0.50; Support GNU style of multiline comments in C source code
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: Alan Mackenzie <acm@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


It sounds like none of the comment styles in 'comment-styles' can
produce the style of C code comments that we use in Emacs, i.e.

    /* This is the first line of a multi-line comment.
       This is the final line of a multi-line comment.  */

And I don't see anything in the CC Mode manual to augment that,
either.

Is this true?  If so, a feature request: add a style to support that.
If such a style already exists, please clarify the documentation so that
users could understand which style does that.

And one more nit: Can the 'comment-end' inserted after the end of a
comment please keep _two_ spaces after the period that ends the last
line of a comment?  Or at least heed the setting of
'sentence-end-double-space'?

Thanks.

In GNU Emacs 28.0.50 (build 1891, i686-pc-mingw32)
 of 2021-09-27 built on HOME-C4E4A596F7
Repository revision: d45b3e03c96813e10f8de3c375a5310c01623dab
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 5.1.2600
System Description: Microsoft Windows XP Service Pack 3 (v5.1.0.2600)

Configured using:
 'configure -C --prefix=/d/usr --with-wide-int --with-modules
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -gdwarf-4 -g3''

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY
W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XPM
ZLIB

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1255

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process emacs)

Memory information:
((conses 16 56764 6239)
 (symbols 48 7798 1)
 (strings 16 21663 2718)
 (string-bytes 1 633064)
 (vectors 16 13627)
 (vector-slots 8 179704 10721)
 (floats 8 23 53)
 (intervals 40 265 116)
 (buffers 888 10))




Acknowledgement sent to Eli Zaretskii <eliz@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#50840; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 29 Sep 2021 17:30:03 UTC

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