unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#681: Wrong C++ indentation in batch mode
@ 2008-08-09 15:26 Vivien Mallet
  2008-08-10 16:42 ` OFFICE ZERO
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Vivien Mallet @ 2008-08-09 15:26 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]

	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.

[-- Attachment #2: test-wrong_indentation.cxx --]
[-- Type: text/x-c++src, Size: 251 bytes --]

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

[-- Attachment #3: test.cxx --]
[-- Type: text/x-c++src, Size: 256 bytes --]

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

[-- Attachment #4: cpp_indent.lisp --]
[-- Type: text/plain, Size: 121 bytes --]

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

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-02-07 22:10 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-09 15:26 bug#681: Wrong C++ indentation in batch mode Vivien Mallet
2008-08-10 16:42 ` OFFICE ZERO
     [not found]   ` <handler.681.B681.12183870793367.ackinfo@emacsbugs.donarmstrong.com>
2008-08-10 17:10     ` bug#681: Info received (bug#681: Wrong C++ indentation in batch mode) OFFICE ZERO
     [not found]       ` <handler.681.B681.121838828710091.ackinfo@emacsbugs.donarmstrong.com>
2008-08-11  1:17         ` bug#681: Info received (bug#681: Info received (bug#681: Wrong C++ indentation in batch mode)) OFFICE ZERO
2008-08-10 17:01 ` bug#681: Wrong C++ indentation in batch mode OFFICE ZERO
     [not found]   ` <handler.681.B681.12183876726365.ackinfo@emacsbugs.donarmstrong.com>
2008-08-11  1:17     ` bug#681: Info received (bug#681: Wrong C++ indentation in batch mode) OFFICE ZERO
2008-08-10 17:11 ` bug#681: Wrong C++ indentation in batch mode OFFICE ZERO
     [not found]   ` <handler.681.B681.121838833410165.ackinfo@emacsbugs.donarmstrong.com>
2008-08-11  1:16     ` bug#681: Info received (bug#681: Wrong C++ indentation in batch mode) OFFICE ZERO
2008-08-10 17:12 ` bug#681: Wrong C++ indentation in batch mode OFFICE ZERO
     [not found]   ` <handler.681.B681.121838833410168.ackinfo@emacsbugs.donarmstrong.com>
2008-08-11  1:07     ` bug#681: Info received (bug#681: Wrong C++ indentation in batch mode) OFFICE ZERO
2014-01-07 10:26 ` bug#681: Wrong C++ indentation in batch mode Bastien Guerry
2014-01-07 15:36   ` Vivien Mallet
2014-01-07 16:09     ` Bastien
2015-12-29  1:18       ` Andrew Hyatt
2015-12-29 22:02         ` Alan Mackenzie
2016-01-04 23:16         ` Alan Mackenzie
2016-01-26  4:46           ` Andrew Hyatt
2016-02-06 12:05           ` Vivien Mallet
2016-02-07 22:09             ` Alan Mackenzie
2016-02-07 22:10               ` Vivien Mallet

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).