summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorpaulhoad <mydeveloperday@gmail.com>2019-11-06 09:50:54 +0000
committerpaulhoad <mydeveloperday@gmail.com>2019-11-06 09:50:54 +0000
commitf349cc37cc485fd5fc7b34cb84053af459337ecc (patch)
treefa772d8ff14f9779d10866b28f447e7f6b1646f9 /clang/tools
parent76ec6b1ef69fcbd27cb0d587a5eb2d51a135a6bb (diff)
downloadbcm5719-llvm-f349cc37cc485fd5fc7b34cb84053af459337ecc.tar.gz
bcm5719-llvm-f349cc37cc485fd5fc7b34cb84053af459337ecc.zip
clang-format: Add a fallback style to Emacs mode
Summary: This allows one to enable `clang-format-buffer` on file save and avoid reformatting files that are outside of any project with .clang-format style. Reviewers: djasper, klimek, sammccall, owenpan, mitchell-stellar, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Patch By: dottedmag Tags: #clang, #clang-format Differential Revision: https://reviews.llvm.org/D69752
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/clang-format/clang-format.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/tools/clang-format/clang-format.el b/clang/tools/clang-format/clang-format.el
index 3096ec12f55..768acb3a5d0 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -57,6 +57,18 @@ of the buffer."
:safe #'stringp)
(make-variable-buffer-local 'clang-format-style)
+(defcustom clang-format-fallback-style "none"
+ "Fallback style to pass to clang-format.
+
+This style will be used if clang-format-style is set to \"file\"
+and no .clang-format is found in the directory of the buffer or
+one of parent directories. Set to \"none\" to disable formatting
+in such buffers."
+ :group 'clang-format
+ :type 'string
+ :safe #'stringp)
+(make-variable-buffer-local 'clang-format-fallback-style)
+
(defun clang-format--extract (xml-node)
"Extract replacements and cursor information from XML-NODE."
(unless (and (listp xml-node) (eq (xml-node-name xml-node) 'replacements))
@@ -162,6 +174,7 @@ uses the function `buffer-file-name'."
,@(and assume-file-name
(list "-assume-filename" assume-file-name))
,@(and style (list "-style" style))
+ "-fallback-style" ,clang-format-fallback-style
"-offset" ,(number-to-string file-start)
"-length" ,(number-to-string (- file-end file-start))
"-cursor" ,(number-to-string cursor))))
OpenPOWER on IntegriCloud