Subject: bug#70520: closed (Re: 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.)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 23 Apr 2024 04:58:02 +0000

Your bug report

#70520: 30.0.50; [PATCH] c-ts-common-comment-indent-new-line does nothing when the comment line in a block starts with whitespace.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
70520: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70520
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: 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.
From: Yuan Fu <[email-masked]>
To: Vincenzo Pupillo <[email-masked]>
Cc: [email-masked]
Date: Mon, 22 Apr 2024 21:57:10 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

> On Apr 22, 2024, at 1:16 PM, Vincenzo Pupillo <[email-masked]> wrote:
> 
> 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.
From aa0b1f1d25a068b0386eeb81bab564465b31399e Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
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

Merged, thank you!

Yuan

Subject: 30.0.50; [PATCH] c-ts-common-comment-indent-new-line does nothing when the comment line in a block starts with whitespace.
From: Vincenzo Pupillo <[email-masked]>
To: [email-masked]
Date: Mon, 22 Apr 2024 22:16:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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.
>From aa0b1f1d25a068b0386eeb81bab564465b31399e Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
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