mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-12 19:03:10 +03:00
formatting: step 3 - add clang-format configuration
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
parent
8ade31c315
commit
f1094c9faa
36
.clang-format
Normal file
36
.clang-format
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
BasedOnStyle: GNU
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
PadOperators: true
|
||||
AlignOperands: DontAlign
|
||||
AttributeMacros:
|
||||
- G_GNUC_PRINTF
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterExternBlock: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
ColumnLimit: 100
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
SortIncludes: Never
|
||||
SpaceAfterCStyleCast: true
|
||||
SpacesBeforeTrailingComments: 2
|
@ -115,14 +115,7 @@ cppcheck-split-all: \
|
||||
cppcheck-unusedFunction \
|
||||
cppcheck-missingInclude
|
||||
|
||||
INDENT_CMD = $(INDENT) \
|
||||
--gnu-style \
|
||||
--format-first-column-comments \
|
||||
--indent-level4 \
|
||||
--brace-indent0 \
|
||||
--line-length100 \
|
||||
--no-tabs \
|
||||
--blank-lines-after-procedures
|
||||
INDENT_CMD = clang-format -i
|
||||
|
||||
INDENT_DIRS = \
|
||||
"$(top_srcdir)/lib" \
|
||||
|
@ -218,7 +218,6 @@ dnl ############################################################################
|
||||
dnl Check for other tools
|
||||
dnl ############################################################################
|
||||
|
||||
AC_CHECK_TOOLS([INDENT], [gindent indent])
|
||||
mc_UNIT_TESTS
|
||||
|
||||
|
||||
|
26
doc/HACKING
26
doc/HACKING
@ -66,29 +66,11 @@ cd mc-slang
|
||||
cd ../mc-ncurses
|
||||
/usr/local/src/mc/configure --with-screen=ncurses && make all
|
||||
|
||||
Please use the same indentation as other developers. To indent a block,
|
||||
select in the internal editor and use Shift-F9 to call the external
|
||||
indent. For historic reasons, GNU Midnight Commander used formatting
|
||||
that is not default for GNU Indent. Please put following text to your
|
||||
~/.indent.pro file to make GNU Indent follow the style used in GNU
|
||||
Midnight Commander:
|
||||
Please use the same indentation as other developers. We enforce our
|
||||
indentation style with clang-format. If your IDE doesn't have a
|
||||
suitable itegration, make sure to run the formatter yourself:
|
||||
|
||||
--gnu-style
|
||||
--format-first-column-comments
|
||||
--indent-level4
|
||||
--brace-indent0
|
||||
--line-length100
|
||||
--no-tabs
|
||||
--blank-lines-after-procedures
|
||||
|
||||
or in short notation:
|
||||
|
||||
indent -gnu -fc1 -i4 -bli0 -nut -bap -l100
|
||||
|
||||
It's OK to indent the whole function if you edit it. However, please
|
||||
refrain from it if you are posting your patch for review. In this case
|
||||
you would save time of other developers if you only include significant
|
||||
changes. The developer applying your patch can format the code for you.
|
||||
make indent
|
||||
|
||||
Please keep in mind that the VFS subsystem is licensed under LGPL, while
|
||||
the rest of the code uses GPL.
|
||||
|
@ -23,32 +23,7 @@ pollute name space by unnecessary symbols (so I do not crash fellow
|
||||
programs) and that I should have a clean interface between myself and
|
||||
midnight.
|
||||
|
||||
Because I'm rather close to midnight, try to:
|
||||
|
||||
* Keep the indentation as the rest of the code. Following could help
|
||||
you with your friend emacs:
|
||||
|
||||
(defun mc-c-mode ()
|
||||
"C mode with adjusted defaults for use with the Midnight commander."
|
||||
(interactive)
|
||||
(c-mode)
|
||||
(c-set-style "K&R")
|
||||
(setq c-indent-level 4
|
||||
c-continued-statement-offset 4
|
||||
c-brace-offset 0
|
||||
c-argdecl-indent 4
|
||||
c-label-offset -4
|
||||
c-brace-imaginary-offset 0
|
||||
c-continued-brace-offset 0
|
||||
c-tab-always-indent nil
|
||||
c-basic-offset 4
|
||||
tab-width 8
|
||||
comment-column 60))
|
||||
|
||||
(setq auto-mode-alist (cons '(".*/mc/.*\\.[ch]$" . mc-c-mode)
|
||||
auto-mode-alist))
|
||||
|
||||
And because I'm trying to live life on my own as libvfs.so, try to:
|
||||
Because I'm trying to live life on my own as libvfs.so, try to:
|
||||
|
||||
* Make sure all exported symbols are defined in vfs.h and begin with
|
||||
'vfs_'.
|
||||
|
@ -7,25 +7,21 @@
|
||||
exec >/dev/null
|
||||
|
||||
case `echo $1 |sed 's/^.*\.//'` in
|
||||
c|h)
|
||||
# ftp://ftp.gnu.org/pub/gnu/indent/
|
||||
# Please add options to your ~/.indent.pro, not here.
|
||||
indent "$2"
|
||||
;;
|
||||
C|cc|CC|cxx|CXX|cpp|CPP)
|
||||
# http://astyle.sourceforge.net/
|
||||
astyle "$2"
|
||||
c|C|cc|CC|cxx|CXX|cpp|CPP|c++|C++|h|H|hh|hxx|hpp)
|
||||
# https://clang.llvm.org/docs/ClangFormat.html
|
||||
# Please add options to your .clang-format, not here.
|
||||
clang-format -i "$2"
|
||||
;;
|
||||
java|JAVA)
|
||||
# http://astyle.sourceforge.net/
|
||||
# https://astyle.sourceforge.net
|
||||
astyle --style=java --mode=java "$2"
|
||||
;;
|
||||
htm|html|HTM|HTML)
|
||||
# http://tidy.sourceforge.net/
|
||||
# https://tidy.sourceforge.net
|
||||
tidy -q -m -ascii -wrap 80 "$2"
|
||||
;;
|
||||
*)
|
||||
# http://www.gnu.org/software/coreutils/
|
||||
# https://www.gnu.org/software/coreutils/
|
||||
fmt "$2" >"$2.tmp" && rm -f "$2" && mv -f "$2.tmp" "$2"
|
||||
;;
|
||||
esac
|
||||
|
@ -1,3 +1,3 @@
|
||||
#silent
|
||||
t Indent `C' formatter
|
||||
indent -gnu -fc1 -i4 -bli0 -nut -bap -l100 %b 1>/dev/null 2> %e
|
||||
t clang-format `C/C++' formatter
|
||||
clang-format -i %b 1>/dev/null 2> %e
|
||||
|
@ -403,8 +403,8 @@ c Compile, link and run the current .c file
|
||||
(echo -ne "\n--- Press any key for return to edit. ---"; read)
|
||||
|
||||
+ f \.c$ | f \.h$
|
||||
t Indent `C' formatter
|
||||
indent -kr -pcs %b 1>/dev/null 2> %e
|
||||
t clang-format `C/C++' formatter
|
||||
clang-format -i %b 1>/dev/null 2> %e
|
||||
|
||||
#--------------------- End [c/c++] language template --------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user