From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 27 03:56:25 2021 Received: (at submit) by debbugs.gnu.org; 27 Sep 2021 07:56:25 +0000 Received: from localhost ([127.0.0.1]:39577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUlUu-0006M3-NU for submit@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 ) id 1mUlUp-0006Lq-DA for submit@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 ) id 1mUlUp-00030r-3Q for bug-gnu-emacs@gnu.org; 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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: bug-gnu-emacs@gnu.org 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 , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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)) From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 27 07:41:58 2021 Received: (at control) by debbugs.gnu.org; 27 Sep 2021 11:41:58 +0000 Received: from localhost ([127.0.0.1]:39900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUp1B-00041H-VO for submit@debbugs.gnu.org; Mon, 27 Sep 2021 07:41:58 -0400 Received: from mail-pj1-f47.google.com ([209.85.216.47]:39702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUp1A-000410-4B for control@debbugs.gnu.org; Mon, 27 Sep 2021 07:41:56 -0400 Received: by mail-pj1-f47.google.com with SMTP id bj3-20020a17090b088300b0019e6603fe89so11599225pjb.4 for ; Mon, 27 Sep 2021 04:41:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=FY1lwvRXHAvUzXyl/TAg/4p8oDj8qSSzNoH3T7XWozM=; b=faK/WTiIuMplQp5S+7lFnDgaMfZYbsKQ6geKBuGHox3DYUNrjKfs4ikVzqndM0UwNs 4pKIeLNecJXN7LUU6FWr+l2p85hfBpIp0ZjewBiAqGvIr639T6LGXVVrLj/vbdkOLiS1 46TlJgBsa/lqiw4eAIs5Zb1eQD6fMrczCJPYnbK9qjcLBm/yjJBv+dS0iQsr+XOISYmF /J2xflgwIFXxSkOpvdIKckBgMWWfNDNmKNZHNjtqHZcxGMcF9gmVxe42aA5k38nbmvbx kZLsVBblnP5bzFkO5U1sk7Xk/6oZTanNN3Pa0//m1d61bLPgXT/WC07YcUEE9rdFav3R ONPQ== X-Gm-Message-State: AOAM530NvhiBE8FaJYHRJx+cnx6NKCf4cd0sEp4eGFkCSs0tUpNCvN1F 2i17pyrso0aj0e0/f2/WUSr+ZBhwyQuRYKyudpfSePPP X-Google-Smtp-Source: ABdhPJwGsdreWlVADONoHOUrLly2SqZhvJHo4vvx9qpmxT1qILd+dnIYmMu8g5P42Ht8Bi+o5dWmF4YCvsjxUdYVa/8= X-Received: by 2002:a17:902:c1c5:b0:13e:2e1e:aaa4 with SMTP id c5-20020a170902c1c500b0013e2e1eaaa4mr3634222plc.32.1632742910082; Mon, 27 Sep 2021 04:41:50 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 27 Sep 2021 04:41:49 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 27 Sep 2021 04:41:49 -0700 Message-ID: Subject: control message for bug #50840 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) severity 50840 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 27 14:36:19 2021 Received: (at 50840) by debbugs.gnu.org; 27 Sep 2021 18:36:20 +0000 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 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 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 Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <837df2moym.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 50840 Cc: acm@muc.de, Stefan Monnier , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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). From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 27 14:51:51 2021 Received: (at 50840) by debbugs.gnu.org; 27 Sep 2021 18:51:51 +0000 Received: from localhost ([127.0.0.1]:42862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUvjD-0001Dg-5k for submit@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 ) id 1mUvjB-0001DT-I3 for 50840@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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: Alan Mackenzie In-Reply-To: (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@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50840 Cc: acm@muc.de, monnier@iro.umontreal.ca, 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 29 07:04:24 2021 Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 11:04:24 +0000 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 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 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 Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> <83ee99lum6.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <83ee99lum6.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 50840 Cc: monnier@iro.umontreal.ca, 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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@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). From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 29 08:08:53 2021 Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 12:08:53 +0000 Received: from localhost ([127.0.0.1]:48017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVYOL-0006Sz-Fl for submit@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 ) id 1mVYOJ-0006Sf-Hs for 50840@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 To: Alan Mackenzie Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> <83ee99lum6.fsf@gnu.org> Date: Wed, 29 Sep 2021 08:08:43 -0400 In-Reply-To: (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 , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 29 13:30:47 2021 Received: (at 50840) by debbugs.gnu.org; 29 Sep 2021 17:30:47 +0000 Received: from localhost ([127.0.0.1]:50106 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVdPq-00069J-MR for submit@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 ) id 1mVdPo-000615-DL for 50840@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 Subject: Re: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> <83ee99lum6.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 50840 Cc: Eli Zaretskii , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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). From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 01 15:42:44 2021 Received: (at 50840) by debbugs.gnu.org; 1 Oct 2021 19:42:44 +0000 Received: from localhost ([127.0.0.1]:57393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWOQd-0007wN-SA for submit@debbugs.gnu.org; Fri, 01 Oct 2021 15:42:44 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:33444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWOQb-0007w9-Nw for 50840@debbugs.gnu.org; Fri, 01 Oct 2021 15:42:43 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DA9338084E; Fri, 1 Oct 2021 15:42:35 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id EE3AB80161; Fri, 1 Oct 2021 15:42:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1633117353; bh=16knGHyMCyZ0l0y8K/ywnI8MrKXwpt12jraymefzwnE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=YSfabKY768H5RnQCR4C3nMb5ocUJQJbMQ36a4seb6oGs612g9mNEFB+obDU0+pJGH nLPq8R46Pijkr/3J/oDnD79jVJYjuzeRIPnGZROqLu1e1cq6RJTzJxPgP0kQaVCYbc c+kNvZ1pIT7/Y4W9fNrPHlPDbDkPPCZK3hkjd0sycn5sdQtBhFzVbTqV5zv+esyUP9 iwutT+VzIa5g3qzIalUBThDPli7QmYMBjGgupeDGlV2oU/zGngoPR7M6dicf2w2Ut8 ltLe0XFHBeng67WLYZ5FF1eV2gLMWgNxgATXoxRCkNqBu8l19W2bLXzjdmYi4CZWg8 ODpPiY42c34+A== Received: from ceviche (modemcable004.216-203-24.mc.videotron.ca [24.203.216.4]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AB8D81202A1; Fri, 1 Oct 2021 15:42:33 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> Date: Fri, 01 Oct 2021 15:42:32 -0400 In-Reply-To: <837df2moym.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Sep 2021 10:56:17 +0300") 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.104 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: Alan Mackenzie , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. I'm not sure exactly what that would mean in practice. `comment-style` is used to comment out code rather than to write the text of a comment. I think what you're asking for is what you get by setting `comment-multi-line` and then writing your text (e.g. starting with M-; and then typing the text in there, maybe with auto-fill set). If you want comment-region to produce something like the above, then maybe a patch like the following would make sense? The idea is to add a new value nil to `comment-style` which would instruct `comment-region` to refrain from adding `comment-continue` on eachline of a multiline comment. Stefan diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 52e7f09b693..619353d72fd 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -279,13 +277,13 @@ comment-style See `comment-styles' for a list of available styles." :type (if (boundp 'comment-styles) `(choice + (cons :tag "nil: Minimal" nil) ,@(mapcar (lambda (s) `(const :tag ,(format "%s: %s" (car s) (nth 5 s)) ,(car s))) comment-styles)) 'symbol) - :version "23.1" - :group 'comment) + :version "23.1") ;;;###autoload (defcustom comment-padding (purecopy " ") @@ -345,9 +339,7 @@ comment-string-strip "\\'") str) (match-string 1 str)) -(defun comment-string-reverse (s) - "Return the mirror image of string S, without any trailing space." - (comment-string-strip (concat (nreverse (string-to-list s))) nil t)) +(define-obsolete-function-alias 'comment-string-reverse #'reverse "29.1") ;;;###autoload (defun comment-normalize-vars (&optional noerror) @@ -933,7 +925,10 @@ uncomment-region-default-1 (let* ((numarg (prefix-numeric-value arg)) (ccs comment-continue) (srei (or (comment-padright ccs 're) - (and (stringp comment-continue) comment-continue))) + ;; `comment-padright' returns nil for whitespace-only + ;; strings. + (and (stringp comment-continue) + comment-continue))) (csre (comment-padright comment-start 're)) (sre (and srei (concat "^\\s-*?\\(" srei "\\)"))) spt) @@ -1005,8 +1000,8 @@ uncomment-region-default-1 ;; Eliminate continuation markers as well. (when sre - (let* ((cce (comment-string-reverse (or comment-continue - comment-start))) + (let* ((cce (reverse (or comment-continue + comment-start))) (erei (and box (comment-padleft cce 're))) (ere (and erei (concat "\\(" erei "\\)\\s-*$")))) (goto-char (point-min)) @@ -1149,7 +1144,7 @@ comment-region-internal ;; Should we mark empty lines as well ? (if (or ccs block lines) (setq no-empty nil)) ;; Make sure we have end-markers for BLOCK mode. - (when block (unless ce (setq ce (comment-string-reverse cs)))) + (when block (unless ce (setq ce (reverse cs)))) ;; If BLOCK is not requested, we don't need CCE. (unless block (setq cce nil)) ;; Continuation defaults to the same as CS and CE. @@ -1244,7 +1239,7 @@ comment-region-default-1 (style (cdr (assoc comment-style comment-styles))) (lines (nth 2 style)) (block (nth 1 style)) - (multi (nth 0 style))) + (multi (if style (nth 0 style) t))) (if noadjust (when (bolp) @@ -1297,10 +1292,9 @@ comment-region-default-1 ;; In Lisp and similar modes with one-character comment starters, ;; double it by default if `comment-add' says so. ;; If it isn't indented, triple it. - (if (and (null arg) (not multi-char)) - (setq numarg (* comment-add (if triple 2 1))) - (setq numarg (1- (prefix-numeric-value arg)))) - + (setq numarg (if (and (null arg) (not multi-char)) + (* comment-add (if triple 2 1)) + (1- (prefix-numeric-value arg)))) (comment-region-internal beg end (let ((s (comment-padright comment-start numarg))) @@ -1309,13 +1303,17 @@ comment-region-default-1 (let ((s (comment-padleft comment-end numarg))) (and s (if (string-match comment-end-skip s) s (comment-padright comment-end)))) - (if multi - (or (comment-padright comment-continue numarg) - ;; `comment-padright' returns nil when - ;; `comment-continue' contains only whitespace - (and (stringp comment-continue) comment-continue))) - (if multi - (comment-padleft (comment-string-reverse comment-continue) numarg)) + (cond + ((not style) (make-string (string-width cs) "")) + (multi + (or (comment-padright comment-continue numarg) + ;; `comment-padright' returns nil when + ;; `comment-continue' contains only whitespace + (and (stringp comment-continue) comment-continue)))) + (cond + ((not style) "") + (multi + (comment-padleft (reverse comment-continue) numarg))) block lines indent)))))) @@ -1360,7 +1358,7 @@ comment-or-uncomment-region (interactive "*r\nP") (comment-normalize-vars) (funcall (if (comment-only-p beg end) - 'uncomment-region 'comment-region) + #'uncomment-region #'comment-region) beg end arg)) ;;;###autoload @@ -1545,8 +1542,9 @@ comment-indent-new-line (comment-start comstart) (comment-end comend) (continuep (or comment-multi-line - (cadr (assoc comment-style - comment-styles)))) + (null comment-style) + (cadr (assq comment-style + comment-styles)))) ;; Recreate comment-continue from comment-start. ;; FIXME: wrong if comment-continue was set explicitly! ;; FIXME: use prev line's continuation if available. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 01 15:50:54 2021 Received: (at 50840) by debbugs.gnu.org; 1 Oct 2021 19:50:54 +0000 Received: from localhost ([127.0.0.1]:57407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWOYX-0008Cd-Rt for submit@debbugs.gnu.org; Fri, 01 Oct 2021 15:50:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWOYW-0008CQ-8Z for 50840@debbugs.gnu.org; Fri, 01 Oct 2021 15:50:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54876) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWOYP-0002Fh-Bc; Fri, 01 Oct 2021 15:50:45 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4369 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWOYA-0007W3-TG; Fri, 01 Oct 2021 15:50:45 -0400 Date: Fri, 01 Oct 2021 22:50:11 +0300 Message-Id: <83o888cyoc.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Fri, 01 Oct 2021 15:42:32 -0400) Subject: Re: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code References: <837df2moym.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50840 Cc: acm@muc.de, 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: 50840@debbugs.gnu.org, Alan Mackenzie > Date: Fri, 01 Oct 2021 15:42:32 -0400 > > > 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. > > I'm not sure exactly what that would mean in practice. > `comment-style` is used to comment out code rather than to write the > text of a comment. I think what you're asking for is what you get by > setting `comment-multi-line` and then writing your text (e.g. starting > with M-; and then typing the text in there, maybe with auto-fill set). The actual use case is to convert a block of comments like this: // First line // continuation line with more text, // more text. And another sentence // which continues here. to our comment style. I thought it was easy: first uncomment the region, then comment the region using the proper style. But there's no style to take a sequence of lines like this: First line continuation line with more text, more text. And another sentence which continues here. and make it look like this: /* First line continuation line with more text, more text. And another sentence which continues here. */ > If you want comment-region to produce something like the above, then > maybe a patch like the following would make sense? It's late down here, so instead of applying the patch and playing with it, let me ask you: will this patch support the above use case? > The idea is to add a new value nil to `comment-style` which would > instruct `comment-region` to refrain from adding `comment-continue` on > eachline of a multiline comment. The value nil doesn't sound like a good mnemonic. I think the style I have in mind is a multi-line style, just without the "* " leader on each line. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 01 16:57:13 2021 Received: (at 50840) by debbugs.gnu.org; 1 Oct 2021 20:57:13 +0000 Received: from localhost ([127.0.0.1]:57469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWPai-0001VI-Vm for submit@debbugs.gnu.org; Fri, 01 Oct 2021 16:57:13 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWPag-0001V3-3Y for 50840@debbugs.gnu.org; Fri, 01 Oct 2021 16:57:11 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7D9108084E; Fri, 1 Oct 2021 16:57:04 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DADA98028B; Fri, 1 Oct 2021 16:57:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1633121822; bh=ed3oZp8s8WBh+NtoGjnI+7uVtGyZ5GpXT8LeNliHLng=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=oDuj8F4sGtxxZEURswIIF3PcDMZnzvUW4Lu0ak3ZUGe+9OKKfMwmXt00cbw3Vn60V ABreWQSEIuiZpe9+F/Ho/oEIYzP9HGD4yOODYkdri8nqcW+CMZ4ehvmShdxZSkfQpb AYyIDdODbYWbbo5SB74kvBFvkft3DWZUsnluYHh0kJHJOI00Lz5F82SmsrDLpQCtie +GDDUP+IYjREt4TCuMIGjKZsjy7EZ3DQmByGmZLcAHO5qTL5LXdjQX9V1FfSRTHnPH 5fX8VMOrqSGMupmh36HGIqaKTMCz97iTkrX2sWScf4jJY7e2RwA2YLcttnZfgk/3jG WfaPfoUNgme2A== Received: from ceviche (modemcable004.216-203-24.mc.videotron.ca [24.203.216.4]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 95B8812033B; Fri, 1 Oct 2021 16:57:02 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code Message-ID: References: <837df2moym.fsf@gnu.org> <83o888cyoc.fsf@gnu.org> Date: Fri, 01 Oct 2021 16:57:01 -0400 In-Reply-To: <83o888cyoc.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Oct 2021 22:50:11 +0300") 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.103 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: acm@muc.de, 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > The actual use case is to convert a block of comments like this: > > // First line > // continuation line with more text, > // more text. And another sentence > // which continues here. > > to our comment style. I thought it was easy: first uncomment the > region, then comment the region using the proper style. But there's > no style to take a sequence of lines like this: > > First line > continuation line with more text, > more text. And another sentence > which continues here. > > and make it look like this: > > /* First line > continuation line with more text, > more text. And another sentence > which continues here. */ Ah, now that makes sense, thanks. >> If you want comment-region to produce something like the above, then >> maybe a patch like the following would make sense? > It's late down here, so instead of applying the patch and playing with > it, let me ask you: will this patch support the above use case? I don't think so because it will fail to indent the last 3 lines by the extra 3 spaces. >> The idea is to add a new value nil to `comment-style` which would >> instruct `comment-region` to refrain from adding `comment-continue` on >> eachline of a multiline comment. > The value nil doesn't sound like a good mnemonic. I think the style I > have in mind is a multi-line style, just without the "* " leader on > each line. Right (though you do want to use a leader on each line, just one of " " instead of " * "), but `comment-styles` doesn't have a field to specify that the comment-continuation should be empty, so I was going for a cheaper solution. I'll try again later for something less cheap ;-) Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 03 13:09:58 2021 Received: (at 50840) by debbugs.gnu.org; 3 Oct 2021 17:09:58 +0000 Received: from localhost ([127.0.0.1]:34833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX4zt-0005EZ-SM for submit@debbugs.gnu.org; Sun, 03 Oct 2021 13:09:58 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:52565) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX4zs-0005EK-8h for 50840@debbugs.gnu.org; Sun, 03 Oct 2021 13:09:56 -0400 Received: (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 10F8D200003; Sun, 3 Oct 2021 17:09:48 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code Organization: LINKOV.NET References: <837df2moym.fsf@gnu.org> <83o888cyoc.fsf@gnu.org> Date: Sun, 03 Oct 2021 20:02:14 +0300 In-Reply-To: <83o888cyoc.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Oct 2021 22:50:11 +0300") Message-ID: <8735pib2ly.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 50840 Cc: acm@muc.de, Stefan Monnier , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > But there's no style to take a sequence of lines like this: > > First line > continuation line with more text, > more text. And another sentence > which continues here. > > and make it look like this: > > /* First line > continuation line with more text, > more text. And another sentence > which continues here. */ Recently lisp/newcomment.el was fixed in bug#47167 and bug#50226 to handle whitespace in 'comment-continue' with the multi-line style. So you can get the above with: (setq-local comment-style 'multi-line comment-continue " ") PS: It doesn't add double space at the sentence end since this is a separate feature. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 07:00:03 2022 Received: (at 50840) by debbugs.gnu.org; 2 Sep 2022 11:00:03 +0000 Received: from localhost ([127.0.0.1]:45026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4P4-0002Iu-Ma for submit@debbugs.gnu.org; Fri, 02 Sep 2022 07:00:03 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4P0-0002HC-Gj for 50840@debbugs.gnu.org; Fri, 02 Sep 2022 07:00:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GFgs137+wW9Tea5moQLYOgUyZpAyrwQZAQT96qXqHGo=; b=pvulv44qgzdNZnMp2v6wQvp4+w JgrE+KaFhhe6BgG5HRUjSw1L9EJS8zdTZQiCJ5wTfAHuWjsM0aY7vNbke7YNKWM6UjibE9fdyesM4 YkR/qKTfYqVuoyexSVHscR+OPi/vjF2Nrc52ZtIOj76OuvjGvOlK3jOjmLJMGo2PAcoE=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU4Oq-0004lk-Et; Fri, 02 Sep 2022 12:59:50 +0200 From: Lars Ingebrigtsen To: Juri Linkov Subject: Re: bug#50840: 28.0.50; Support GNU style of multiline comments in C source code In-Reply-To: <8735pib2ly.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 03 Oct 2021 20:02:14 +0300") References: <837df2moym.fsf@gnu.org> <83o888cyoc.fsf@gnu.org> <8735pib2ly.fsf@mail.linkov.net> X-Now-Playing: The Cure's _Bloodflowers_: "Watching Me Fall" Date: Fri, 02 Sep 2022 12:59:47 +0200 Message-ID: <87wnamvy70.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Juri Linkov writes: > Recently lisp/newcomment.el was fixed in bug#47167 and bug#50226 > to handle whitespace in 'comment-continue' with the multi-line style. > So you can get the above with: > > (setq-local comment-styl [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50840 Cc: acm@muc.de, Eli Zaretskii , Stefan Monnier , 50840@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Juri Linkov writes: > Recently lisp/newcomment.el was fixed in bug#47167 and bug#50226 > to handle whitespace in 'comment-continue' with the multi-line style. > So you can get the above with: > > (setq-local comment-style 'multi-line > comment-continue " ") Seems to work well, so I guess there isn't more to be done here, and I'm closing this bug report. > PS: It doesn't add double space at the sentence end > since this is a separate feature. Yup. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 07:00:02 2022 Received: (at control) by debbugs.gnu.org; 2 Sep 2022 11:00:03 +0000 Received: from localhost ([127.0.0.1]:45024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4P4-0002IV-AC for submit@debbugs.gnu.org; Fri, 02 Sep 2022 07:00:02 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4P2-0002HF-Jr for control@debbugs.gnu.org; Fri, 02 Sep 2022 07:00:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QCKa8mnHfFhgw7agMgSZG4ZICDabWPU7msrC/T4Mj1E=; b=LUxbVFjEMLi9Nc9OJYSqE36b5Z GZ4ucm+yHLbN9iqP3qBmeEcDZZdD2IE6kEUTV98OOiFccIPXmeNtVkEQCgwS9Ni9cAfQO6cZEkJ5w qwiZP9za9ltY0B0apFPlsCNnrWbv9k8kYpZ7KSJtsgoQOt0twtUF3A0ouuebZFvry4TM=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU4Ou-0004lp-QJ for control@debbugs.gnu.org; Fri, 02 Sep 2022 12:59:54 +0200 Date: Fri, 02 Sep 2022 12:59:52 +0200 Message-Id: <87v8q6vy6v.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #50840 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 50840 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 50840 29.1 quit From unknown Fri Aug 15 16:21:21 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 30 Sep 2022 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator