From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo 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 22:16:07 +0200 Message-ID: <13523084.uLZWGnKmhe@fedora> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2958064.e9J7NaK4W3" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13695"; mail-complaints-to="usenet@ciao.gmane.io" To: 70520@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 22 22:17:03 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 1rz061-0003Ib-KO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Apr 2024 22:17:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rz05q-0002wZ-Kd; Mon, 22 Apr 2024 16:16:50 -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 1rz05o-0002wA-0d for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 16:16:48 -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 1rz05n-0006V4-Ph for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 16:16:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rz063-0003S5-PP for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 16:17:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2024 20:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70520 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171381700013084 (code B ref -1); Mon, 22 Apr 2024 20:17:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Apr 2024 20:16:40 +0000 Original-Received: from localhost ([127.0.0.1]:47685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz05e-0003Om-9q for submit@debbugs.gnu.org; Mon, 22 Apr 2024 16:16:39 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:45580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rz05a-0003NS-4a for submit@debbugs.gnu.org; Mon, 22 Apr 2024 16:16:37 -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 1rz05E-0002p0-JX for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 16:16:12 -0400 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rz05D-0006Tn-2i for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 16:16:12 -0400 Original-Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41a1d2a7b81so10105335e9.0 for ; Mon, 22 Apr 2024 13:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713816969; x=1714421769; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=hh8ek54sGa9sjuHUsI+FmznlESH/dwuQhTEzdYAhzVk=; b=b0ygw/UCqTe7YwFowmEzi02qF1ausUOh9C661o31WEO9VYEbJHh+c+6Lx8WX3+4jEn jJKpgTSXWq/q8hYUgHUrvev4yJAZuSCWj/xEVyL4eBB418Vs0wOGUTv3s/EA0NmGbT2k vKINADVqBGhWUEQK7hLdyGt/6fhMuMoMc6mhDqWiyvienJyv5zst1g9ET9Z4MAcYFGjG rNb5kZAqxpYy1Wf3n41mjwkrnu4Y3VfIeC72oCCTShSI1B+0hrHhAEAeFXg69xtc2SwA h9t1dGEYWrrS8X6yS6DwXRaoUcBowiNIDvettqxChIQ02bUpcqzKAWufzLPYQd1pc2m/ ad8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713816969; x=1714421769; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hh8ek54sGa9sjuHUsI+FmznlESH/dwuQhTEzdYAhzVk=; b=riyH9s1U73LOLGGPe407Oichuq90McB3quHRpbYVnmJBcaiQ7flYjyH4FhJrEgyWLC mZSlqVxr0+F3BqltVXPd/mhgP/h/U0nZUam9Eh/Xf25OMSrV+F6MqgcWCF4zJNsC1GuL ZTPA9X7XTZ+W/uPSrk7NgwxJ/XnnxX+/DZJW8xOu+a5ItTA8ZTNryntA8UWeJqNd6uej 24WOue4I3+jP/e1+wONKz6DzW9MXSLdpoL/Et73CDpZRMz+5VahYxmhpIXJgBONaxehl 70mO5SUeYrLCE4ZS4MZQsz6WM8cfUn4ncOKX7qlRwuN36ajUV7oUCTUsfJ6v+d9EBzIV 6KGg== X-Gm-Message-State: AOJu0YzyVxf0Pe7f68XWEI7yx8m0cpGk2sHNf+q+Gb3yV4BVOXo/0ARQ uuSnGOuRasNXuHTPTB+KS22f0cQ2ixHRodj739GSCyBj9uo3vDSUwRzAyA== X-Google-Smtp-Source: AGHT+IF0HcXlpELQjDykmnO4xYVDMXsR5uxoeikbTe17p6QQhIMrqWB2/lY3bsM3N8NJlqrZPA6skg== X-Received: by 2002:a05:600c:1ca9:b0:418:9d4a:1ba5 with SMTP id k41-20020a05600c1ca900b004189d4a1ba5mr483091wms.6.1713816968970; Mon, 22 Apr 2024 13:16:08 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id j1-20020a05600c1c0100b00419ea5fb0cbsm9912396wms.42.2024.04.22.13.16.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:16:08 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=v.pupillo@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:283850 Archived-At: This is a multi-part message in MIME format. --nextPart2958064.e9J7NaK4W3 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hello, the new function c-ts-common-comment-indent-new-line has a different behavior from comment-indent-new-line in c-mode. In a comment block like this: /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, 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. Thank you. V. --nextPart2958064.e9J7NaK4W3 Content-Disposition: attachment; filename="0001-Cover-more-c-ts-common-comment-indent-new-line.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Cover-more-c-ts-common-comment-indent-new-line.patch" >From 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))))) ;;; Statement indent -- 2.44.0 --nextPart2958064.e9J7NaK4W3--