From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.bugs Subject: bug#341: c-indent-command misindents? Date: Tue, 29 Dec 2015 20:38:24 +0000 Message-ID: References: <5712ce4f0805310813oea4c69bub98e6bc1f5877943@mail.gmail.com> <20151229203307.GC1884@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1143fae0cbc0d805280f673a X-Trace: ger.gmane.org 1451421621 27079 80.91.229.3 (29 Dec 2015 20:40:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Dec 2015 20:40:21 +0000 (UTC) Cc: Ralovich@debbugs.gnu.org, =?UTF-8?Q?Krist=C3=B3f?= , 341@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 29 21:40:13 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 1aE140-0001h5-Hl for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 21:40:12 +0100 Original-Received: from localhost ([::1]:50030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE13z-0001PS-Te for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 15:40:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE13a-0001Kt-Qa for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 15:40:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aE13F-0006TZ-1D for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 15:39:46 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE12s-0005sd-3A; Tue, 29 Dec 2015 15:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aE12r-0001e5-PQ; Tue, 29 Dec 2015 15:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Hyatt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Tue, 29 Dec 2015 20:39:01 +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.14514215226296 (code B ref 341); Tue, 29 Dec 2015 20:39:01 +0000 Original-Received: (at 341) by debbugs.gnu.org; 29 Dec 2015 20:38:42 +0000 Original-Received: from localhost ([127.0.0.1]:48944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE12X-0001dT-TE for submit@debbugs.gnu.org; Tue, 29 Dec 2015 15:38:42 -0500 Original-Received: from mail-vk0-f50.google.com ([209.85.213.50]:33599) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE12W-0001dA-6F for 341@debbugs.gnu.org; Tue, 29 Dec 2015 15:38:40 -0500 Original-Received: by mail-vk0-f50.google.com with SMTP id a188so197787711vkc.0; Tue, 29 Dec 2015 12:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=SkOPfoIhVwGggIkRuhikTxL39do8TzM6NHHlp4X4foM=; b=PyO1997eZBUsEKFnAhpW1od4GbtFnmTjnjM46q6uBCb458HxWAsF354LyutMkhO51u /IqheLi33Y0eN8+Qu0hbVoXl51EoqZYIn5ftPl6Ckm6S6yIVZYbZ8GJGdieWFfCch3hq TII4BuGMmXMvYycehXPOtkZMr+uGMG1kXIaex6geXvtA9lzP4M2DVzD9b+V4jZJ4R4QV 5jnO633+N9m8OqcrRMJxA912pm7F5rU2/2Yj+Qmab0XLVPAD+EYWH2LhDGwaEGjHRS6G zq0lvi9LSt9O12KeeLvP+IpLaAWE9TH+5yJSUvLFh5a+oxDHf2yTMdYY1NrCL+E0vGj9 WLjA== X-Received: by 10.31.47.200 with SMTP id v191mr42082156vkv.116.1451421514577; Tue, 29 Dec 2015 12:38:34 -0800 (PST) In-Reply-To: <20151229203307.GC1884@acm.fritz.box> 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:110982 Archived-At: --001a1143fae0cbc0d805280f673a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Dec 29, 2015 at 3:30 PM Alan Mackenzie wrote: > Hello Andrew and Krist=C3=B3f. > > 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. > Perhaps the right thing to do is to mark it as "wontfix" since it's unlikely to be possible without a big rewrite. What do you think? > > > "Ralovich, "Krist=C3=B3f\"" 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=C3=B3f > > -- > Alan Mackenzie (Nuremberg, Germany). > --001a1143fae0cbc0d805280f673a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Tue= , Dec 29, 2015 at 3:30 PM Alan Mackenzie <= acm@muc.de> wrote:
Hello An= drew and Krist=C3=B3f.

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.=C2=A0 Parsing happens mainly in the backwards direction, and in genera= l,
the #ifdefs in a file form a tree structure.=C2=A0 Which is the line previo= us
to line 6?=C2=A0 It could be L4, it could be L2.=C2=A0 Typically, such &quo= t;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.=C2=A0 In=
fact, something like:

#ifdef A
int foo(int a, int b)
#else
int bar(int a, int b)
{
=C2=A0 if (a > b)
#endif
{
=C2=A0 return a+b;
}

would do it.

I don't know if this problem will ever be fixed.
<= br>
Perhaps the right thing to do is to mark it as "wontfix&= quot; since it's unlikely to be possible without a big rewrite.=C2=A0 W= hat do you think?
=C2=A0

> "Ralovich, "Krist=C3=B3f\"" <kristof.ralovich@gmail.com> 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 snipp= et
> > (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:=C2=A0 =C2=A0return a+b;
> > 8: }

> > the line is getting indented falsely:

> > 1: #ifdef A
> > 2: int foo(int a, int b)
> > 3: #else
> > 4:=C2=A0 =C2=A0int bar(int a, int b)
> > 5: #endif
> > 6: {
> > 7:=C2=A0 =C2=A0return a+b;
> > 8: }

> > I think, it should not get indented, please correct me if I am wr= ong!

> > I am using emacs 22.2 with it's default cc-mode.

> > Looking forward to hearing from you!


> > Krist=C3=B3f

--
Alan Mackenzie (Nuremberg, Germany).
--001a1143fae0cbc0d805280f673a--