mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-17 11:20:39 -08:00
Fix c-ts-common-comment-indent-new-line (bug#73900)
* lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line): Delete trailing whitespace before inserting newline. The insert-line-break function is the same as in c-indent-new-comment-line.
This commit is contained in:
parent
df5ac0daf0
commit
e6a8492fab
1 changed files with 52 additions and 46 deletions
|
|
@ -302,6 +302,12 @@ and /* */ comments. SOFT works the same as in
|
|||
;; is a // comment, insert a newline and a // prefix; if the current
|
||||
;; line is in a /* comment, insert a newline and a * prefix. No
|
||||
;; auto-fill or other smart features.
|
||||
(let ((insert-line-break
|
||||
(lambda ()
|
||||
(delete-horizontal-space)
|
||||
(if soft
|
||||
(insert-and-inherit ?\n)
|
||||
(newline (if allow-auto-fill nil 1))))))
|
||||
(cond
|
||||
;; Line starts with //, or ///, or ////...
|
||||
;; Or //! (used in rust).
|
||||
|
|
@ -313,7 +319,7 @@ and /* */ comments. SOFT works the same as in
|
|||
t nil))
|
||||
(let ((offset (- (match-beginning 0) (line-beginning-position)))
|
||||
(whitespaces (match-string 1)))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(funcall insert-line-break)
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert (make-string offset ?\s) "//" whitespaces)))
|
||||
|
||||
|
|
@ -326,7 +332,7 @@ and /* */ comments. SOFT works the same as in
|
|||
t nil))
|
||||
(let ((offset (- (match-beginning 0) (line-beginning-position)))
|
||||
(whitespace-and-star-len (length (match-string 1))))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(funcall insert-line-break)
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert
|
||||
(make-string offset ?\s)
|
||||
|
|
@ -338,7 +344,7 @@ and /* */ comments. SOFT works the same as in
|
|||
(beginning-of-line)
|
||||
(looking-at (rx (group (* " ") (any "*|") (* " ")))))
|
||||
(let ((prefix (match-string 1)))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(funcall insert-line-break)
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert prefix)))
|
||||
|
||||
|
|
@ -348,9 +354,9 @@ and /* */ comments. SOFT works the same as in
|
|||
(beginning-of-line)
|
||||
(looking-at (rx (* " "))))
|
||||
(let ((whitespaces (match-string 0)))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(funcall insert-line-break)
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert whitespaces)))))
|
||||
(insert whitespaces))))))
|
||||
|
||||
;;; Statement indent
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue