Emacs CC-Mode Indent c-block-comment-ender Differently

Viewed 58

TL;DR:
I want emacs to indent C block comments like this:

/*
  Lorem Ipsum Dolor
  Sit Amet
*/

Not this:

/*
  Lorem Ipsum Dolor
  Sit Amet
  */

What do?


I have the following as part of my cc-mode style:

(c-add-style
  "jf-cc-mode-style"
  '(
     (c-tab-always-indent        . t)
     (c-comment-only-line-offset . 0)
     (c-offsets-alist . (
       (c             . 2)
       (comment-intro . 0)
     )
   )

But I have not been able to find anything in the docs about being able to set the indentation for the comment end (*/) to something different. Changing the value of c does of course change it, but this also affects the middle lines too.


Follow up: Can I also have it indent specific non-empty comment-ends to column 0?

/*
  Lorem Ipsum Dolor
  Sit Amet
M*/
// or
/*
  Lorem Ipsum Dolor
  Sit Amet
C*/

not

/*
  Lorem Ipsum Dolor
  Sit Amet
  M*/
// or
/*
  Lorem Ipsum Dolor
  Sit Amet
  C*/

I suppose I can advise c-lineup-C-comments to also match a regexp, but maybe there's a cleaner way?

0 Answers
Related