Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 抑制c++;emacs中的名称空间缩进_C++_Emacs_Indentation - Fatal编程技术网

C++ 抑制c++;emacs中的名称空间缩进

C++ 抑制c++;emacs中的名称空间缩进,c++,emacs,indentation,C++,Emacs,Indentation,可能重复: 我希望emacs不要在名称空间中缩进代码 namespace a_namespace{ // no indentation int namespace_global_variable; // no indentation class Class { // comment Class(); //... }; // and so on } 当我试图修改namespace变量中的时,或者使用C-C-o更改感兴趣点的缩进时,我没有得到预期的效果(事实上

可能重复:

我希望emacs不要在名称空间中缩进代码

namespace a_namespace{

// no indentation
int namespace_global_variable;


// no indentation
class Class {
    // comment
    Class();
    //...
};

// and so on


}
当我试图修改namespace变量中的
时,或者使用
C-C-o
更改感兴趣点的缩进时,我没有得到预期的效果(事实上后者消除了函数内部的所有缩进)

我的缩进配置如下(复制自Google emacs配置):

(自定义我的cc样式
“(“抄送模式”
(c-offsets-alist.((在名称空间[0]()())))
(c-添加样式“我的抄送模式”我的抄送样式)

从的。此处有效。

似乎与相同。该解决方案不适用于我(可能是用户错误)。这不是严格的重复,因为另一个问题要求一些缩进,而这不要求缩进。“无”的解决方案可能比“金额设置为零的部分”的解决方案更好。只需将
-
替换为
[0]
在我现有的
c-offsets-alist中
并不能解决这个问题。现在它似乎可以工作了——我不能100%确定emacs重新读取其init文件需要什么。不知何故,这对我来说不起作用,即使在重新启动emacs之后
(c-set-offset'innamespace 0)
虽然有效(取自)注意,这是从“然后使用c-set-style来使用您自己的样式”状态复制而来的答案。这里有一条重要的信息缺失?这是很旧的,但对于emacs来说“重新读取其初始文件”:-x eval buffer(在访问.emacs或任何您命名的文件时)
(c-offsets-alist . ((arglist-intro vista-c-lineup-expression-plus-4)
                    (func-decl-cont . ++)
                    (member-init-intro . +)
                    (inher-intro . ++)
                    (comment-intro . 0)
                    (arglist-close . c-lineup-arglist)
                    (topmost-intro . 0)
                    (block-open . 0)
                    (inline-open . 0)
                    (substatement-open . 0)
                    (statement-cont
                     .
                     (,(when (fboundp 'c-no-indent-after-java-annotations)
                         'c-no-indent-after-java-annotations)
                      ,(when (fboundp 'c-lineup-assignments)
                         'c-lineup-assignments)
                      ++))
                    (label . /)
                    (case-label . +)
                    (statement-case-open . +)
                    (statement-case-intro . +) ; case w/o {
                    (access-label . /)
                    (innamespace . -))))