Question: When a new user registers, I would like to give him an gravatar profile image by default, afterwards he should be able to set it manually, so the changeset method should only apply if profile\_img\_url is nil

```
def changeset(model, params \\ :empty) do
  model
  |> cast(...)
  ...
  |> get_gravatar
end

defp get_gravatar(current_changeset) do
  case current_changeset do
    %Ecto.Changeset{valid?: true, *is_nil:* :profile_img_url} ->
         put_change(current_changeset, :profile_img_url, get_somehow_the_gravatar_img(current_changeset))
    _ -> current_changeset
  end
end

```

So basically, the question is, is this the right way to do it, and is there an Ecto mehtod to check if the value is nil or not. (Not only in the changeset, but also in the db)

Answer: 
You will not be able to get clang-format to respect all custom inhouse formatting, and their [documentation on adding new style options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options) is pretty tight. The adoption of clang-format into an existing codebase requires *some* compromising. This is one of those compromises.

I was in your situation, a large codebase with dozens of engineers fixed in their ways and unwilling to change their inhouse coding standard. I had done several large refactors which had weeks of fixing up spacing. Not a good use of time.

I was unable to navigate the politics of standardising the legacy formatting. Clang-Formats adoption was conditional on it respecting our legacy formatting.

My solution was to write a wrapping script which would read the file in, detect the inhouse oddities (in your case, look for a long comment of only '=' and ' ') and sandwich them in clang-format instructions:

```
// clang-format off
// AddedByYourTool
//           Name    Size    Starting val
//           ======= ======= ============
w  = Create( "Dubs", abc,    123 );
x  = Create( "X",    n,      m );
yz = Create( "YZ",   ij / q, kl );
// clang-format on

```

It would then pipe it through clang-format. Then find the AddedByYourTool in the output and remove the surrounding clang-format off. (You need that token so you don't remove existing clang-format offs).

It sucks. It is a horrible solution, but unless you have the power to order that formatting to die, or the political skills to negotiate it to die, or feel like manually reformatting for the rest of your career, it's the only real solution.
As of **clang-format** 13 there is a new `AlignArrayOfStructures` option available
that can help with exactly this.