CodingStyle

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Wed Mar 5 13:25:30 PST 2014


On Wed, 5 Mar 2014, Dirk Hohndel wrote:
> On Wed, 2014-03-05 at 17:29 +0100, Cristian Ionescu-Idbohrn wrote:
> > On Mon, 3 Mar 2014, Dirk Hohndel wrote:
> > >
> > > OK, I used my lunch break (the things I do for fun...) to tweak
> > > the tool and fixed two odd cases that I noticed when studying
> > > profile.c.
> >
> > And I used my sick leave to do the same :)
> > See attached elisp script subsurface.el.
> > The 'linux-tabs-only' style is (for now) restricted to .[ch] files.
> >
> > > Would you test the emacs auto-generated indentation settings
> > > against the latest?
> >
> > Did that.  The result in not perfect, but there are a few more knobs
> > for further adjustments.
> >
> > It corrects a few indentation problems, makes some indentation
> > glitches obvious and creates new ones ;)
>
> I haven't gone through all of this (675 lines of patches),

Yes.  I wanted to test enough material to get a better idea.

> but I notice a few things that stand out:
>
> - Positioning of a trailing '\'
>
> Hard to get worked up about. The logic in clang-format seems a bit
> inconsistent there - it's what I'm working with

One idea may be to reduce that, as in 's/[[:blank:]]+\\$/ \\/' (just
one blank before the '\' at end-of-line, else it may get chaotic.

> - Positioning of the /* fallthrough */ comment in switch statements
>
> I kinda like it where I had it (lined up with "case" so it stands out
> more)

Yes.  I'll look around and try to find something in that big pile of
elisp scripts.

> - indentation of follow up lines in multi line #define
>
> I actually like neither of the version. In tree right now we have some
> with four space indentation (WTF?) - but your version in some instances
> indents things way too much... I'll need to play with that to find a
> happy medium.

I agree.  I located a knob to reduce that.  Still, can we agree that
each open bracket followed by a '\' introduces a new level of
indentation.

> - alignment of multi line comments with /* and *
>
> That's an improvement. I wonder why this is broken in tree right now
>
> And then there is what your script does to code that is inside of
> comments, where it completely removes indentation. Not cool.

Yes.  The thing is that it wouldn't have done so if _all_ the code
were commented out properly, like in:

	/*
	 * for (i=0; i<columns;++i) {
	 * 	fprintf(stderr, "%s\t", column[i]);
	 * }
	 * fprintf(stderr, "\n");
	 * for (i=0; i<columns;++i) {
	 * 	fprintf(stderr, "%s\t", data[i]);
	 * }
	 * fprintf(stderr, "\n");
	 * //exit(0);
	 */

instead of:

	/*
	for (i=0; i<columns;++i) {
		fprintf(stderr, "%s\t", column[i]);
	}
	fprintf(stderr, "\n");
	for (i=0; i<columns;++i) {
		fprintf(stderr, "%s\t", data[i]);
	}
	fprintf(stderr, "\n");
	//exit(0);
	*/

The latter will be indented as 'all is a comment' and not 'a comment
with some code in between'.

Emacs has an useful command: `comment-or-uncomment-region'.  One
would use that for convenience.

> > Well, why not let people take a look and improve the elisp script.
>
> > > And add them to CodingStyle if they seem to work?
> >
> > Shouldn't I wait a while to give people time to play with it?
> >
> > If I were to add subsurface.el to the repository I would put it in the
> > scripts directory.
>
> BTW, just to make sure there's no misunderstanding. Are you suggesting
> switching to the .el script as the 'reference implementation of the
> coding style'?

No, it's not what I'm suggesting.  You're the maintainer.  You decide.

What I'm suggesting is that people using emacs play with the script
and contribute to make the it more useful.


Cheers,

-- 
Cristian


More information about the subsurface mailing list