<div dir="ltr">Is this correct? Right now, when I open a new buffer in vim with its pwd somewhere in my llvm or chromium checkout, clang-format will find the .clang-format file that's somewhere in a parent directory of the pwd and use the style from there. With this change, it looks like vim would always use style llvm instead of the style selected in a .clang-format file for unnamed buffers.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 8, 2014 at 10:07 PM, Ahmed Charles <span dir="ltr"><<a href="mailto:acharles@outlook.com" target="_blank">acharles@outlook.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi djasper,<br>
<br>
This allows formatting of buffers before saving them without warnings.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D3019" target="_blank">http://llvm-reviews.chandlerc.com/D3019</a><br>
<br>
Files:<br>
tools/clang-format/clang-format.py<br>
<br>
Index: tools/clang-format/clang-format.py<br>
===================================================================<br>
--- tools/clang-format/clang-format.py<br>
+++ tools/clang-format/clang-format.py<br>
@@ -29,8 +29,8 @@<br>
# Change this to format according to other formatting styles. See the output of<br>
# 'clang-format --help' for a list of supported styles. The default looks for<br>
# a '.clang-format' or '_clang-format' file to indicate the style that should be<br>
-# used.<br>
-style = 'file'<br>
+# used if the vim buffer is associated with a file, or LLVM otherwise.<br>
+style = None<br>
<br>
def main():<br>
# Get the current text.<br>
@@ -52,9 +52,15 @@<br>
startupinfo.wShowWindow = subprocess.SW_HIDE<br>
<br>
# Call formatter.<br>
- command = [binary, '-lines', lines, '-style', style, '-cursor', str(cursor)]<br>
+ command = [binary, '-lines', lines, '-cursor', str(cursor)]<br>
if <a href="http://vim.current.buffer.name" target="_blank">vim.current.buffer.name</a>:<br>
command.extend(['-assume-filename', <a href="http://vim.current.buffer.name" target="_blank">vim.current.buffer.name</a>])<br>
+ if style:<br>
+ command.extend(['-style', style])<br>
+ elif <a href="http://vim.current.buffer.name" target="_blank">vim.current.buffer.name</a>:<br>
+ command.extend(['-style', 'file'])<br>
+ else:<br>
+ command.extend(['-style', 'LLVM'])<br>
p = subprocess.Popen(command,<br>
stdout=subprocess.PIPE, stderr=subprocess.PIPE,<br>
stdin=subprocess.PIPE, startupinfo=startupinfo)<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>