Commit f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb

Authored by Jay Berkenbilt
1 parent 97fc9890

Add .clang-format and .dir-locals.el files to set coding style

Configure emacs and clang-format 15 to the coding style I am choosing
for qpdf.
.clang-format 0 → 100644
  1 +# -*- yaml -*-
  2 +# This configuration works with clang-format-15.
  3 +# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html
  4 +---
  5 +Language: Cpp
  6 +BasedOnStyle: LLVM
  7 +AlignAfterOpenBracket: AlwaysBreak
  8 +AlignEscapedNewlines: DontAlign
  9 +AlignOperands: DontAlign
  10 +AllowShortFunctionsOnASingleLine: None
  11 +AlwaysBreakAfterReturnType: AllDefinitions
  12 +AlwaysBreakTemplateDeclarations: Yes
  13 +AttributeMacros:
  14 + - QPDF_DLL
  15 + - QPDF_DLL_CLASS
  16 +BinPackArguments: false
  17 +BinPackParameters: false
  18 +BraceWrapping:
  19 + AfterClass: true
  20 + AfterFunction: true
  21 + AfterNamespace: true
  22 + AfterStruct: true
  23 + AfterUnion: true
  24 +BreakBeforeBraces: Custom
  25 +BreakConstructorInitializers: AfterColon
  26 +DeriveLineEnding: false
  27 +PackConstructorInitializers: Never
  28 +IncludeCategories:
  29 + - Regex: '^["<](qpdf)/'
  30 + Priority: 1
  31 + SortPriority: 0
  32 + CaseSensitive: false
  33 + - Regex: '.*'
  34 + Priority: 2
  35 + SortPriority: 0
  36 + CaseSensitive: false
  37 + - Regex: '.*'
  38 + Priority: 1
  39 + SortPriority: 0
  40 + CaseSensitive: false
  41 +IndentCaseBlocks: true
  42 +IndentExternBlock: Indent
  43 +IndentPPDirectives: AfterHash
  44 +IndentWidth: 4
  45 +InsertTrailingCommas: Wrapped
  46 +KeepEmptyLinesAtTheStartOfBlocks: false
  47 +NamespaceIndentation: All
  48 +PointerAlignment: Left
  49 +PPIndentWidth: 1
  50 +SpaceBeforeInheritanceColon: false
.dir-locals.el 0 → 100644
  1 +((nil . ((indent-tabs-mode . t)
  2 + (qpdf-cc-style
  3 + .
  4 + ("qpdf"
  5 + (c-basic-offset . 4)
  6 + (c-comment-only-line-offset . 0)
  7 + (c-offsets-alist
  8 + (defun-block-intro . +)
  9 + (block-open . 0)
  10 + (substatement-open . 0)
  11 + (statement-cont . +)
  12 + (case-label . 0)
  13 + (access-label . -2)
  14 + (statement-case-intro . +)
  15 + (statement-case-open . +)
  16 + (arglist-intro . +)
  17 + (arglist-close . 0)
  18 + (inline-open . 0)
  19 + (inlambda . 0)
  20 + )
  21 + )
  22 + )
  23 + (c-noise-macro-names . ("QPDF_DLL" "QPDF_DLL_CLASS" "QPDF_DLL_LOCAL"))
  24 + )
  25 + )
  26 + (c++-mode . ((eval . (progn
  27 + (add-to-list 'c-style-alist qpdf-cc-style)
  28 + (c-set-style "qpdf")
  29 + )
  30 + ))
  31 + )
  32 + (c-mode . ((eval . (progn
  33 + (add-to-list 'c-style-alist qpdf-cc-style)
  34 + (c-set-style "qpdf")
  35 + )
  36 + ))
  37 + )
  38 +)
@@ -60,43 +60,11 @@ Use clang-format-15. @@ -60,43 +60,11 @@ Use clang-format-15.
60 60
61 as well as the use of a comment to force a line break. 61 as well as the use of a comment to force a line break.
62 62
63 -Tentative .clang-format:  
64 -  
65 -```  
66 ----  
67 -Language: Cpp  
68 -BasedOnStyle: LLVM  
69 -AlignAfterOpenBracket: AlwaysBreak  
70 -AlignEscapedNewlines: DontAlign  
71 -AllowShortFunctionsOnASingleLine: None  
72 -BinPackArguments: false  
73 -BinPackParameters: false  
74 -BreakConstructorInitializers: BeforeComma  
75 -DeriveLineEnding: false  
76 -PackConstructorInitializers: Never  
77 -IncludeCategories:  
78 - - Regex: '^["<](qpdf)/'  
79 - Priority: 1  
80 - SortPriority: 0  
81 - CaseSensitive: false  
82 - - Regex: '.*'  
83 - Priority: 2  
84 - SortPriority: 0  
85 - CaseSensitive: false  
86 - - Regex: '.*'  
87 - Priority: 1  
88 - SortPriority: 0  
89 - CaseSensitive: false  
90 -IndentCaseBlocks: true  
91 -IndentWidth: 4  
92 -InsertTrailingCommas: Wrapped  
93 -KeepEmptyLinesAtTheStartOfBlocks: false  
94 -PointerAlignment: Left  
95 -``` 63 +https://clang.llvm.org/docs/ClangFormatStyleOptions.html
96 64
97 Remaining work: 65 Remaining work:
98 66
99 -* Try to get emacs c-style to match as closely as possible 67 +* Document .dir-locals.el and how it's close but not perfect
100 * Consider blame.ignoreRevsFile if it seems to help 68 * Consider blame.ignoreRevsFile if it seems to help
101 * Add a `make format` similar to `make spell` (or whatever this ends 69 * Add a `make format` similar to `make spell` (or whatever this ends
102 up being with cmake) 70 up being with cmake)