GNU bug report logs - #681
Wrong C++ indentation in batch mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs,cc-mode; Reported by: Vivien Mallet <Vivien.Mallet <at> inria.fr>; dated Sat, 9 Aug 2008 15:35:04 UTC; Maintainer for emacs is bug-gnu-emacs <at> gnu.org.
Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#681; Package emacs. Full text available.

Message received at (unknown):


Received: (at unknown) by unknown; unknown
X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02
	(2007-08-08) on rzlab.ucr.edu
X-Spam-Level: 
X-Spam-Status: No, score=-5.0 required=4.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW
	autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02
Received: (at submit) by emacsbugs.donarmstrong.com; 9 Aug 2008 15:26:32 +0000
Received: from lists.gnu.org (lists.gnu.org [199.232.76.165])
	by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m79FQSje023366
	for <submit <at> emacsbugs.donarmstrong.com>; Sat, 9 Aug 2008 08:26:30 -0700
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1KRqKq-0004Fb-2n
	for bug-gnu-emacs <at> gnu.org; Sat, 09 Aug 2008 11:26:28 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1KRqKo-0004Bv-Hx
	for bug-gnu-emacs <at> gnu.org; Sat, 09 Aug 2008 11:26:27 -0400
Received: from [199.232.76.173] (port=58824 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1KRqKo-0004Bg-E2
	for bug-gnu-emacs <at> gnu.org; Sat, 09 Aug 2008 11:26:26 -0400
Received: from smtp8-g19.free.fr ([212.27.42.65]:33222)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <Vivien.Mallet <at> inria.fr>)
	id 1KRqKo-0007KB-0T
	for bug-gnu-emacs <at> gnu.org; Sat, 09 Aug 2008 11:26:26 -0400
Received: from smtp8-g19.free.fr (localhost [127.0.0.1])
	by smtp8-g19.free.fr (Postfix) with ESMTP id 69ABC32A8A9;
	Sat,  9 Aug 2008 17:26:23 +0200 (CEST)
Received: from data.localnet (ver78-6-88-166-87-133.fbx.proxad.net [88.166.87.133])
	by smtp8-g19.free.fr (Postfix) with ESMTP id 40DCF32A886;
	Sat,  9 Aug 2008 17:26:23 +0200 (CEST)
From: Vivien Mallet <Vivien.Mallet <at> inria.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: Wrong C++ indentation in batch mode
Date: Sat, 9 Aug 2008 17:26:22 +0200
User-Agent: KMail/1.10.0 (Linux/2.6.24-19-generic; KDE/4.1.0; i686; ; )
Organization: INRIA Paris-Rocquencourt
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_ecbnIzzH7LbWYfi"
Message-Id: <200808091726.22907.Vivien.Mallet <at> inria.fr>
X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2)

--Boundary-00=_ecbnIzzH7LbWYfi
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

	Hello,

	The indentation in C++ mode does not seem to work properly in batch mode with 
the following code (indented in interactive mode):
"""
template <class A, class B>
Derived<A, B>::Derived():
  Base<A,
       B>() // Problem: wrong indentation in batch mode.
{
}
"""

	Now, define the Lisp function:
(defun cpp_indent ()
  (c-set-style "gnu")
  (c++-mode)
  (indent-region (point-min) (point-max) ())
  (save-buffer)
  )
	And apply it the previous function. It will result in:
"""
template <class A, class B>
Derived<A, B>::Derived():
  Base<A,
  B>() // Problem: wrong indentation in batch mode.
{
}
"""
	which is inconsistent with the interactive and is not, I presume, the 
targeted result.
	I found the problem in Emacs 23.0.60.1 (emacs snapshot in Kubuntu 8.04) and 
in Emacs 22.1.3. It does not appear in Emacs 21.4.1 (Debian Etch).


	Just an unrelated note about the indentation. I found a difference between the 
two latest versions I mentioned and the version 21.4.1. This code (indented 
with Emacs 22+):
"""
template <class A, class B>
Derived0<A, B>::Derived0():
  Base<A, B>
  ()
{
}
"""
	is indented by Emacs 21.4.1 as
"""
template <class A, class B>
Derived0<A, B>::Derived0():
  Base<A, B>
()
{
}
"""
	I like the new indentation better, and I suppose it was an improvement 
introduced in the latest versions. I mention it, just in case...


	I attach three files:
- test.cxx: a file to be indented (but already well indented);
- test-wrong_indentation.cxx: test.cxx after indentation in batch mode with 
Emacs 22+;
- cpp_indent.lisp: the indentation function. Used in: "emacs -batch test.cxx -
l cpp_indent.lisp -f cpp_indent".


	Thank you for your great work,
	Vivien Mallet.

--Boundary-00=_ecbnIzzH7LbWYfi
Content-Type: text/x-c++src;
  charset="us-ascii";
  name="test-wrong_indentation.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test-wrong_indentation.cxx"

template <class A, class B>
Derived<A, B>::Derived():
  Base<A,
  B>() // Problem: wrong indentation in batch mode.
{
}


template <class A, class B>
Derived0<A, B>::Derived0():
  Base<A, B>
  () // Just a note: Emacs 21 did not indent like that.
{
}

--Boundary-00=_ecbnIzzH7LbWYfi
Content-Type: text/x-c++src;
  charset="us-ascii";
  name="test.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test.cxx"

template <class A, class B>
Derived<A, B>::Derived():
  Base<A,
       B>() // Problem: wrong indentation in batch mode.
{
}


template <class A, class B>
Derived0<A, B>::Derived0():
  Base<A, B>
  () // Just a note: Emacs 21 did not indent like that.
{
}

--Boundary-00=_ecbnIzzH7LbWYfi
Content-Type: text/plain;
  charset="us-ascii";
  name="cpp_indent.lisp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="cpp_indent.lisp"

(defun cpp_indent ()
  (c-set-style "gnu")
  (c++-mode)
  (indent-region (point-min) (point-max) ())
  (save-buffer)
  )

--Boundary-00=_ecbnIzzH7LbWYfi--





Acknowledgement sent to Vivien Mallet <Vivien.Mallet <at> inria.fr>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text available.
Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#681; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 20 Sep 2011 19:45:02 UTC

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