From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code Date: Mon, 27 Sep 2021 18:35:50 +0000 Message-ID: References: <837df2moym.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20123"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, Stefan Monnier , 50840@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 27 20:37:26 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUvVF-00051m-Sq for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 20:37:25 +0200 Original-Received: from localhost ([::1]:60998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUvVE-0004kK-Rv for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 14:37:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUvUs-0004js-Ie for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 14:37:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUvUs-0005yL-AM for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 14:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mUvUs-0000mK-7f for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 14:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Sep 2021 18:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50840 X-GNU-PR-Package: emacs Original-Received: via spool by 50840-submit@debbugs.gnu.org id=B50840.16327677802937 (code B ref 50840); Mon, 27 Sep 2021 18:37:02 +0000 Original-Received: (at 50840) by debbugs.gnu.org; 27 Sep 2021 18:36:20 +0000 Original-Received: from localhost ([127.0.0.1]:42816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUvUB-0000lJ-J8 for submit@debbugs.gnu.org; Mon, 27 Sep 2021 14:36:19 -0400 Original-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 ) id 1mUvUA-0000l7-Bu for 50840@debbugs.gnu.org; Mon, 27 Sep 2021 14:36:18 -0400 Original-Received: (qmail 40151 invoked by uid 3782); 27 Sep 2021 18:36:12 -0000 Original-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 Original-Received: (qmail 8895 invoked by uid 1000); 27 Sep 2021 18:35:50 -0000 Content-Disposition: inline In-Reply-To: <837df2moym.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:215694 Archived-At: 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).