<div dir="ltr">I don't know anything about that, don't use ObjC myself. The main problem will be finding someone who can maintain this in the long(er) run. Adding Nico for additional thoughts.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 24, 2015 at 9:25 AM, Yavuz Nuzumlalı <span dir="ltr"><<a href="mailto:manuyavuz@gmail.com" target="_blank">manuyavuz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Daniel,<div dir="ltr"><br></div><div dir="ltr">Are you OK with an option like "ObjCColonAlignMultipleBlocks" which aligns multiple block arguments from colon. I think this is needed because aligning multiple block arguments from colon character is so common in Objective-C community. It's also the default indentation behavior of Xcode. </div><div dir="ltr"><br></div><div>We can still set this to false by default, but could provide an option to disable that behavior? </div><div><br></div><div>I've done an implementation internally, if you're OK and suggest a proper key, I can send a patch for it.  </div><div><div class="h5"><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 14, 2015 at 1:16 PM Daniel Jasper via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 14, 2015 at 9:43 AM, manuyavuz <span dir="ltr"><<a href="mailto:yavuz.nuzumlali@gmail.com" target="_blank">yavuz.nuzumlali@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div>On 13 Dec 2015, at 20:15, Daniel Jasper <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 13, 2015 at 6:53 PM, Yavuz Nuzumlalı <span dir="ltr"><<a href="mailto:manuyavuz@gmail.com" target="_blank">manuyavuz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div style="white-space:pre-wrap"></div><div dir="auto" style="word-wrap:break-word">Thanks for the response Daniel,<div><br></div><div>Could you guide me on where can I look inside clang-format implementation to see how clang-format currently handles lambdas in other languages, so that I may try to implement the same functionality for Objective-C case?</div></div></div></div></blockquote><div><br></div><div>Not really, it is all in ContinuationIndenter.cpp. However, this is among the most complex code of clang-format and giving you details on how to do this probably would take me longer than looking at this myself. If you still want to try and take a look, feel free. I am happy to answer any specific questions you might have.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="auto" style="word-wrap:break-word"><div><br></div><div>Besides that, I have one more question, which is somewhat related to topic.</div><div><br></div><div>When I try to use clang-format to format the following simple code:<br><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">- (void)asdf {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap"> </span>[UIView animateasdfasdf:0 animations:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">     </span>[UIView animations:^{ } done:YES];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">      </span>[UIView animations:^{ } completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">       </span>[UIView testasdfasdfsd:YES animations:^{ } completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">    </span>[UIView animations:^{ } tessd:YES completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><br></div><div>Output is the following:<br><br><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal">- (void)asdf {</div><div style="margin:0px;line-height:normal">  [UIView animateasdfasdf:0</div><div style="margin:0px;line-height:normal">               animations:^{</div><div style="margin:0px;line-height:normal">               }];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">                done:YES];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">  [UIView testasdfasdfsd:YES</div><div style="margin:0px;line-height:normal">      animations:^{</div><div style="margin:0px;line-height:normal">      }</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">      tessd:YES</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">}</div></div><span><div><span><br></span></div></span></div></div></div></div><div dir="auto" style="word-wrap:break-word"><div><div><div><span>I think clang-format somehow decides to not use colon alignment but align using `</span>ContinuationIndentWidth` where there are more than one block parameters.</div><div><span>Is this an intended behavior? Seems like a bug to me.</span></div></div></div></div></blockquote><div><br></div><div>It is intentional. Column alignment with more than one internal block doesn't really work. And this is also explicitly written in Google's style guide: <a href="https://google.github.io/styleguide/objcguide.xml#Blocks" target="_blank">https://google.github.io/styleguide/objcguide.xml#Blocks</a></div><div><br></div><div>Independent of that some of you examples look like there are still other bugs in there.</div><div><br></div></div></div></div></div></blockquote></div></div>I carefully read the google style guide, and behavior about multiple inline blocks seems reasonable now. <div>However, I still feel it's not fully consistent because of the third method call example above. </div><div>I think that case should have something like the following format in order to be consistent across the code:</div><span><div><br></div><div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">[UIView </div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    animations:^{</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    }</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    completion:^{</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    }];</div></div></span></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>As I mentioned in my previous email, there are cases in your example that look buggy to me. I was just stating that in general, this is intended.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><div>Also there is another case in which formatting messes completely:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  [UIView animateWithDuration:123 delay:123 usingSpringWithDamping:123 initialSpringVelocity:123 options:123 animations:^{ } completion:^(BOOL finished){ }];</div></div><div><br></div><div>becomes this:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">  [UIView animateWithDuration:123</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      delay:123</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      usingSpringWithDamping:123</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      initialSpringVelocity:123</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      options:123</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      animations:^{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      completion:^(BOOL finished){</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">      }];</div></div><div><br></div><div>Is this (cancelling colon alignment also for non-block parameters ) also intentional?</div></div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It is intended and I think it makes sense. However, I have never worked on ObjC code, so my understanding of the pros and cons is *very* limited.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><div>If so, I understand that clang-format will apply standard `ContinuationIndentWidth` value whenever a method call includes more than one inline blocks.</div><div><br></div><div>I question this scenario too much because the above code is a frequent code block to animate views on screen, and having a consistent behavior is important in order to use clang-format’s automatic formatting without any hesitancy</div></div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Sure, I understand. But as I mentioned above, I might actually not be the best person to ask. As the main author of clang-format, I try to support ObjC on a best-effort basis, without understanding much of it. There is also limited time I can spend on this at least in the foreseeable future.</div><div><br></div><div>Cheers</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Daniel</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><div><div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto" style="word-wrap:break-word"><div><span>PS : I'm using the <span></span>default LLVM configuration for the above case.</span></div></div><span><div dir="auto" style="word-wrap:break-word"><div><span><blockquote type="cite">On 13 Dec 2015, at 16:42, Daniel Jasper <<a>djasper@google.com</a>> wrote:<br><br></blockquote></span></div></div></span><div><div><div dir="auto" style="word-wrap:break-word"><div><span><blockquote type="cite">Nope, this behavior isn't currently implemented. I agree that it might make sense, as it is similar to how clang-format treats lambdas at the end of several other parameters.<br><br>On Fri, Dec 11, 2015 at 4:08 PM, Yavuz Nuzumlalı <<a>cfe-dev@lists.llvm.org</a>> wrote:<br>Hi everyone,<br><br>I'm experiencing a problem with clang-format for my code.<br><br>I'm using ColumnLimit as 120. When I write some code like this:<br><br>[self testMethod:15 withBlock:^{<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br>}];<br><br>This code would be converted to this by clang-format:<br><br>[self testMethod:15<br>       withBlock:^{<br><span style="white-space:pre-wrap">   </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>   }];<br><br>That seems wrong to me because the method call before block variable actually fits in width of 120. I guess this is because clang-format behaves above code as a single method call and assumes it as one line. But I really want to not split the method like this because it feels weird.<br><br>Is there a way to accomplish this with current system?<br><br>I put my configuration file as an attachment.<br><br>Best<br><br><br>_______________________________________________<br>cfe-dev mailing list<br><a>cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br><br><br></blockquote></span></div></div>
</div></div></blockquote></div><br></div></div>
</div></blockquote></div></div></div></div></div></div></div></blockquote></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div></div></div>
</blockquote></div><br></div>