bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#341: c-indent-command misindents?


From: Alan Mackenzie
Subject: bug#341: c-indent-command misindents?
Date: Tue, 29 Dec 2015 20:33:07 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]