Subject: Re: bug#18072: 24.3; cc-mode indentation is broken

From: Alan Mackenzie <[email-masked]>
Date: 2 Nov 2019 12:23:05 -0000

Hello, Stefan and Juhani.

In article <[email-masked]> you wrote:
> Juhani Åhman <[email-masked]> writes:

>> I can't reliably reproduce the bug. 
>> All I can say that the auto-indentation thingymajig in cc-mode stops working at 
>> random every 5-15 minutes or so. 
>> I can get it working again by reloading the file I am editing. 
>> When the indentation is broken, pressing enter will leave no indentation 
>> space for braces and such. 
>>
>> it looks like this 
>>
>> if(1) { 
>> foo(); 
>> bar(); 
>> zot(); 
>> } 
>>
>> when it should look like this 
>>
>> if(1) { 
>>     foo(); 
>>     bar(); 
>>     zot(); 
>> } 
>>
>> I'm pretty sure the indentation was working in some previous version, 
>> about two years ago or so, but not in any of the newer versions of Emacs.

Is this C++ Mode, by any chance?

> I'm not seeing this here.  Can you reproduce this when running under
> "emacs -Q"?

This looks like having the same cause as bug #37910 "CC Mode 5.33.2
(C++//l); CC-mode inconsistently indents everything as topmost-intro
after a while".

I'm pretty sure it's a defect in a particular CC Mode cache (the "state
cache"), which tracks parentheses, braces, and brackets containing and
near point.  Somehow, it's missing the critical {, believing that
foo();, etc., are at top level.  A C-c C-s on that line would likely
show "topmost-intro".

> Best regards,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).