Emacs CC-Mode
2 分钟阅读
emacs的代码风格配置主要是由一系列 association list (即键值对)组成。
- 换行风格配置集中在
c-cleanup-list
- 缩进配置集中在
c-offsets-alist
可以通过 C-h v
输入 c-cleanup-list
或 c-offsets-alist
查看帮助。
c-offsets-alist
+
表示以首行为起始,增加1倍c-basic-offset
++
表示以首行为起始,表示增加2倍c-basic-offset
*
表示以首行为起始,增加0.5倍c-basic-offset
-
表示以首行为起始,减少1倍c-basic-offset
--
表示以首行为起始,减少增加2倍c-basic-offset
/
表示以首行为起始,减少0.5倍c-basic-offset
函数的调用参数列表
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
函数定义时
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-intro
andcomment-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