我认为这是emacs缩进模式中的一个错误

时间:2010-10-12 21:39:36

标签: emacs indentation

我碰巧在写这样的东西:

int main( int nargs, char **args ) {
    int i, j;
    if ( i > 0 && NEAR( i-1, j ).dist == INFINITY )
    {
        NEAR( i-1, j ).dist = 1.0;
        NEAR( i-1, j ).X = i;
        NEAR( i-1, j ).Y = j;
        newWorkPoints.push_back( IPoint( i-1, j ));
    }
    if ( j > 0 && NEAR( i, j-1 ).dist == INFINITY )
    {
        NEAR( i, j-1 ).dist = 1.0;
        NEAR( i, j-1 ).X = i;
        NEAR( i, j-1 ).Y = j;
        newWorkPoints.push_back( IPoint( i, j-1 ));
    }
    if ( i < maxwid && NEAR( i+1, j ).dist == INFINITY )
    {
        NEAR( i+1, j ).dist = 1.0;
        NEAR( i+1, j ).X = i;
        NEAR( i+1, j ).Y = j;
        newWorkPoints.push_back( IPoint( i+1, j ));
    }
    if ( j < maxheight && NEAR( i, j+1 ).dist == INFINITY )
    {
        NEAR( i, j+1 ).dist = 1.0;
        NEAR( i, j+1 ).X = i;
        NEAR( i, j+1 ).Y = j;
        newWorkPoints.push_back( IPoint( i, j+1 ));
    }
}

当我写这篇文章时,emacs(2010-03-30的22.2.1,Ubuntu)非常糟糕地缩进了它:

int main( int nargs, char **args ) {
    int i, j;
    if ( i > 0 && NEAR( i-1, j ).dist == INFINITY )
    {
        NEAR( i-1, j ).dist = 1.0;
        NEAR( i-1, j ).X = i;
        NEAR( i-1, j ).Y = j;
        newWorkPoints.push_back( IPoint( i-1, j ));
    }
    if ( j > 0 && NEAR( i, j-1 ).dist == INFINITY )
    {
        NEAR( i, j-1 ).dist = 1.0;
        NEAR( i, j-1 ).X = i;
        NEAR( i, j-1 ).Y = j;
        newWorkPoints.push_back( IPoint( i, j-1 ));
    }
    if ( i < maxwid && NEAR( i+1, j ).dist == INFINITY )
        {
            NEAR( i+1, j ).dist = 1.0;
            NEAR( i+1, j ).X = i;
            NEAR( i+1, j ).Y = j;
            newWorkPoints.push_back( IPoint( i+1, j ));
        }
        if ( j < maxheight && NEAR( i, j+1 ).dist == INFINITY )
            {
                NEAR( i, j+1 ).dist = 1.0;
                NEAR( i, j+1 ).X = i;
                NEAR( i, j+1 ).Y = j;
                newWorkPoints.push_back( IPoint( i, j+1 ));
            }
            }

&lt;&lt;&lt;在表达中,正在做它。这似乎是一个不太可能的错误!我做错了吗?

1 个答案:

答案 0 :(得分:1)

嗯,很难说你是否做错了,因为你没有提供足够的信息。您使用的是哪个版本的emacs?您使用的是什么版本的cc模式?缓冲区是否在java / c ++ / c-mode中?

cc模式手册在customizing indentation上有很好的文档,通常首先是interactive customization