;; `comment-prefix' on a line and indent it to find the
;; correct column and the correct mix of tabs and spaces.
(setq res
- (let (tmp-pre tmp-post)
+ (let (tmp-pre tmp-post at-close)
(unwind-protect
(progn
(goto-char (car lit-limits))
(if (looking-at comment-start-regexp)
- (goto-char (min (match-end 0)
- comment-text-end))
+ (progn
+ (goto-char (min (match-end 0)
+ comment-text-end))
+ (setq
+ at-close
+ (looking-at c-block-comment-ender-regexp)))
(forward-char 2)
(skip-chars-forward " \t"))
(save-excursion
(skip-chars-backward " \t")
(point))
- (point)))))
-
+ (point))))
+ ;; If hard up against the comment ender, the
+ ;; prefix must end in at least two spaces.
+ (when at-close
+ (or (string-match "\\s \\s +\\'" comment-prefix)
+ (setq comment-prefix
+ (concat comment-prefix " ")))))
(setq tmp-pre (point-marker))
;; We insert an extra non-whitespace character
(c-collect-line-comments c-lit-limits))
c-lit-type)))
(pos (point))
- (start-col (current-column))
(comment-text-end
(or (and (eq c-lit-type 'c)
(save-excursion
(goto-char (+ (car c-lit-limits) 2))))
(funcall do-line-break)
(insert-and-inherit (car fill))
- (if (> (current-column) start-col)
- (move-to-column start-col)))) ; can this hit the
- ; middle of a TAB?
+ (if (and (looking-at c-block-comment-ender-regexp)
+ (memq (char-before) '(?\ ?\t)))
+ (backward-char)))) ; can this hit the
+ ; middle of a TAB?
;; Inside a comment that should be broken.
(let ((comment-start comment-start)
(comment-end comment-end)