Emacs CC-Mode
2 minute read
Emacs code style configuration primarily consists of a series of association lists (i.e., key-value pairs).
- Line breaking style configuration is focused in
c-cleanup-list - Indentation configuration is focused in
c-offsets-alist
You can use C-h v to enter c-cleanup-list or c-offsets-alist to view help.
c-offsets-alist
+means to use the first line as the starting point, adding 1xc-basic-offset++means to use the first line as the starting point, adding 2xc-basic-offset*means to use the first line as the starting point, adding 0.5xc-basic-offset-means to use the first line as the starting point, subtracting 1xc-basic-offset--means to use the first line as the starting point, subtracting 2xc-basic-offset/means to use the first line as the starting point, subtracting 0.5xc-basic-offset
Function Call Argument List
func(
a, b, c, // arglist-intro
d, e, f, // arglist-cont
); // arglist-close
func(
a, b, c, // arglist-intro
d, e, f); // arglist-cont-nonempty
func(a,
b, c, // arglist-cont
d, e, f); // arglist-cont-nonempty
Function Definition
1: void Bass::play( int volume )
2: const
3: {
4: /* this line starts a multiline
5: * comment. This line should get 'c' syntax */
6:
7: char* a_multiline_string = "This line starts a multiline \
8: string. This line should get 'string' syntax.";
9:
10: note:
11: {
12: #ifdef LOCK
13: Lock acquire();
14: #endif // LOCK
15: slap_pop();
16: cout << "I played "
17: << "a note\n";
18: }
19: }
- Line 2:
func-decl-cont - Line 4: both
defun-block-introandcomment-intro - Line 5:
c - Line 6:
defun-block-intro - Line 8:
string - Line 10:
label - Line 11:
block-open&statement - Lines 12,14:
cpp-macro,statement-block-intro,statement - Line 17:
stream-op
1: int res = ({
2: int y = foo (); int z;
3: if (y > 0) z = y; else z = - y;
4: z;
5: });
- Lines 2, 5:
inexpr-statement
1: array itgob()
2: {
3: string s = map (backtrace()[-2][3..],
4: lambda
5: (mixed arg)
6: {
7: return sprintf ("%t", arg);
8: }) * ", " + "\n";
9: return catch {
10: write (s + "\n");
11: };
12: }
- Lines 4 through 8:
lambda - line 5:
lambda-intro-cont - line 6:
inlambda,inline-open - line 8:
inline-close - line 10:
inexpr-statement