mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Make c-ts-common-comment-indent-new-line work for more cases
* lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line): Handle the case where user types M-j in the middle of a line; and when the line starts with /**.
This commit is contained in:
parent
81391ae3f5
commit
ecf15513ea
1 changed files with 10 additions and 6 deletions
|
|
@ -292,27 +292,31 @@ and /* */ comments. SOFT works the same as in
|
|||
;; line is in a /* comment, insert a newline and a * prefix. No
|
||||
;; auto-fill or other smart features.
|
||||
(cond
|
||||
;; Line starts with //
|
||||
((save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at (rx "//" (group (* " ")))))
|
||||
(let ((whitespaces (match-string 1)))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(delete-region (point) (line-end-position))
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert "//" whitespaces)))
|
||||
|
||||
;; Line starts with /* or /**
|
||||
((save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at (rx "/*")))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(delete-region (point) (line-end-position))
|
||||
(insert " *"))
|
||||
(looking-at (rx "/*" (group (? "*") (* " ")))))
|
||||
(let ((whitespace-and-star-len (length (match-string 1))))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert " *" (make-string whitespace-and-star-len ?\s))))
|
||||
|
||||
;; Line starts with *
|
||||
((save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at (rx (group (* " ") (or "*" "|") (* " ")))))
|
||||
(let ((prefix (match-string 1)))
|
||||
(if soft (insert-and-inherit ?\n) (newline 1))
|
||||
(delete-region (point) (line-end-position))
|
||||
(delete-region (line-beginning-position) (point))
|
||||
(insert prefix)))))
|
||||
|
||||
;;; Statement indent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue