From: Nikolai Weibull Date: 2005-03-23T09:02:39+09:00 Subject: Re: Any guides for good coding in Ruby? [OT] tabs vs. spaces * Sam Roberts (Mar 23, 2005 00:50): > That's funny, I haven't found that emacs uses spaces to indent by > default. Its supposed to default to the GNU coding standard, though > what it does on any machine is pretty subject to the whims of who > installed it. The emacs standard/GNU indent style is the weirdest > around, IMO. Yes, but you aren't using it in your example: > foo() > { > int ; > > if() > { > ... That would be foo(void) { int i; if () { ... } } And there is a good reason for doing it that way: the name of the function appears in column one, making it easy to grep for and for certain utilities to parse the file. The default indent-size is two spaces, as can be seen in the third line and also note how the curly-brackets are in column 1 for a function body. For the if, the bracket-group is the statement associated with and inside it, code is indented another level. See how consistent it is? See how the bracket-delimited block is indented like a single statement to the if would have been? It's very, very consistent. It's also very, very ugly. > It uses TAB by default (every time indent gets over 8 chars, it uses a > TAB). I've always though the GNU coding style was specified to showcase > the power of the emacs indentation engine. I never got vim to do it, but > I just fed my functions through GNU indent, and whatever it looked like, > I comitted. Can't be acused of not following the GNU coding standards > then, GNU indents output is supposed to follow it! It's very easy to do with vim. Simply leave your 'ts' alone, set 'sw' to 8, don't set 'sts' and don't set 'et'. Those are all default settings by the way. GNU indent can be set to use any of a variety of indentation "standards". It can also be configured to your hearts delight. > I'm averse to indents over about 4, and I think tabs are lame. They work > fine if everybody on your team uses the same settings, but when anybody > else looks at your code, it will look bad. In a perfect world, people would actually use tabs appropriately. Until they do, the best solution is to not use them, nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: minimalistic.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}