Page MenuHomePhabricator

[emacs] Indent statement continuation to match clang-format
ClosedPublic

Authored by asavonic on Jul 24 2018, 5:39 AM.

Details

Summary

Was:

int LongVariableName =
  veryLongFunctionNameThatExceeds80ColumnsRule(SomeParameter);

int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
  .nowThisDoesntFit()
  .andThis()

Now:

int LongVariableName =
    veryLongFunctionNameThatExceeds80ColumnsRule(SomeParameter);

int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
                   .nowThisDoesntFit()
                   .andThis()

Diff Detail

Repository
rL LLVM

Event Timeline

asavonic created this revision.Jul 24 2018, 5:39 AM

+1 for this functionality. I'm not enough of a C-mode guru to know if the implementation is correct.

MaskRay added inline comments.Jul 30 2018, 9:43 AM
utils/emacs/emacs.el
14 ↗(On Diff #157010)

How about

(statement-cont . c-lineup-assignments)
asavonic updated this revision to Diff 158195.Jul 31 2018, 3:02 AM

Use c-lineup-assignment.

asavonic added inline comments.Jul 31 2018, 3:04 AM
utils/emacs/emacs.el
14 ↗(On Diff #157010)

Thanks, your reference `c-lineup-assignments' helped me find another
pattern for which our current style does not work:

// no statement-cont
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
  .nowThisDoesntFit()
  .andThis()
/* clang-format:
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
                   .nowThisDoesntFit()
                   .andThis()
*/

`c-lineup-assignments' helps here, but we need more indentation for
subsequent lines:

// (statement-cont . c-lineup-assignments)
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
               .nowThisDoesntFit()
               .andThis()
/* clang-format:
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
                   .nowThisDoesntFit()
                   .andThis()
*/

So I used a custom function to handle this:

// (statement-cont . llvm-lineup-statement)
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
                   .nowThisDoesntFit()
                   .andThis()
/* clang-format:
int ShortVar = veryLongFunctionNameThatStillFitsIntoOneLine(SomeParameter)
                   .nowThisDoesntFit()
                   .andThis()
*/
asavonic edited the summary of this revision. (Show Details)Jul 31 2018, 3:05 AM
MaskRay accepted this revision.Jul 31 2018, 10:09 AM
This revision is now accepted and ready to land.Jul 31 2018, 10:09 AM

Can you commit?

I've requested a commit access from Chris, and hopefully I will commit this patch soon. Otherwise I'll ask someone to commit it.
Thanks for the review!

This revision was automatically updated to reflect the committed changes.