BRIEFEST:
The original question boiled down to:
Many if not most emacs c indentation styles make comments on a line by themselves, e.g.
// ...
indent to match the surrounding code.
I want to make comments that look like //+ or //- be indented one or more indent settings more than the surrounding code.
I usually think of this in terms of having same-indentation-level comments apply to the next lines of code, and extra-indentation-level comments apply to preceding lines of code. But that's just style.
BRIEF:
Are there (reasonably standard) emacs settings to obtain different indentation for C/C++ comments, depending on whether the comment is associated with the next line (in which case I want it indented appropriately for the syntax) or whether the comment is associated with the previous line (in which case I want it indented an additional level)?
E.g.
int
foo()
{
// this comment is for the variable bazz below
int bazz;
//- this comment is for the variable bazz,on the line above.
//- I want it indented an extra level, which I will do by hand here.
// this comment is for the next variable, biff
int biff;
int example; /* comment
* on multiple lines
* but this can be too much indented
*/
int example_of_a_really_long_name_that_can_produce_excessive_indentation; /* comment
* on multiple lines
* but this can be too much indented
*/
}
The comments beginning //and //- are pretty much what I want. // is indented along with the surrounding code. This is what emacs gives me.
I would like //- to be indented an extra indentation level. Or //+,or whatever, if there is a convention. Sounds like a job for a regexp.
I provide examples of what I know how to do for // and /. The / comments get spread over multiple lines, but can be excessively indented.
DETAIL:
I am just now installing emacs 24.1 - or at least I hope I am installing it, the systems at work have very old and crankly distros. But if something works on older emacs, such as 21.4.1, I'd e even happier - avoiding the hassle of having to install emacs on many different systems.
================================
By the way, I already know about c-indent-comment-syntactically, and much of cc-mode.el.
In particular, c-indent-comment-syntactically gives me:
int
foo()
{
// this comment is for the variable bazz below
int bazz;
//- this comment is for the variable bazz,on the line above.
//- I want it indented an extra level, which I will do by hand here.
// this comment is for the next variable, biff
int biff;
int example; /* comment
* on multiple lines
* but this can be too much indented
*/
int example_of_a_really_long_name_that_can_produce_excessive_indentation; /* comment
* on multiple lines
* but this can be too much indented
*/
if( foo )
// comment
bar();
if( foo ) {
// comment
bar();
}
}
This is not what I want. I want the //- comment lines to be indented an extra indent level.
Heck, why not something like elisp:
/// <-- start in columno 0
// indented syntactically (pertaining to next line of code)
or perhaps //^ (the ^ indicates "above".
//- or //^ - indented an extra indent level (pertaining to previous line of code.
