ZenPhoto source code formatting

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?

Comments

  • trisweb Administrator
    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. :-)
  • trisweb Administrator
    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).
  • 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 :)
  • Why did you revert [1115]? Does someone not have a tab key?
  • trisweb Administrator
    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.
  • Ah, okay. You might want to wait on the purge cache patch I submitted then. It conforms to [1115].
  • It is part of the changes I was doing.
  • 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.
  • 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.
  • 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.
  • trisweb Administrator
    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 :)
Sign In or Register to comment.