简体   繁体   English

预处理器宏之后,Emacs C模式自动缩进失败

[英]Emacs C-mode auto-indent fails after preprocessor macro

Emacs 24.2 for Windows. 适用于Windows的Emacs 24.2。

case TYPE_LONG: 
 {                           <------- 65383 
   traceCodePath(20);        
   tempLongVal = iterator_long(it);  
   tempLongVal = 10; 
   if (isBigEndian()) 
   { 
     swap_endian64(&tempLongValCon, &tempLongVal); 
     traceCodePath(25);      <------- 65601 
     if (i > 0) 
       {     <------ get weird from here /* ((substatement-open 65601)) */ 
 }           <------ this line aligns with the { below "case"  /* ((block-close 65383)) */ 
 }           <------ the code afterward all align with { below "case" /* ((block-close 65383)) */

c-mode indentation worked well since the beginning, until I added some Preprocessor macro, #ifdef, #else, #end, after that, from some point in code, all afterward indentations get messy. c模式缩进从一开始就运行良好,直到我添加了一些预处理器宏,#ifdef,#else,#end,之后,从代码中的某些点开始,所有后续缩进都变得混乱。 Every line's syntatic symbol is right, but the anchor positions are all wrong, seems they can not recognize the { at their same level, but anchor to some { before them at a upper level. 每一行的合成符号都是正确的,但是锚点位置都是错误的,似乎他们无法识别{在同一级别,但是在某些级别{在他们之前处于上层级别。

What's more weird, even I remove those preprocessor macro's again, indentation won't recover again. 更奇怪的是,即使我再次删除那些预处理器宏,缩进也不会再次恢复。
What's more more weird, sometimes later, it recovered for no reason. 更奇怪的是,有时甚至更晚,它无缘无故地恢复了。 I don't know what operations triggered this, but most possible I think is "save" "revert-buffer" etc. 我不知道是什么操作触发了这个,但我认为最可能的是“保存”“恢复缓冲区”等。

Hope someone can figure the reason out, thanks in advance. 希望有人能够找出原因,提前谢谢。

This may very well be related to "bug #14133 24.2; c functions recognition breaks on certain preprocessor macros": 这很可能与“bug#14133 24.2; c函数识别某些预处理器宏中断”有关:

http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-04/msg00055.html http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-04/msg00055.html

The problem seems to be with spaces preceding #. 问题似乎是#之前的空格。 The way I noticed this is that CMa and CMe stopped working correctly, and auto-indenting regions was strange just as in your case. 我注意到这一点的方式是CMa和CMe停止正常工作,并且自动缩进区域就像你的情况一样奇怪。

Recoveries were not consistent for me neither. 恢复对我来说也不一致。

The patch proposed by Alan Mackenzie solved the problem for my case, you should try it out. Alan Mackenzie提出补丁解决了我的问题,你应该尝试一下。

You can also try with emacs 23, I could not reproduce the error in this version. 您也可以尝试使用emacs 23,我无法重现此版本中的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM