【发布时间】:2016-11-01 01:56:50
【问题描述】:
这是我关于堆栈溢出的第一篇文章,所以请原谅我的任何错误。
我通过 Xcode 学习了 c++,最近开始与一个使用 Emacs 的小组合作。这个小组有大量的 C++ 代码,所以我做了一个 CMake 接口来在 Xcode 中生成一个项目。发生的事情是代码在 Xcode 中出现严重缩进。例如,emacs 中的这些行:
if ( argc > 4 ) {
std::string argument( argv[arg_index++] );
// NOTE: file_name should NOT be "aboveCrack" or "belowCrack"
if ( argument == "aboveCrack" ) {
surf_to_draw = CrackMn3DGraphDX2::EAboveSurface;
}
else if ( argument == "belowCrack" ) {
surf_to_draw = CrackMn3DGraphDX2::EBelowSurface;
}
else {
// argument 4 is comp. crack surface output name
got_file_name = true;
postCompSurface_file_name = argument;
}
}
if ( !got_file_name && argc > 5 ) {
got_file_name = true;
postCompSurface_file_name = argv[arg_index++];
if ( argc > 6 ) {
// get comp. crack surface output style
postCompSurface_style = argv[arg_index++];
}
}
在 Xcode 中看起来像这样:
if ( argc > 4 ) {
std::string argument( argv[arg_index++] );
// NOTE: file_name should NOT be "aboveCrack" or "belowCrack"
if ( argument == "aboveCrack" ) {
surf_to_draw = CrackMn3DGraphDX2::EAboveSurface;
}
else if ( argument == "belowCrack" ) {
surf_to_draw = CrackMn3DGraphDX2::EBelowSurface;
}
else {
// argument 4 is comp. crack surface output name
got_file_name = true;
postCompSurface_file_name = argument;
}
}
if ( !got_file_name && argc > 5 ) {
got_file_name = true;
postCompSurface_file_name = argv[arg_index++];
if ( argc > 6 ) {
// get comp. crack surface output style
postCompSurface_style = argv[arg_index++];
}
}
这是不可能编程的。
我搜索了一下,显然它与 Emacs 中的选项卡有关。基于此,我能找到的一个修复方法是在 Emacs 中打开每个文件并执行 C-x h(全部标记),然后执行 M-x untabify。这会转换空格中的制表符,并且在 Xcode 中一切看起来都很好。
这个想法的问题是它需要一个一个地更改文件,并且它不会阻止将来再次发生这种情况。
因此,我的问题是:有没有办法在 Xcode 中打开 Emacs 缩进文件保留缩进?
非常感谢!
内森·肖尔
【问题讨论】:
标签: c++ xcode emacs indentation