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: Wed, 29 Sep 2021 11:04:13 +0000 Message-ID: References: <837df2moym.fsf@gnu.org> <83ee99lum6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8973"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, 50840@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 29 13:05:29 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 1mVXOy-00027x-Uk for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 13:05:28 +0200 Original-Received: from localhost ([::1]:39486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVXOx-0000e8-PR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 07:05:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVXOZ-0000bp-3d for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2021 07:05:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVXOY-0002Xt-OS for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2021 07:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVXOY-0006fC-Cq for bug-gnu-emacs@gnu.org; Wed, 29 Sep 2021 07:05: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: Wed, 29 Sep 2021 11:05: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.163291346425559 (code B ref 50840); Wed, 29 Sep 2021 11:05:02 +0000 Original-Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 11:04:24 +0000 Original-Received: from localhost ([127.0.0.1]:47868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVXNw-0006eA-11 for submit@debbugs.gnu.org; Wed, 29 Sep 2021 07:04:24 -0400 Original-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 ) id 1mVXNt-0006dt-D2 for 50840@debbugs.gnu.org; Wed, 29 Sep 2021 07:04:22 -0400 Original-Received: (qmail 79922 invoked by uid 3782); 29 Sep 2021 11:04:14 -0000 Original-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 Original-Received: (qmail 18862 invoked by uid 1000); 29 Sep 2021 11:04:13 -0000 Content-Disposition: inline In-Reply-To: <83ee99lum6.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:215833 Archived-At: 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@debbugs.gnu.org, Stefan Monnier , > > acm@muc.de > > From: Alan Mackenzie > > > 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).