From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#70520: 30.0.50; [PATCH] c-ts-common-comment-indent-new-line does nothing when the comment line in a block starts with whitespace. Date: Mon, 22 Apr 2024 21:57:10 -0700 Message-ID: <0D0F8221-6E3E-4D9E-9AFE-708FD46C460C@gmail.com> References: <13523084.uLZWGnKmhe@fedora> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_3E67BCA8-886B-4C3C-BF8D-563305F31AA4" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26637"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70520-done@debbugs.gnu.org To: Vincenzo Pupillo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 23 06:58:19 2024 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 1rz8EU-0006fp-Ft for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Apr 2024 06:58:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rz8Dz-0000Jv-8n; Tue, 23 Apr 2024 00:57:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rz8Dy-0000J7-6t for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 00:57:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rz8Dx-00049a-TT for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 00:57:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rz8ED-00047h-V4 for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 00:58:01 -0400 Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Apr 2024 04:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 70520 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 70520@debbugs.gnu.org, casouri@gmail.com, v.pupillo@gmail.com Original-Received: via spool by 70520-done@debbugs.gnu.org id=D70520.171384826915758 (code D ref 70520); Tue, 23 Apr 2024 04:58:01 +0000 Original-Received: (at 70520-done) by debbugs.gnu.org; 23 Apr 2024 04:57:49 +0000 Original-Received: from localhost ([127.0.0.1]:49805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz8E0-000465-NL for submit@debbugs.gnu.org; Tue, 23 Apr 2024 00:57:49 -0400 Original-Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:50558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz8Dw-00044d-Ev for 70520-done@debbugs.gnu.org; Tue, 23 Apr 2024 00:57:46 -0400 Original-Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e651a9f3ffso29051365ad.1 for <70520-done@debbugs.gnu.org>; Mon, 22 Apr 2024 21:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713848242; x=1714453042; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=T8kfDLZARt9giQJ1LIznXeFn/zU13rpMFW15b1MkmSQ=; b=UTcYaedU7jtvXe0f5kwA0a7GcSt8LMR3NhlcXa+FQ8KaWcEdPMB7ET6M2z1DNuMDMN 9NnzjXjeW37nN4VscwxrBRb/O+bMd3xlAX8KNnUn5Dk3q+Eo53TOArQ8WO2iLiPLdV1m JsdHhzyrfNGaIkfl1i6q5wk34SsNJCeW0f/YCoJMaEMQ8vfyRbcjUGE893bDgEvMB3gr +3EKYRBuHs1xb+yxSLVDwSvYDhK2Q/ABDbyGw3S+Kb2BD7LNs/hSTNvaTIILQcbUeZTx Vey/QjkeSY5w6k9z/c5FxFvbJKyitnrWj8TkvweeRC4UDF47qQjDN6E/pwg5wvDykaS+ 99UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713848242; x=1714453042; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T8kfDLZARt9giQJ1LIznXeFn/zU13rpMFW15b1MkmSQ=; b=uEvoUc2CjOP+FtylRW/1HJDulyeRZC6e3QNU1zMN9NfKAj31dyq9pGNgO1C2U67ZTn HFDnOKxB/uL71fniGvhxQTG5KW0s/nUdbyKfm+9GPDMrJ+5RON7UtgmxguxCOII87SNg 9y++GQXcjy/8C2XbfXaoRW+eFnZXC0yq+C0xC4V2DESqcuONMcTRW6u5MoYSK9iLEWh9 14BW06wBNyf1vu1pZqkf8TXBnQHJIU+6W4IF9AtMKgoFl67UFImykS2Uq60wWEU85S0P hUp7qCYAgHI3oLJrJs0/jn2v3TpSH8tK3dFdrTojTZjJwky5ffQWc9/8vhoHeKeDfWF3 7iZQ== X-Gm-Message-State: AOJu0Yy5JQqKerxhjYv7Al5h72qvTZgUZuU3f1fwjaM+DFRkwl3ij9gB CsyrHgX4Sw2wgPwI2DMZfwmP24PVh0DeqSMJLLubOkBcv4vYZL3f X-Google-Smtp-Source: AGHT+IF8ZO5XySbvAj6AaphCFotFpc8p26BAznJGpLWGaoPLYxT3x7qvdBqXTMiJ5suPjRW/bF96GQ== X-Received: by 2002:a17:902:cf0d:b0:1e4:7ca3:8a33 with SMTP id i13-20020a170902cf0d00b001e47ca38a33mr15078311plg.17.1713848242074; Mon, 22 Apr 2024 21:57:22 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:641:300:4910:e4f6:f0b8:c91d:e40b]) by smtp.gmail.com with ESMTPSA id h15-20020a170902680f00b001e89e7b2b74sm8352406plk.235.2024.04.22.21.57.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2024 21:57:21 -0700 (PDT) In-Reply-To: <13523084.uLZWGnKmhe@fedora> X-Mailer: Apple Mail (2.3731.700.6.1.1) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283861 Archived-At: --Apple-Mail=_3E67BCA8-886B-4C3C-BF8D-563305F31AA4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Apr 22, 2024, at 1:16 PM, Vincenzo Pupillo = wrote: >=20 > Hello,=20 > the new function c-ts-common-comment-indent-new-line has a different = behavior=20 > from comment-indent-new-line in c-mode. > In a comment block like this: > /* > Lorem ipsum dolor sit amet, consectetur adipiscing elit,=20 > sed do eiusmod tempor incididunt ut labore et dolore magna aliqua > */ > M-j does not break the line or indent. The cursor simply stands still. > The attached patch handles this case. >=20 > Thank you. > V. --Apple-Mail=_3E67BCA8-886B-4C3C-BF8D-563305F31AA4 Content-Disposition: attachment; filename=0001-Cover-more-c-ts-common-comment-indent-new-line.patch Content-Type: text/x-patch; x-unix-mode=0644; name="0001-Cover-more-c-ts-common-comment-indent-new-line.patch" Content-Transfer-Encoding: quoted-printable =46rom aa0b1f1d25a068b0386eeb81bab564465b31399e Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 22 Apr 2024 21:05:49 +0200 Subject: [PATCH] Cover more c-ts-common-comment-indent-new-line. * lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line): Handles the case of comments in a comment block that begin with whitespaces. --- lisp/progmodes/c-ts-common.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/c-ts-common.el = b/lisp/progmodes/c-ts-common.el index 735126e1eac..025703d7fce 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -317,7 +317,16 @@ c-ts-common-comment-indent-new-line (let ((prefix (match-string 1))) (if soft (insert-and-inherit ?\n) (newline 1)) (delete-region (line-beginning-position) (point)) - (insert prefix))))) + (insert prefix))) + + ;; Line starts with whitespaces + ((save-excursion + (beginning-of-line) + (looking-at (rx (* " ")))) + (let ((whitespaces (match-string 0))) + (if soft (insert-and-inherit ?\n) (newline 1)) + (delete-region (line-beginning-position) (point)) + (insert whitespaces))))) =20 ;;; Statement indent =20 --=20 2.44.0 --Apple-Mail=_3E67BCA8-886B-4C3C-BF8D-563305F31AA4 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Merged, thank you! Yuan --Apple-Mail=_3E67BCA8-886B-4C3C-BF8D-563305F31AA4--