Subject: bug#25608: CC Mode 5.33 (C/l); Incorrect syntactic information and indentation after multi-line comment with parenthesis or keywords

From: Alan Mackenzie <[email-masked]>
Date: Thu, 2 Feb 2017 22:03:19 +0000

Hello, Chris.

On Thu, Feb 02, 2017 at 13:45:36 +0000, Chris Wagner wrote:
> Hello,

> With the following c code:

> /*-----------------------------------------------------------------------------
> (c) Copyright notice containing open parentheses
> -----------------------------------------------------------------------------*/

> /*---------------------------------------------------------------------------*/

> the last line is indented incorrectly, as the identified syntactic
> information is ((topmost-intro-cont 1) (comment-intro)). I think it
> should be ((topmost-intro 1) (comment-intro)), which the following code
> correctly identifies:

> /*-----------------------------------------------------------------------------
> Non parenthesis language
> -----------------------------------------------------------------------------*/

> /*---------------------------------------------------------------------------*/

> Similarly, if there is a keyword in the comment, the next comment is
> incorrectly identified and indented:

> /*-----------------------------------------------------------------------------
> (c) Copyright notice containing open parentheses
> Line containing keyword for
> -----------------------------------------------------------------------------*/

> /*---------------------------------------------------------------------------*/

> Note that indenting the comment region removes the problem:

> /*-----------------------------------------------------------------------------
>   (c) Copyright notice containing open parentheses
>   Line containing keyword for
> -----------------------------------------------------------------------------*/

> /*---------------------------------------------------------------------------*/

> indents correctly.

> Best regards,
> Chris

The problem in all these cases which fail is the open parenthesis at
column zero inside the comment.  This (currently) causes mis-analysis of
the code around it, as detailed in the Emacs manual on page "Left Margin
Paren".

However, I would be the first to agree with you that this is a fault in
Emacs rather than anything wrong with your source code, which is
perfectly normal C.  There is a fix for this problem, and I have some
hope that this fix will be incorporated into Emacs 26.

[ CC Mode configuration dump snipped, but appreciated. ]

> Dr Chris Wagner
> Senior Consultant, Medical Technology 
> Cambridge Consultants
> Science Park, Milton Road 
> Cambridge, CB4 0DW, England
> Switchboard: +44 (0)1223 420024
> Direct dial: +44 (0)1223 392497
> Fax: +44 (0)1223 423373
> [email-masked]
> www.CambridgeConsultants.com

-- 
Alan Mackenzie (Nuremberg, Germany).