]> git.eshelyaron.com Git - emacs.git/commitdiff
Cover more c-ts-common-comment-indent-new-line (bug#70520)
authorVincenzo Pupillo <v.pupillo@gmail.com>
Mon, 22 Apr 2024 19:05:49 +0000 (21:05 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 23 Apr 2024 10:13:52 +0000 (12:13 +0200)
* 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.

(cherry picked from commit 1f443c277a1215ab6353c47161819af155638110)

lisp/progmodes/c-ts-common.el

index 735126e1eac5e609f1f62fc06e50ff84f0b8070d..025703d7fcea86314a65e29b73424355bc2c7b35 100644 (file)
@@ -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