- Clean-Ups
"Clean-ups" are mechanisms which remove (or exceptionally, add)
whitespace in specific circumstances and are complementary to colon and
brace hanging. You enable a clean-up by adding its symbol into
`c-cleanup-list', e.g. like this:
(add-to-list 'c-cleanup-list 'space-before-funcall)
一些clean-up要在启用了auto-newline minor mode的情况下才能生效,另外一些总是有效. - Line-Up
The most flexible way to customize indentation is by writing custom
line-up functions, and associating them with specific syntactic symbols
(*note c-offsets-alist::).
google-c-style.el里定义了一个line-up函数.
如何自己写一个Line-up函数:http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Custom-Line_002dUp - Fill 与 Breaking
- c-basic-offset
- c-cleanup-list
- c-offsets-alist
很重要的一个变量,关联的值可以是一个int,一个函数,lambda表达式(参见lineup部分),或者+,++,-,--,/
三、缩进的原理
分两步:
- 分析当前行的语法符号
- 去c-offsets-alist查找该符号的offset
五、有用的交互式的按键
- C-c C-s 显示当前行的语法符号,和缩进的基准point.
- C-c C-o 交互式的设置缩进.
在看wget的代码的时候有些别扭,缩进是2个空格,if语句要这样写:
if ( a > b)
{
return a;
}
{,}都也是缩进了2个空格.
1. 最基本的设置 c-basic-offset
定义了缩进一级的大小,即符号+,-在c-offset-alist中代表的数量.
在wget代码里,要设置:
(setq c-basic-offset 2)
2.
没有评论:
发表评论