--- Begin Message ---
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; ; ) |
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.
test-wrong_indentation.cxx
Description: Text Data
test.cxx
Description: Text Data
cpp_indent.lisp
Description: Text document
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#681: Wrong C++ indentation in batch mode |
Date: |
Sun, 7 Feb 2016 22:09:31 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
Hello, Vivien.
On Sat, Feb 06, 2016 at 01:05:48PM +0100, Vivien Mallet wrote:
> Hello,
> On Tue, Jan 05 2016, Alan Mackenzie wrote:
> > I've committed what I hope is a fix to the emacs-25 branch at savannah.
> > Sorry it's taken (a lot) longer than it should have done.
> Sure, 7.5 years is a long time! But it is good to see this bug report
> was not lost, contrary to other reports.
> > Would you please tell me what version of Emacs you're currently using,
> > and I will try to adapt the patch for that version. Then I will ask you
> > to try out the patch and let me know whether or not there are still
> > errors.
> My current version is 24.5.3.
> I am not sure this is so useful that the fix is tested on this
> version. Instead, I could check with the latest version in the branch
> you mention. I have just tried to compile current version, but I got
> this error
> CC callint.o
> alloc.c:1137:1: error: static declaration of ?aligned_alloc? follows
> non-static declaration
> aligned_alloc (size_t alignment, size_t size)
> ^
> In file included from alloc.c:31:0:
> lisp.h:3779:14: note: previous declaration of ?aligned_alloc? was here
> extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2));
> I do not have a lot of time to dig. So you might just mark the bug as
> resolved!
OK, then, I'll do that!
Thanks again for the bug report, all these years ago.
> Thank you,
> Vivien.
--
Alan Mackenzie (Nuremberg, Germany).
--- End Message ---