diff options
author | Daniel Jasper <djasper@google.com> | 2013-04-09 15:23:04 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-04-09 15:23:04 +0000 |
commit | 63911838bf7891445ff39fdc7f81d1469d54f5c1 (patch) | |
tree | e8d0591f84016c3a6c2ce852a6edaed7f0e2c90e /tools/clang-format/clang-format-diff.py | |
parent | 40db5155fbd78faa792aefec5ceddcbf4fc3bb41 (diff) |
Improvements to clang-format integrations.
This adds an emacs editor integration (thanks to Ami Fischman). Also
pulls out the style into a variable for the vi integration and just
uses clang-formats defaults style in clang-format-diff.py.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format/clang-format-diff.py')
-rwxr-xr-x | tools/clang-format/clang-format-diff.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py index ab5f1b1bc6..16c6ad2159 100755 --- a/tools/clang-format/clang-format-diff.py +++ b/tools/clang-format/clang-format-diff.py @@ -63,9 +63,10 @@ def formatRange(r, style): offset, length = getOffsetLength(filename, line_number, line_count) with open(filename, 'r') as f: text = f.read() - p = subprocess.Popen([binary, '-offset', str(offset), '-length', str(length), - '-style', style], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, + command = [binary, '-offset', str(offset), '-length', str(length)] + if style: + command.append('-style', style) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = p.communicate(input=text) if stderr: @@ -84,8 +85,7 @@ def main(): 'Reformat changed lines in diff') parser.add_argument('-p', default=1, help='strip the smallest prefix containing P slashes') - parser.add_argument('-style', default='LLVM', - help='formatting style to apply (LLVM, Google)') + parser.add_argument('-style', help='formatting style to apply (LLVM, Google)') args = parser.parse_args() filename = None |