dfmt icon indicating copy to clipboard operation
dfmt copied to clipboard

infer format option by providing a formatted example

Open timotheecour opened this issue 9 years ago • 3 comments

It would be nice if there'd be an option to infer (most of the) format options by providing an example:

void fun () {
  int a = b + c;
  if (a) fun();
}

The parser would infer the parameters, eg:

  • space around operators
  • one-liners allowed

It would reject the example if the inferred options would not be idem-potent (ie if the formatting the input via the inferred options would change the input).

timotheecour avatar Jul 08 '15 02:07 timotheecour

The odds of me implementing this are incredibly low.

Hackerpilot avatar Jul 08 '15 03:07 Hackerpilot

it's by no mean urgent, could be picked up later by someone else if there's more interest.

timotheecour avatar Jul 08 '15 04:07 timotheecour

clang-format started with the idea that this is the main use case. Infer style from input file via "majority voting" and then unify the style. Turned out that an external style definition is the main use case.

qznc avatar Aug 06 '15 21:08 qznc