<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 14, 2017 at 1:42 AM, Samuel Williams via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="cremed">cfe-dev@lists.llvm.org</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"><div style="font-size:12.800000190734863px">Thanks for your feedback, and I appreciate the link and the logic behind it.</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Unfortunately, by stripping all trailing whitespace, clang-format has made a policy decision, but with no way to control it via the configuration. I understand it's not desirable for every option to be configurable, but this is something which significantly affects existing code. I propose that it would be good to have an option "TrailingWhitespace: Truncate|Preserve|Fix". Truncate would be existing behaviour. Preserve would not alter leading whitespace on blank lines or touch trailing whitespace. Fix would fix leading whitespace on blank lines, fix trailing whitespace on code, but avoid making any changes in comments except if it was reflowed. It could be more granular but that's where I'd start.</div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">## Some objective problems:</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><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><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><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><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><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><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><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><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><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">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>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" class="cremed">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="cremed">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>