|
![]() |
#1 |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
Coding standard? Indentation?
I keep making a mess of indentation whenever I touch a C file from Angband, so I wonder what I should set up my Emacs to (or Eclipse, or 'indent' utility). I see a year ago I had the following conversation on the NPP forum, but now that V is again active I wonder if there are any opinions...
> > > Merry Christmas! > > > > > > wonder what coding standards do you adhere to. > > > E.g. GNU (http://www.gnu.org/prep/standards/standards.html)? Any other? > > > > > > Also, I wonder what indentation you use: GNU, K&R? Spaces or tabs for indents? > > > 4-wide or 8-wide tabs? What was the original standard of Moria? > > > Of Ben Harrison's Vanillia? Do you ever use > > > the indent utility to maintain a single format? > > > > > > BTW, is NPP os a CVS/SVN somewhere? > > > > > > Thanks a lot! > > > > CJN: AFAIK, most *bands, including NPP, use K&R style with 8-wide tabs and tab for indent. > > > > Bad, bad, bad. But at least the tab width is standard --- > however the text must go off 80 characters wide terminal very often... > Hmm, from the look of the code it's not pure K&R. Obviously not GNU, too. > I guess everybody indents as he likes... |
![]() |
![]() |
![]() |
#2 | |
Veteran
Join Date: Apr 2007
Posts: 1,951
Donated: $40
![]() |
Quote:
|
|
![]() |
![]() |
![]() |
#3 | |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
A very nice article. It says
Quote:
Supposedly (Wikipedia) Code:
indent somefile.c -st -bad --blank-lines-after-procedures -bli0 -i4 -l79 \ -ncs -npcs -nut -npsl -fca -lc79 -fc1 Emacs can be set up for BSD/Allman probably just with Code:
'(c-default-style (quote ((c-mode . "bsd") (c++-mode . "bsd")))) '(c-basic-offset 3) '(standard-indent 3) '(tab-width 3) ![]() Edit: more emacs code Last edited by Bandobras; December 22, 2007 at 00:56. |
|
![]() |
![]() |
![]() |
#4 | ||
Veteran
Join Date: Apr 2007
Posts: 1,951
Donated: $40
![]() |
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#5 |
Administrator
|
Tabs are ment to be eight spaces wide
![]() That said, it does not matter much on a 300+ columns terminal. ![]()
__________________
See the elves and everything! http://angband.oook.cz |
![]() |
![]() |
![]() |
#6 |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
Those wide-screen monitors?
|
![]() |
![]() |
![]() |
#7 |
Administrator
|
Pretty wide. Good for coding, bad for scrollback.
__________________
See the elves and everything! http://angband.oook.cz |
![]() |
![]() |
![]() |
#8 | |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
Quote:
Code:
int v = MY_CONST * (wieeerd_struct->loooooooooooong_field + wieeerd_struct->longeeeeeeeeeeeeeeeeeer_field - wieeerd_struct->medium_field) P.S. A simpler example: Code:
int v = (wieeerd_struct->loooooooooooong_field + wieeerd_struct->longeeeeeeeeeeeeeeeeeer_field - wieeerd_struct->medium_field) Last edited by Bandobras; March 21, 2008 at 23:54. |
|
![]() |
![]() |
![]() |
#9 | |
Veteran
Join Date: Apr 2007
Posts: 1,951
Donated: $40
![]() |
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
Ha, so this is emacs fault --- it does not let me mix tabs and spaces with default settings. Instead it fits as many tabs as it can and then a few spaces. Of course it's configurable, for sure...
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|