Re: Fixing indentation in our source files
On 2011-09-09 22:36, Russ Allbery wrote: Jakub Wilk jw...@debian.org writes: Yes, a few files have a cperl-indent-level: 8 declaration. On the other hand, some of them have also contradictory vim: ts=4 declaration. :( Personally I'd prefer 4*space indentation everywhere. I could live with tabs, but tabs mixed with spaces make me cringe. I'm basically in the same camp, although the most important thing to me for tab/space policy is that the right Emacs gunk is in the file so that the right thing happens automatically. But in general I use four-space indents and never put tabs in files. So we are looking at a 4 space indentation for each basic block? if ($a) { do_stuff(); } How about extended ifs? if(some very long condition even more condition) do_stuff(); } - and - do_stuff unless some very long condition even more condition; Would that be 4 spaces from the indentation (as shown above) or 4 spaces from the base line (would align the even more condition in the first part with do_stuff())? Alternatively do we do something different there? Are there other cases worth considering/debating? ~Niels -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e6b0094.6040...@thykier.net
Re: Fixing indentation in our source files
Niels Thykier ni...@thykier.net writes: So we are looking at a 4 space indentation for each basic block? if ($a) { do_stuff(); } Yeah. How about extended ifs? if(some very long condition even more condition) do_stuff(); } I'm agnostic on that. 8-space indents are often clearer, even if inconsistent somewhat. - and - do_stuff unless some very long condition even more condition; I would tend to write this as: do_stuff unless (some very long condition even more condition); since the parens make Emacs keep the indentation consistent, but I'm agnostic on this too. Although even better would be to find ways of avoiding writing things like this, since I think they're inherently harder to read compared to pulling the condition into a sub or assigning it to a variable with a reasonable name. Are there other cases worth considering/debating? There's oodles of stuff one can run into. Just as random input (I'm definitely not advocating that we adopt this as an official coding style), my personal Perl style is at: http://www.eyrie.org/~eagle/notes/style/perl.html It's easy to spend way too much time discussing this sort of thing than it's actually worth. -- Russ Allbery (r...@debian.org) http://www.eyrie.org/~eagle/ -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/874o0kvrmo@windlord.stanford.edu
Re: Fixing indentation in our source files
On 2011-09-10 08:27, Russ Allbery wrote: Niels Thykier ni...@thykier.net writes: [...] Are there other cases worth considering/debating? There's oodles of stuff one can run into. Just as random input (I'm definitely not advocating that we adopt this as an official coding style), my personal Perl style is at: http://www.eyrie.org/~eagle/notes/style/perl.html From my memory, we seem to (often) be following reasonable part of your list. Not very surprisingly and I have found myself to refer to it a while back when I was in doubt about something. That being said we probably have inconsistent style a lot of places as well. :) It's easy to spend way too much time discussing this sort of thing than it's actually worth. I guess it is just a question of somebody sitting down and writing a draft for a style... any volunteers? If not I will have a look at it. ~Niels -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e6b2660@thykier.net
Re: Fixing indentation in our source files
Niels Thykier ni...@thykier.net writes: Jakub pointed out that a some of our source files have inconsistent. He also produced the attached document that visualize the different indentation styles in our code (Tttt is one tab and s is a space). So would anyone object if I sed s/\t//g'ed our code (with manual fixup where needed). It could (and probably will) give issues applying any existing patches (on the BTS). I'm always of two minds about this kind of thing since it makes any merging or patch application across the change a huge pain, but I like having consistency. I was mostly leaving things alone except when we mostly rewrote a file, but that doesn't get us anywhere particularly quickly. If we're going to do a mass indentation fix and take the hit for that, it would be tempting to standardize on an identation level as well. I think we have some files that are using an eight-space indent. -- Russ Allbery (r...@debian.org) http://www.eyrie.org/~eagle/ -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87fwk5si2j@windlord.stanford.edu
Re: Fixing indentation in our source files
* Russ Allbery r...@debian.org, 2011-09-09, 11:10: Jakub pointed out that a some of our source files have inconsistent. He also produced the attached document that visualize the different indentation styles in our code (Tttt is one tab and s is a space). So would anyone object if I sed s/\t//g'ed our code (with manual fixup where needed). It could (and probably will) give issues applying any existing patches (on the BTS). Patches in the BTS should be a big issue. You just need to remember to do the same transformation on them before applying. :) If we're going to do a mass indentation fix and take the hit for that, it would be tempting to standardize on an identation level as well. I think we have some files that are using an eight-space indent. Yes, a few files have a cperl-indent-level: 8 declaration. On the other hand, some of them have also contradictory vim: ts=4 declaration. :( Personally I'd prefer 4*space indentation everywhere. I could live with tabs, but tabs mixed with spaces make me cringe. -- Jakub Wilk -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110909201008.ga...@jwilk.net
Re: Fixing indentation in our source files
Jakub Wilk jw...@debian.org writes: Yes, a few files have a cperl-indent-level: 8 declaration. On the other hand, some of them have also contradictory vim: ts=4 declaration. :( Personally I'd prefer 4*space indentation everywhere. I could live with tabs, but tabs mixed with spaces make me cringe. I'm basically in the same camp, although the most important thing to me for tab/space policy is that the right Emacs gunk is in the file so that the right thing happens automatically. But in general I use four-space indents and never put tabs in files. -- Russ Allbery (r...@debian.org) http://www.eyrie.org/~eagle/ -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87sjo5qwpt@windlord.stanford.edu