mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
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.
This commit is contained in:
parent
97fc98901c
commit
f20fa61eb4
50
.clang-format
Normal file
50
.clang-format
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# -*- yaml -*-
|
||||||
|
# This configuration works with clang-format-15.
|
||||||
|
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AlwaysBreakAfterReturnType: AllDefinitions
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
AttributeMacros:
|
||||||
|
- QPDF_DLL
|
||||||
|
- QPDF_DLL_CLASS
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
DeriveLineEnding: false
|
||||||
|
PackConstructorInitializers: Never
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^["<](qpdf)/'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IndentCaseBlocks: true
|
||||||
|
IndentExternBlock: Indent
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: 4
|
||||||
|
InsertTrailingCommas: Wrapped
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
NamespaceIndentation: All
|
||||||
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: 1
|
||||||
|
SpaceBeforeInheritanceColon: false
|
38
.dir-locals.el
Normal file
38
.dir-locals.el
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
((nil . ((indent-tabs-mode . t)
|
||||||
|
(qpdf-cc-style
|
||||||
|
.
|
||||||
|
("qpdf"
|
||||||
|
(c-basic-offset . 4)
|
||||||
|
(c-comment-only-line-offset . 0)
|
||||||
|
(c-offsets-alist
|
||||||
|
(defun-block-intro . +)
|
||||||
|
(block-open . 0)
|
||||||
|
(substatement-open . 0)
|
||||||
|
(statement-cont . +)
|
||||||
|
(case-label . 0)
|
||||||
|
(access-label . -2)
|
||||||
|
(statement-case-intro . +)
|
||||||
|
(statement-case-open . +)
|
||||||
|
(arglist-intro . +)
|
||||||
|
(arglist-close . 0)
|
||||||
|
(inline-open . 0)
|
||||||
|
(inlambda . 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(c-noise-macro-names . ("QPDF_DLL" "QPDF_DLL_CLASS" "QPDF_DLL_LOCAL"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(c++-mode . ((eval . (progn
|
||||||
|
(add-to-list 'c-style-alist qpdf-cc-style)
|
||||||
|
(c-set-style "qpdf")
|
||||||
|
)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
(c-mode . ((eval . (progn
|
||||||
|
(add-to-list 'c-style-alist qpdf-cc-style)
|
||||||
|
(c-set-style "qpdf")
|
||||||
|
)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
)
|
36
TODO
36
TODO
@ -60,43 +60,11 @@ Use clang-format-15.
|
|||||||
|
|
||||||
as well as the use of a comment to force a line break.
|
as well as the use of a comment to force a line break.
|
||||||
|
|
||||||
Tentative .clang-format:
|
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
|
|
||||||
```
|
|
||||||
---
|
|
||||||
Language: Cpp
|
|
||||||
BasedOnStyle: LLVM
|
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
|
||||||
AlignEscapedNewlines: DontAlign
|
|
||||||
AllowShortFunctionsOnASingleLine: None
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: false
|
|
||||||
BreakConstructorInitializers: BeforeComma
|
|
||||||
DeriveLineEnding: false
|
|
||||||
PackConstructorInitializers: Never
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^["<](qpdf)/'
|
|
||||||
Priority: 1
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 2
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 1
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
IndentCaseBlocks: true
|
|
||||||
IndentWidth: 4
|
|
||||||
InsertTrailingCommas: Wrapped
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
||||||
PointerAlignment: Left
|
|
||||||
```
|
|
||||||
|
|
||||||
Remaining work:
|
Remaining work:
|
||||||
|
|
||||||
* Try to get emacs c-style to match as closely as possible
|
* Document .dir-locals.el and how it's close but not perfect
|
||||||
* Consider blame.ignoreRevsFile if it seems to help
|
* Consider blame.ignoreRevsFile if it seems to help
|
||||||
* Add a `make format` similar to `make spell` (or whatever this ends
|
* Add a `make format` similar to `make spell` (or whatever this ends
|
||||||
up being with cmake)
|
up being with cmake)
|
||||||
|
Loading…
Reference in New Issue
Block a user