6464 :group 'swift
6565 :safe 'integerp )
6666
67+ ;;;### autoload
68+ (defcustom swift-mode:prepend-asterisk-to-comment-line nil
69+ " Automatically insert a asterisk to each comment line if non-nil."
70+ :type 'boolean
71+ :group 'swift
72+ :safe 'booleanp )
73+
6774;;;### autoload
6875(defcustom swift-mode:insert-space-after-asterisk-in-comment t
6976 " Automatically insert a space after asterisk in comment if non-nil."
@@ -1528,7 +1535,11 @@ See `indent-new-comment-line' for SOFT."
15281535 (is-single-line-comment (eq (nth 7 parser-state) 1 ))
15291536 (comment-beginning-position (nth 8 parser-state))
15301537 (space-after-asterisk
1531- (if swift-mode:insert-space-after-asterisk-in-comment " " " " )))
1538+ (if swift-mode:insert-space-after-asterisk-in-comment " " " " ))
1539+ (default-line-prefix
1540+ (if swift-mode:prepend-asterisk-to-comment-line
1541+ (concat " *" space-after-asterisk)
1542+ " " )))
15321543 (delete-horizontal-space )
15331544 (if soft (insert-and-inherit ?\n ) (newline 1 ))
15341545 (delete-horizontal-space )
@@ -1539,8 +1550,8 @@ See `indent-new-comment-line' for SOFT."
15391550 (is-single-line-comment
15401551 (save-excursion
15411552 (goto-char comment-beginning-position)
1542- (looking-at " /+" )
1543- (concat ( match-string-no-properties 0 ) space-after-asterisk )))
1553+ (looking-at " /+\\ s * " )
1554+ (match-string-no-properties 0 )))
15441555
15451556 (comment-multi-line
15461557 (save-excursion
@@ -1550,13 +1561,14 @@ See `indent-new-comment-line' for SOFT."
15501561 (if (<= (point ) comment-beginning-position)
15511562 ; ; The cursor was on the 2nd line of the comment.
15521563 ; ; Uses default prefix.
1553- ( concat " * " space-after-asterisk)
1564+ default-line-prefix
15541565 ; ; The cursor was on the 3nd or following lines of
15551566 ; ; the comment.
15561567 ; ; Use the prefix of the previous line.
15571568 (back-to-indentation )
1558- (if (looking-at " \\ *+" )
1559- (concat (match-string-no-properties 0 ) space-after-asterisk)
1569+ (if (and swift-mode:prepend-asterisk-to-comment-line
1570+ (looking-at " \\ *+\\ s *" ))
1571+ (match-string-no-properties 0 )
15601572 " " ))))
15611573
15621574 (t
@@ -1565,8 +1577,8 @@ See `indent-new-comment-line' for SOFT."
15651577 (forward-char )
15661578 (save-excursion
15671579 (goto-char comment-beginning-position)
1568- (looking-at " /\\ *+" )
1569- (concat ( match-string-no-properties 0 ) space-after-asterisk ))))))
1580+ (looking-at " /\\ *+\\ s * " )
1581+ (match-string-no-properties 0 ))))))
15701582 (indent-according-to-mode )
15711583
15721584 ; ; Closes incomplete multiline comment.
@@ -1585,6 +1597,7 @@ See `indent-new-comment-line' for SOFT."
15851597 ; ; Indents electrically and insert a space when "*" is inserted at the
15861598 ; ; beginning of a line inside a multiline comment.
15871599 ((and
1600+ swift-mode:prepend-asterisk-to-comment-line
15881601 (= last-command-event ?* )
15891602 (nth 4 (syntax-ppss ))
15901603 (save-excursion (backward-char ) (skip-syntax-backward " " ) (bolp )))
@@ -1601,7 +1614,7 @@ See `indent-new-comment-line' for SOFT."
16011614 (let ((pos (point )))
16021615 (beginning-of-line )
16031616 (and
1604- (looking-at " ^[ ] *\\ *[ ] +/" )
1617+ (looking-at " ^\\ s *\\ *\\ s +/" )
16051618 (eq (match-end 0 ) pos)
16061619 (swift-mode:incomplete-comment-p)))))
16071620 (backward-char )
0 commit comments