From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: C99 compound literals in c-mode Date: Thu, 24 Aug 2017 16:37:16 +0000 Message-ID: <20170824163716.GA3392@ACM> References: <20170820204030.GA8206@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1503593841 23901 195.159.176.226 (24 Aug 2017 16:57:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 Aug 2017 16:57:21 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: Emacs Developers To: Nikolai Weibull Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 24 18:57:17 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkvRV-00062k-Eb for ged-emacs-devel@m.gmane.org; Thu, 24 Aug 2017 18:57:17 +0200 Original-Received: from localhost ([::1]:49539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkvRc-0006GO-9Y for ged-emacs-devel@m.gmane.org; Thu, 24 Aug 2017 12:57:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkvAJ-0000H4-3i for emacs-devel@gnu.org; Thu, 24 Aug 2017 12:39:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkvAF-0005L8-V2 for emacs-devel@gnu.org; Thu, 24 Aug 2017 12:39:31 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:15736 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1dkvAF-0005Jl-K9 for emacs-devel@gnu.org; Thu, 24 Aug 2017 12:39:27 -0400 Original-Received: (qmail 35668 invoked by uid 3782); 24 Aug 2017 16:39:25 -0000 Original-Received: from acm.muc.de (p548C6D20.dip0.t-ipconnect.de [84.140.109.32]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Aug 2017 18:39:24 +0200 Original-Received: (qmail 3974 invoked by uid 1000); 24 Aug 2017 16:37:16 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217770 Archived-At: Hello, Nikolai. On Wed, Aug 23, 2017 at 12:01:34 +0200, Nikolai Weibull wrote: > On Sun, Aug 20, 2017 at 10:40 PM, Alan Mackenzie wrote: > > Hello, Nikolai. > > On Tue, Aug 15, 2017 at 11:57:25 +0200, Nikolai Weibull wrote: > >> struct a { > >> int b; > >> }; > > This seems to be correctly analysed and indented by CC Mode. You can > > see this by doing C-c C-s on any line to get the syntactic analysis. > > On the middle line, this shows ((inclass 332) (topmost-intro 332)) > > (where the "332" may vary, depending on the position in the file). > > The "inclass" bit causes an indentation of c-basic-offset (here 8) > > columns. > > What indentation do you want here? > Sorry, this was just there to give a complete example, it indents > correctly as is. OK. > >> int > >> main(void) > >> { > >> return (struct a){ > >> 0 > >> }.b; > >> } > > Here, the "0" line is being wrongly analysed as a > > statement-block-intro, when it should be a brace-list-intro. The > > problem is that brace lists are recognised only by their context in > > the source code, rather than their internal structure. When a brace > > list can appear virtually anywhere, this doesn't make sense. > > The following patch causes brace lists to be recognised by their > > internal structure too. Would you please apply it to CC Mode (in > > directory .../lisp/progmodes), try it out, and let me know how well it > > solves the problems with compound literals. > This seems to be a patch for a newer version of CC Mode than that > installed with my Emacs (25.2.1 via MacPorts). The function > c-looking-at-statement-block isn’t even defined. Apologies, I didn't read your original post properly. There have indeed been quite a few changes to CC Mode since the code freeze for Emacs 25.2. Would it be OK if I sent you a tarball (format .tar.gz) of the up to date CC Mode sources (including this patch)? The total size is around 440 kB. > Nikolai -- Alan Mackenzie (Nuremberg, Germany).