<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 26, 2018 at 10:06 AM Samuel Williams via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">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"><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"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.800000190734863px">## Some objective problems:<br></div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">- Existing code which is indented this way would require a lot of changes.</div></div></blockquote><div><br></div></span><div>That's true for any project starting to use clang-format. That's why we'd suggest to use editor and version control system integrations and only format the lines that are touched.</div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I'm not really sure the workflow you describe really makes sense.</div><div><br></div><div>I'd prefer to apply it to the whole project in one shot and then keep it formatted that way using pre-commit hooks or something like that.<br></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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.800000190734863px">- Markdown (which is useful in comments) is sensitive to trailing whitespace.</div></div></blockquote><div><br></div></span><div>I haven't seen a project using markdown in comments and relying on the trailing whitespace. However, even if some do, I think it'd be better for clang-format to recognize this and not remove spaces for those comments specifically.</div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>clang-format simply can't know that the comments contain markdown or not, so what you propose is impossible. One option would be to not reformat comments.</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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.800000190734863px">It's possible to add a post process script to normalise leading whitespace but not trailing whitespace (e.g. in the case of markdown).<br></div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">## Some subjective problems:</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">- It's my preference when I start editing on a line, the indentation is correct already.</div></div></blockquote><div><br></div></span><div>How often do you even start editing in a currently empty line? Don't you normally start with some existing code and have to insert a line break? clang-format wouldn't help there..</div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I start editing on empty lines all the time.</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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>(It's also a really easy habit to loose once you have gotten yourself to rely on clang-format working in your editor).</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.800000190734863px">- When moving cursor up and down it's my preference that it doesn't jump back and forward when crossing blank lines.</div></div></blockquote><div><br></div></span><div>But the proposal wouldn't really change much here, unless you happen to have the cursor right at the start of the line and it would all be indented the exact same level. Isn't that a really rare case?</div></div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It's not a rare case at all if you have lots of empty lines.</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 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"><span><div dir="ltr"><div style="font-size:12.800000190734863px">Some of these issues can be fixed by editor configuration/plugins, but it's still not 100% correct.</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Thanks for your time.</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Kind regards,</div><div style="font-size:12.800000190734863px">Samuel</div><div class="gmail_extra"><br></div></div>
<br></span><span>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" class="m_1673494000892040862m_8361827383777437432cremed" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="m_1673494000892040862m_8361827383777437432cremed" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></span></blockquote></div><br></div></div>
</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"></div><br></div><div class="gmail_extra">I still think this is a good idea. and the fact that many top projects prefer this style is a good indication that it would be a useful addition, IMHO.</div></div></blockquote><div><br></div><div>Do you have links to example projects? Do those projects have public style guides?</div><div> </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"><br></div><div class="gmail_extra">Kind regards,</div><div class="gmail_extra">Samuel</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>