From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#341: c-indent-command misindents? Date: Tue, 29 Dec 2015 20:33:07 +0000 Message-ID: <20151229203307.GC1884@acm.fritz.box> References: <5712ce4f0805310813oea4c69bub98e6bc1f5877943@mail.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1451421081 19152 80.91.229.3 (29 Dec 2015 20:31:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Dec 2015 20:31:21 +0000 (UTC) Cc: Ralovich@debbugs.gnu.org, =?UTF-8?Q?Krist=C3=B3f?= , 341@debbugs.gnu.org To: Andrew Hyatt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 29 21:31:10 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aE0vF-0002QZ-9d for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 21:31:09 +0100 Original-Received: from localhost ([::1]:50008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE0vE-0007aO-Gs for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 15:31:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE0vB-0007aD-PO for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 15:31:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aE0v8-0004G2-JG for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 15:31:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE0v8-0004Fy-F5; Tue, 29 Dec 2015 15:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aE0v8-0001Rr-An; Tue, 29 Dec 2015 15:31:02 -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: Tue, 29 Dec 2015 20:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 341 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 341-submit@debbugs.gnu.org id=B341.14514210545549 (code B ref 341); Tue, 29 Dec 2015 20:31:02 +0000 Original-Received: (at 341) by debbugs.gnu.org; 29 Dec 2015 20:30:54 +0000 Original-Received: from localhost ([127.0.0.1]:48940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE0v0-0001RQ-3M for submit@debbugs.gnu.org; Tue, 29 Dec 2015 15:30:54 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:14593) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE0uy-0001RH-4E for 341@debbugs.gnu.org; Tue, 29 Dec 2015 15:30:52 -0500 Original-Received: (qmail 56686 invoked by uid 3782); 29 Dec 2015 20:30:50 -0000 Original-Received: from acm.muc.de (p579E804C.dip0.t-ipconnect.de [87.158.128.76]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 29 Dec 2015 21:30:49 +0100 Original-Received: (qmail 20296 invoked by uid 1000); 29 Dec 2015 20:33:07 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110981 Archived-At: Hello Andrew and Kristóf. On Mon, Dec 28, 2015 at 07:48:22PM -0500, Andrew Hyatt wrote: > I've reproduced this bug in emacs 25. > It seems like a real problem, thanks (belatedly) for reporting! Yes, it's a known problem in CC Mode, and it's seriously difficult to fix. Parsing happens mainly in the backwards direction, and in general, the #ifdefs in a file form a tree structure. Which is the line previous to line 6? It could be L4, it could be L2. Typically, such "parallel" text lines aren't nice and compatible, the way they are in this example. Indeed, it's possible to construct an example where L6 has two alternative syntactic contexts, depending on whether A is defined. In fact, something like: #ifdef A int foo(int a, int b) #else int bar(int a, int b) { if (a > b) #endif { return a+b; } would do it. I don't know if this problem will ever be fixed. > "Ralovich, "Kristóf\"" writes: > > Hi, > > I hope this letter ends up at the right maintainers! > > My problem is when running c-indent-command (by pressing TAB or > > calling it directly) on the 4th line of the following small snippet > > (same as attached file): > > 1: #ifdef A > > 2: int foo(int a, int b) > > 3: #else > > 4: int bar(int a, int b) > > 5: #endif > > 6: { > > 7: return a+b; > > 8: } > > the line is getting indented falsely: > > 1: #ifdef A > > 2: int foo(int a, int b) > > 3: #else > > 4: int bar(int a, int b) > > 5: #endif > > 6: { > > 7: return a+b; > > 8: } > > I think, it should not get indented, please correct me if I am wrong! > > I am using emacs 22.2 with it's default cc-mode. > > Looking forward to hearing from you! > > Kristóf -- Alan Mackenzie (Nuremberg, Germany).