Member
Member
jsumners   2008-02-14, 01:51
#1

Is there a defined set of rules for ZenPhoto's source code formatting? I've noticed that the line endings are a mixup of Windows and Unix. I've also noticed that the indentation is manually spaced?

Developer
Developer
trisweb   2008-02-14, 03:13
#2

I've been meaning to write this up formally, but in general:

  • 2-space tabs, manual spaces.
  • Good C-style syntax ala K&R ( http://en.wikipedia.org/wiki/Indent_style#K.26R_style ) with some minor modifications, namely function braces are to be on the same line (as this looks better for PHP).
  • Liberal use of space (between names/brackets, operators, lines, etc)
  • Line endings should be Unix only, I'll fix this.

I am considering switching to tabbed tabs only, as there's too much variation right now. When it was just me it didn't matter as all my tabs were the same, but now for each to have their own tab-size preferences, I think it'd be better to have hard tabs.

All of these are easy to fix with jEdit and a couple regexps. :-)

Developer
Developer
trisweb   2008-02-14, 05:45
#3

Just changed the entire Zenphoto source to use hard tabs instead of spaces. I've been meaning to do that for a long time.

Haven't figured out the win vs. unix line ending thing, but I'll let you know when I do. In any case it shouldn't affect the program (clearly).

Member
Member
jsumners   2008-02-14, 15:26
#4

Essentially, wherever there is a CRLF the CR needs to be removed. The easiest way to do it is to feed every file to dos2unix. I can create an SVN diff if you would like. I submitted one patch already, but it is out of date now.

The hard tabs will save my sanity. Thank you

Member
Member
jsumners   2008-02-14, 21:39
#5

Why did you revert [1115]? Does someone not have a tab key?

Developer
Developer
trisweb   2008-02-15, 00:08
#6

We're waiting until Stephen checks in a large chunk, then the tabs will replace on that section as well, and there will be fewer merging issues.

Just doing the whole shebang at once.

Member
Member
jsumners   2008-02-15, 01:23
#7

Ah, okay. You might want to wait on the purge cache patch I submitted then. It conforms to [1115].

Member
Member
sbillard   2008-02-15, 01:42
#8

It is part of the changes I was doing.

Member
Member
jsumners   2008-02-15, 02:34
#9

I see that. You might want to provide some feedback to the user that the script has actually run. That is the only difference between my implementation and yours.

Member
Member
jlang   2008-02-15, 22:06
#10

While I agree that it's better to have some consistency in the source base, personally I'd prefer it to be spaces to tabs. There's no standard tabstop value - they vary widely across users/printers and applications. Users can be said to make their own choice, but many don't and the defaults is generally 4 or 8 spaces per tab. HTML/PHP code results in lots of nesting and it just crawls too far across the screen - as an example, the diffs on Trac seem to have 7 spaces per tab and are definitely harder to read when the code has hard tabs than 2 or three spaces.
http://www.zenphoto.org/trac/changeset/1124
Anyway, I'm not that bothered myself, but I just thought I'd express an alternative opinion.

Member
Member
jsumners   2008-02-15, 23:08
#11

Spaces for tabs are insanely annoying. They make navigating the code a real pain. I can understand wanting to use them when 80 characters is all that would fit on the screen, but it's a silly concept now.

Developer
Developer
trisweb   2008-02-16, 11:37
#12

Yes, even with nesting the tabs make more sense -- you can set your tabs to be whatever width you want in your editor, and have it your way

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.