[Courses] Style (was Lesson Three: Basic Declarations&Expressions)

Akkana akkana at shallowsky.com
Mon Oct 14 16:11:12 EST 2002


Jenn Vesperman writes:
> I believe that the aspects which can be easily changed by a machine
> (where the braces are, indentation levels) shouldn't be strictly
> enforced in a project.

It depends on the project, of course; but if a project is managed
by CVS or a similar version control system, then if you reformat that
file for your own reading pleasure, then later cvs commit that file
because you changed one line of code, as far as CVS is concerned you
now own nearly every line of that file.  Also, if you reformat a
file before working on it, cvs diff (even if you use the -w argument
to ignore whitespace) may think you changed a lot more lines than
you actually did.

Much easier to just agree on a style and everybody learn to read
and write that style (for files contained within the project).
If you find it really hard to read the project's normal style,
then sure, reformat in your tree; but do that at the risk of having
to do extra work when checkin time comes.

Malcolm-Rannirl writes:
> I think you want:
>  set shiftwidth=4	(or set sw=4)
>  set tabstop=8	(set ts=8)
> 
> (but I don't use emacs, so I'm not entirely sure what those modelines do).

The advantage of mode lines is that they can be different for every file,
and emacs sets it automatically rather than my having to set variables by
hand.  I can set up my own preferences in my .emacs file, but if I edit
a mozilla file it will have a modeline that tells emacs to use mozilla
indentation, and I can have mozilla files and kernel files (if the
kernel used modelines, which alas it doesn't) and my own files all
open at once and emacs will use the right mode/indentation in each.

	...Akkana



More information about the Courses mailing list