GNU bug report logs - #341
c-indent-command misindents?

Previous Next

Packages: emacs, cc-mode;

Reported by: "Ralovich, Kristóf" <kristof.ralovich <at> gmail.com>

Date: Sat, 31 May 2008 15:20:03 UTC

Severity: normal

Tags: wontfix

Found in version 24.0.90

Done: Andrew Hyatt <ahyatt <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 341 in the body.
You can then email your comments to 341 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#341; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Ralovich, Kristóf" <kristof.ralovich <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Ralovich, Kristóf" <kristof.ralovich <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
Subject: c-indent-command misindents?
Date: Sat, 31 May 2008 17:13:49 +0200
[Message part 1 (text/plain, inline)]
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
[cc-mode-bug.c (text/x-csrc, attachment)]

Owner recorded as Alan Mackenzie <acm <at> muc.de>. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Tue, 01 Jul 2008 01:05:06 GMT) Full text and rfc822 format available.

bug reassigned from package `emacs' to `emacs,cc-mode'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 14 Aug 2008 16:45:04 GMT) Full text and rfc822 format available.

Removed annotation that bug was owned by Alan Mackenzie <acm <at> muc.de>. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 29 Jan 2010 19:07:02 GMT) Full text and rfc822 format available.

bug Marked as found in versions 24.0.90. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 03 Oct 2011 20:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Tue, 29 Dec 2015 04:07:01 GMT) Full text and rfc822 format available.

Message #16 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Ralovich, Kristóf <kristof.ralovich <at> gmail.com>
Cc: bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org, 341 <at> debbugs.gnu.org
Subject: Re: bug#341: c-indent-command misindents?
Date: Mon, 28 Dec 2015 19:48:22 -0500
I've reproduced this bug in emacs 25.

It seems like a real problem, thanks (belatedly) for reporting!

"Ralovich, "Kristóf\"" <kristof.ralovich <at> 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 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




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Tue, 29 Dec 2015 04:07:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Tue, 29 Dec 2015 20:31:02 GMT) Full text and rfc822 format available.

Message #22 received at 341 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: Ralovich <at> debbugs.gnu.org, 341 <at> debbugs.gnu.org,
 Kristóf <kristof.ralovich <at> gmail.com>
Subject: Re: bug#341: c-indent-command misindents?
Date: Tue, 29 Dec 2015 20:33:07 +0000
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\"" <kristof.ralovich <at> 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 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).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Tue, 29 Dec 2015 20:39:01 GMT) Full text and rfc822 format available.

Message #25 received at 341 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Ralovich <at> debbugs.gnu.org, 341 <at> debbugs.gnu.org,
 Kristóf <kristof.ralovich <at> gmail.com>
Subject: Re: bug#341: c-indent-command misindents?
Date: Tue, 29 Dec 2015 20:38:24 +0000
[Message part 1 (text/plain, inline)]
On Tue, Dec 29, 2015 at 3:30 PM Alan Mackenzie <acm <at> muc.de> wrote:

> 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.
>

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óf\"" <kristof.ralovich <at> 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 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).
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Mon, 11 Jan 2016 03:13:02 GMT) Full text and rfc822 format available.

Message #28 received at 341 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Ralovich <at> debbugs.gnu.org,
 Kristóf <kristof.ralovich <at> gmail.com>,
 341 <at> debbugs.gnu.org
Subject: Re: bug#341: c-indent-command misindents?
Date: Sun, 10 Jan 2016 22:12:40 -0500
Andrew Hyatt <ahyatt <at> gmail.com> writes:

> On Tue, Dec 29, 2015 at 3:30 PM Alan Mackenzie <acm <at> muc.de> wrote:
>
>
>  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.
>
>
> 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?

I'm going to go ahead and do that, due to lack of opposition. Please
unmark or just let me know if you disagree.

>
>
>  > "Ralovich, "Kristóf\"" <kristof.ralovich <at> 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 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).




Added tag(s) wontfix. Request was from Andrew Hyatt <ahyatt <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 11 Jan 2016 03:13:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 341 <at> debbugs.gnu.org and "Ralovich, Kristóf" <kristof.ralovich <at> gmail.com> Request was from Andrew Hyatt <ahyatt <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 11 Jan 2016 03:13:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#341; Package emacs,cc-mode. (Mon, 11 Jan 2016 13:34:02 GMT) Full text and rfc822 format available.

Message #35 received at 341 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: Ralovich <at> debbugs.gnu.org,
 Kristóf <kristof.ralovich <at> gmail.com>, 341 <at> debbugs.gnu.org
Subject: Re: bug#341: c-indent-command misindents?
Date: Mon, 11 Jan 2016 13:35:48 +0000
Hello, Andrew.

On Sun, Jan 10, 2016 at 10:12:40PM -0500, Andrew Hyatt wrote:
> Andrew Hyatt <ahyatt <at> gmail.com> writes:

> > On Tue, Dec 29, 2015 at 3:30 PM Alan Mackenzie <acm <at> muc.de> wrote:


> >  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.


> > 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?

> I'm going to go ahead and do that, due to lack of opposition. Please
> unmark or just let me know if you disagree.

Yes, I suppose that's the best thing to do, although I'm ambivalent about
it.  Maybe sometime in the distant future there will perhaps be extra
support in the syntax functionality which would make a fix for this
easier to design and implement.  Maybe.  <Sigh>.

So, yes, please go ahead and close it as "won't fix".

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 09 Feb 2016 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.