summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-format/clang-format.py
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-04-09 15:23:04 +0000
committerDaniel Jasper <djasper@google.com>2013-04-09 15:23:04 +0000
commite4549a2391a612e380d7362c2d75b729717c2d2c (patch)
tree12163c41e36ca1cef35c3582c5f47abbc8527cb9 /clang/tools/clang-format/clang-format.py
parentc2413f59e4556f041e82f91d5bbb8ba507cd7de9 (diff)
downloadbcm5719-llvm-e4549a2391a612e380d7362c2d75b729717c2d2c.tar.gz
bcm5719-llvm-e4549a2391a612e380d7362c2d75b729717c2d2c.zip
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. llvm-svn: 179098
Diffstat (limited to 'clang/tools/clang-format/clang-format.py')
-rw-r--r--clang/tools/clang-format/clang-format.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/tools/clang-format/clang-format.py b/clang/tools/clang-format/clang-format.py
index de922574070..d90c62a5bf6 100644
--- a/clang/tools/clang-format/clang-format.py
+++ b/clang/tools/clang-format/clang-format.py
@@ -23,6 +23,10 @@ import subprocess
# Change this to the full path if clang-format is not on the path.
binary = 'clang-format'
+# Change this to format according to other formatting styles (see
+# clang-format -help)
+style = 'LLVM'
+
# Get the current text.
buf = vim.current.buffer
text = "\n".join(buf)
@@ -34,7 +38,8 @@ length = int(vim.eval('line2byte(' +
str(vim.current.range.end + 2) + ')')) - offset - 2
# Call formatter.
-p = subprocess.Popen([binary, '-offset', str(offset), '-length', str(length)],
+p = subprocess.Popen([binary, '-offset', str(offset), '-length', str(length),
+ '-style', style],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
stdout, stderr = p.communicate(input=text)
OpenPOWER on IntegriCloud