danielpoe
danielpoe

Reputation: 3816

Indent C block comments in Emacs

I'm trying to configure emacs to indent my C block comments nicely.

Emacs (22.3) does by default (regardless of the indentation style):

/* My very long comment which spreads over multiple lines
* and thus needs to be filled.
*/

But what I would highly prefer is:

/* My very long comment which spreads over multiple lines
 * and thus needs to be filled.
 */

I tried to play around with c-offset-alist and the syntactical symbol `c', but it didn't help me understand the problem:

(c-add-style "mine"
             '((c-basic-offset . 2)
               (c-block-comment-prefix . "* ")
               (c-offsets-alist
                (c . +)))
             )

Any ideas? Thanks in advance!

Cheers, Daniel

Upvotes: 6

Views: 2417

Answers (2)

scottfrazer
scottfrazer

Reputation: 17327

Hm, it works here with 22.3.1 and starting with the '-Q' option which doesn't load any personal or site lisp files. Sorry to not be much help, but I think it's your setup. Try doing 'emacs -Q' and see if you still see the same problem.

Upvotes: 3

Dortz
Dortz

Reputation: 177

You can try just changing the c-block-comment-prefix to " * ",

or make sure c-comment-prefix-regexp is '//+\\ | \\**'.

Here is the relevant GNU.org CC Mode man page.

Upvotes: 0

Related Questions