GNU bug report logs - #4187
Bug with indentation / parens matching in C++-mode

Previous Next

Packages: cc-mode, emacs21;

Reported by: "Tobias.Schlueter" <Tobias.Schlueter <at> zuppc13.physik.uni-muenchen.de>

Date: Thu, 20 Aug 2009 19:41:45 UTC

Severity: normal

Done: Glenn Morris <rgm <at> gnu.org>

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 4187 in the body.
You can then email your comments to 4187 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#4187; Package emacs. (Thu, 20 Aug 2009 19:41:46 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Tobias.Schlueter" <Tobias.Schlueter <at> zuppc13.physik.uni-muenchen.de>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 20 Aug 2009 19:41:47 GMT) Full text and rfc822 format available.

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

From: "Tobias.Schlueter" <Tobias.Schlueter <at> zuppc13.physik.uni-muenchen.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Bug with indentation / parens matching in C++-mode
Date: Tue, 18 Aug 2009 14:04:21 +0200 (CEST)
This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs <at> gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.4.1 (i686-redhat-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2008-01-04 on norob.fnal.gov
configured using `configure  --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-pop --with-sound'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

Type the following into a buffer which is in C++ mode.  Try to get
correct indentation for the second line of the while condition or the
line following it by hitting the TAB key.  In my case this fails
miserably.  Modifying the while condition to fix this behaves rather
erratically, adding parentheses at least doesn't fix it.

{
  do {
  } while (fabs(chi2 - oldChi2) > 0
      && count < iterMax);
x= 1;
}

You can reach me under tobi <at> schlueters.de, I don't know if this
interface will place the right sender address on the mail.  I guess
the stuff emacs put below will not be of much help, so I'm cutting it
(recent input, the bug appears independent of my input).

Cheers,
- Tobias Schlüter




bug reassigned from package 'emacs' to 'emacs,cc-mode'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Fri, 21 Aug 2009 01:15:06 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4187; Package emacs,cc-mode. (Fri, 21 Aug 2009 15:00:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to bug-cc-mode <at> gnu.org:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Fri, 21 Aug 2009 15:00:05 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: "Tobias.Schlueter" <Tobias.Schlueter <at> zuppc13.physik.uni-muenchen.de>,
        4187 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org, tobi <at> schlueters.de, bug-cc-mode <at> gnu.org
Subject: Re: bug#4187: Bug with indentation / parens matching in C++-mode
Date: Fri, 21 Aug 2009 14:56:54 +0000
Hi, Tobias!

On Tue, Aug 18, 2009 at 02:04:21PM +0200, Tobias.Schlueter wrote:

> In GNU Emacs 21.4.1 (i686-redhat-linux-gnu, X toolkit, Xaw3d scroll bars)
>  of 2008-01-04 on norob.fnal.gov

OK, Emacs 21.4.  That's very old.  Emacs 22 was released in June 2007.
Emacs 23 was released a few weeks ago, on 30th July.  You could do worse
than upgrading (or persuading your sysadmins to upgrade).  Emacs 21
contained CC Mode 28, which is so old as to be barely supportable.  If
you can't upgrade your Emacs, you could certainly install a newer version
of CC Mode in one of your own directories (see
<http://cc-mode.sf.net/release.php>).

> Type the following into a buffer which is in C++ mode.

What version of CC Mode are you using (M-x c-version)?  Have you or
anybody else customised CC Mode at all?  It might well help to see your
complete CC Mode configuration (C-c C-b from within your C++ buffer,
followed by cutting and pasting).

> Try to get correct indentation for the second line of the while
> condition or the line following it by hitting the TAB key.  In my case
> this fails miserably.  Modifying the while condition to fix this
> behaves rather erratically, adding parentheses at least doesn't fix it.

Just as a suggestion, it might help things if you put a proper function
header before the opening "{".  It might not, though.

People's opinions differ on what "correct" indentation is, which is why
you can (and, sadly, MUST) configure it.  So could you please say how you
would like the line to be indented.

One thing you could do is, with point on the "&& count" line, C-c C-s.
This will give the syntactic analysis of the line, something like:

    Syntactic analysis: ((arglist-cont-nonempty 347 355))

.  This says "the line is a continued argument list whose "anchor points"
are at buffer positions 347 and 355".  This is explained in the CC Mode
manual in full detail.

Now try C-c C-o.  It will prompt you with something like:

    Syntactic symbol to change: arglist-cont-nonempty

, and when you hit <CR>, you'll get, say,:

    arglist-cont-nonempty offset (default (c-lineup-gcc-asm-reg c-lineup-arglist)):

, where you can type the new "offset" that you want.  Try entering "+",
or "++" or "*" or "-" here, just to get an idea of how this works.  Then
hit the <tab> key.  Again, the full details of all this stuff are in the
CC Mode manual.  I can give you better help once you've replied with the
details I've asked for.

> {
>   do {
>   } while (fabs(chi2 - oldChi2) > 0
>       && count < iterMax);
> x= 1;
> }

> You can reach me under tobi <at> schlueters.de, I don't know if this
> interface will place the right sender address on the mail.

It didn't, but I have.  :-)  I've also directed your reply to
bug-cc-mode <at> gnu.org, which is a more specific mailing list.

> I guess the stuff emacs put below will not be of much help, so I'm
> cutting it (recent input, the bug appears independent of my input).

Thanks!

> Cheers,
> - Tobias Schlüter

Schöne Grüße aus Nürnberg!

-- 
Alan Mackenzie.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#4187; Package emacs,cc-mode. (Fri, 21 Aug 2009 15:00:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to bug-cc-mode <at> gnu.org:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Fri, 21 Aug 2009 15:00:11 GMT) Full text and rfc822 format available.

bug reassigned from package 'emacs,cc-mode' to 'emacs21,cc-mode'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sat, 22 Aug 2009 20:20:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, owner <at> emacsbugs.donarmstrong.com:
bug#4187; Package emacs21,cc-mode. (Tue, 22 Sep 2009 09:00:17 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Schlüter <tobias.schlueter <at> physik.uni-muenchen.de>:
Extra info received and forwarded to list. Copy sent to owner <at> emacsbugs.donarmstrong.com. (Tue, 22 Sep 2009 09:00:17 GMT) Full text and rfc822 format available.

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

From: Tobias Schlüter
 <tobias.schlueter <at> physik.uni-muenchen.de>
To: bug-cc-mode <at> gnu.org
Cc: 4187 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, tobi <at> schlueters.de
Subject: Re: bug#4187: Bug with indentation / parens matching in C++-mode
Date: Tue, 22 Sep 2009 10:51:28 +0200
Hi,

sorry for not getting back to you earlier, and thank you very much for 
the detailed reply.

Alan Mackenzie wrote:
> Hi, Tobias!
> 
> On Tue, Aug 18, 2009 at 02:04:21PM +0200, Tobias.Schlueter wrote:
> 
>> In GNU Emacs 21.4.1 (i686-redhat-linux-gnu, X toolkit, Xaw3d scroll bars)
>>  of 2008-01-04 on norob.fnal.gov
> 
> OK, Emacs 21.4.  That's very old.

Whoops, yes, of course, everything works as expected with a newer 
version.  Hence I don't think it's worth wasting your time with a 
detailed answer.

Just for the record, I'm perfectly happy with GNU-style indentation, and 
my old version of cc-mode failed to do this for the example I quoted 
again below, maybe it's something for the cc-mode testsuite, if 
something like that exists.

>> {
>>   do {
>>   } while (fabs(chi2 - oldChi2) > 0
>>       && count < iterMax);
>> x= 1;
>> }
> 

Cheers,
- Tobias Schlüter




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, owner <at> emacsbugs.donarmstrong.com:
bug#4187; Package emacs21,cc-mode. (Tue, 22 Sep 2009 09:00:26 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Schlüter <tobias.schlueter <at> physik.uni-muenchen.de>:
Extra info received and forwarded to list. Copy sent to owner <at> emacsbugs.donarmstrong.com. (Tue, 22 Sep 2009 09:00:27 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 4187 <at> debbugs.gnu.org and "Tobias.Schlueter" <Tobias.Schlueter <at> zuppc13.physik.uni-muenchen.de> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 01 Mar 2011 05:32:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 29 Mar 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 84 days ago.

Previous Next


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