<div dir="ltr">Hi Kyle,<div><br></div><div>A similar feature has been proposed: allowing -style to refer to a filename. Could be style=file:<path> which is pretty close...</div><div>I guess it's a little clumsier for the user (and a little less work for the style authors) than what you propose. But it's simple, which is worth something - I don't like the idea of adding things to the format file itself to facilitate this.</div><div>And it would satisfy your goal around error-reporting: -style=foobar fails with "Invalid value for -style" and a nonexistent file could do the same.</div><div><br></div><div>The patch <a href="https://reviews.llvm.org/D50147">https://reviews.llvm.org/D50147</a> got stalled over whether the files should be searched for relative to some predefined search path. I think a version that handled absolute or working-dir-relative paths would be uncontroversial. Would this work for you?<br></div><div><br></div><div>cc Typz who wrote that patch and Mydeveloperday who is the most active clang-format maintainer.</div><div><br></div><div>Cheers, Sam</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 15, 2020 at 9:28 AM Kyle Knoepfel 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Forgive me if this has already been discussed.  <br>
<br>
I work on projects with different formatting guidelines.  For simple cases, it is simple to embed the .clang-format file in the correct (parent) directory, run `clang-format -style=file ...` and everyone's happy.  However, it is easy to get into a situation where the wrong format is applied, especially if you accidentally invoke the command from the wrong directory.<br>
<br>
Would Clang be opposed to a specification like:<br>
<br>
clang-format -style=custom:my-projects-format ...<br>
<br>
where a field in the .clang-format file would have the value 'my-projects-format', thus attributing the file to the format name?  If a user specified something like -style=custom:my-unsupported-format, and such a format name could not be discovered in the .clang-format file, then it would be a hard failure, not letting a silent error slip by.<br>
<br>
Thanks for your input.  If it is favorable, then I'm happy to explore implementing it.<br>
<br>
Kyle Knoepfel<br>
<br>
Software framework group leader, Fermilab<br>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>