From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#29959: cc-mode: wrong indentation in absence of semicolon Date: Sat, 13 Jan 2018 20:37:52 +0000 Message-ID: <20180113203752.GA9688@ACM> References: <8a042ba1-301c-8943-1381-537cba8a2334@yandex.ru> 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 1515876142 10032 195.159.176.226 (13 Jan 2018 20:42:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 13 Jan 2018 20:42:22 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 29959@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 13 21:42:17 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1eaSd5-000236-VB for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jan 2018 21:42:16 +0100 Original-Received: from localhost ([::1]:35795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaSf3-0008MR-TC for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jan 2018 15:44:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaSer-0008K4-Ht for bug-gnu-emacs@gnu.org; Sat, 13 Jan 2018 15:44:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eaSeo-00020h-FX for bug-gnu-emacs@gnu.org; Sat, 13 Jan 2018 15:44:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eaSeo-00020O-B4; Sat, 13 Jan 2018 15:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eaSen-000725-PC; Sat, 13 Jan 2018 15:44:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 13 Jan 2018 20:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29959 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 29959-submit@debbugs.gnu.org id=B29959.151587621126981 (code B ref 29959); Sat, 13 Jan 2018 20:44:01 +0000 Original-Received: (at 29959) by debbugs.gnu.org; 13 Jan 2018 20:43:31 +0000 Original-Received: from localhost ([127.0.0.1]:55160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaSeJ-000716-Fn for submit@debbugs.gnu.org; Sat, 13 Jan 2018 15:43:31 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:40635 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eaSeH-00070v-Fl for 29959@debbugs.gnu.org; Sat, 13 Jan 2018 15:43:30 -0500 Original-Received: (qmail 58060 invoked by uid 3782); 13 Jan 2018 20:43:27 -0000 Original-Received: from acm.muc.de (p548C79A1.dip0.t-ipconnect.de [84.140.121.161]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 13 Jan 2018 21:43:26 +0100 Original-Received: (qmail 9765 invoked by uid 1000); 13 Jan 2018 20:37:52 -0000 Content-Disposition: inline In-Reply-To: <8a042ba1-301c-8943-1381-537cba8a2334@yandex.ru> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142132 Archived-At: Hello, Konstantin. On Sat, Jan 13, 2018 at 14:11:31 +0300, Konstantin Kharlamov wrote: > Just tested with current git, the problem is still present. > I am almost sure this is a regression, I don't remember having that > problem before. The real-world consequences are just too annoying for it > to go unnoticed — basically, every time I'm typing variables indentation > just doesn't work. And I also seem to remember a few irrelevant > situations where I was typing conditions with the like results. The problem originates in a new feature, C99 compound literals, which was committed on 2017-11-10. This detects brace blocks (meaning something like the initialisation of a struct) in the middle of executable code, but it is clear the test for such a brace block isn't rigorous enough, since even function blocks are being mistaken for them. > On 03.01.2018 09:02, Konstantin Kharlamov wrote: > > # Steps to reproduce: > > 1. Open emacs -Q test.c > > 2. Write the following: > > int main() { > >     int a, > > } > > 3. put the caret after the comma symbol, and press enter, e.g. to > > continue writing variables on the new line. > > # Expected: > > the new line alignment stands out with regard to the prev. line. > > # Actual: > > the new line aligned to the beginning of the prev. line. > > # Workarounds: > > Typing the following text: > > int main() { > >     int a,; > > } > > …then pressing enter right after the comma works as expected. At the moment, the bug you're seeing is triggered by CC Mode checking for commas and semicolons in blocks; if the last such delimiter is a comma, the block is taken as a brace block. So a workaround, for the moment, is to ensure that you have a semicolon in each block as the last delimiter there. I will be working on fixing this bug. Thanks for taking the trouble to report it. > > ------------ > > In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.26) > >  of 2017-12-15 built on constantine-N61Ja > > Repository revision: 6c301afa70f6eac32ad1ce92412ea3cf6fcdeeca > > Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 > > System Description: Arch Linux [ .... ] -- Alan Mackenzie (Nuremberg, Germany).