[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1f443c277a1 1/2: Cover more c-ts-common-comment-indent-new-line (
From: |
Yuan Fu |
Subject: |
master 1f443c277a1 1/2: Cover more c-ts-common-comment-indent-new-line (bug#70520) |
Date: |
Tue, 23 Apr 2024 00:56:55 -0400 (EDT) |
branch: master
commit 1f443c277a1215ab6353c47161819af155638110
Author: Vincenzo Pupillo <v.pupillo@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Cover more c-ts-common-comment-indent-new-line (bug#70520)
* 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 @@ and /* */ comments. SOFT works the same as in
(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