On 14 Apr 2009, at 06:57, Trent W. Buck wrote:

1. Add Emacs and vim noise to the bottom of each file, so that
   people using these editors automatically get the right thing,
   even if their global defaults are wrong.  For example

I use TextMate, and I don't think there's an equivalent for this. But what I'm actually describing is more about lining up existing data, than enforcing whitespace rules. Another example, this file:

class Response
  include DataMapper::Resource

  property :id,       Serial
  property :response, Integer,  :nullable => false
  property :made_at,  Time,     :nullable => false

  # ...
end

Is lined up for readability.  But if someone adds the line:

class Response
  include DataMapper::Resource

  property :id,       Serial
  property :response, Integer,  :nullable => false
  property :made_at,  Time,     :nullable => false
  property :some_really_long_name, String

  # ...
end


the formatting is thrown, and all the lines need reformatting:

class Response
  include DataMapper::Resource

  property :id,                    Serial
  property :response,              Integer,  :nullable => false
  property :made_at,               Time,     :nullable => false
  property :some_really_long_name, String

  # ...
end


which would conflict with an unrelated change to, say, the "response" property (eg)

class Response
  include DataMapper::Resource

  property :id,       Serial
  property :response, Integer,  :nullable => false, :default => 0
  property :made_at,  Time,     :nullable => false, :default => ...

  # ...
end

This sort of thing happens to me *all the time*. Maybe it's more prevalent in some languages than others? (Almost everything I do is in Ruby.)


2. If it gets to be a real problem, add a pre-commit hook that refuses
    to commit / push patches that contain "wrong" whitespace.
    Something like,

    darcs setpref test ! grep -r --exclude-dir _darcs \\t .

Again, that sort of thing could be useful. (One person I work with has an interest in a script that checks for trailing whitespace.) But it's actually a separate issue, as it's about universal rules, rather than local formatting.

Thanks
Ashley

--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
http://aviewfromafar.net/
http://twitter.com/ashleymoran






_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to