Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ variable declaration alignment.

35 views
Skip to first unread message

Andrea Venturoli

unread,
Jul 18, 2012, 11:16:40 AM7/18/12
to
Hello.
I'm using emacs to code in C++ and I'm unhappy with how it alignes
variable declarations.

What I get is:

double a,
b;

What I'd like to get is:
double a,
b;

Is there any way to do this?



Also, suppose I have:

return a==b||
a==c||
a==d;

I'd like to get:
return a==b||
a==c||
a==d;

Is this possible too?


bye & Thanks
av.

Peter

unread,
Jul 18, 2012, 5:28:29 PM7/18/12
to
There may well be an easier answer - but I use the align.el package for any customised alignment issues. It is a great package written by John Wiegley and is a part of the Emacs distribution.

Chris Gordon-Smith

unread,
Jul 19, 2012, 4:48:02 PM7/19/12
to
Andrea Venturoli <ml.die...@netfence.it>:
Have you tried the various alignment options? In my .emacs I have:
;; Indentation style
(setq c-default-style "stroustrup")

But I could have had one of several others. 'gnu', 'k&r', 'bsd',
'whitesmith', 'ellemtel, 'linux'...

Chris Gordon-Smith
www.simsoup.info

Andrea Venturoli

unread,
Jul 23, 2012, 8:07:51 AM7/23/12
to
On 07/19/12 22:48, Chris Gordon-Smith wrote:
> Have you tried the various alignment options? In my .emacs I have:
> ;; Indentation style
> (setq c-default-style "stroustrup")
>
> But I could have had one of several others. 'gnu', 'k&r', 'bsd',
> 'whitesmith', 'ellemtel, 'linux'...

Yes.
Unless I'm missing something, none of them does what I asked.
Am I missing something?

bye & Thanks
av.

Andrea Venturoli

unread,
Jul 23, 2012, 8:08:43 AM7/23/12
to
Thanks.
I tried it, but I'm not proficient with emacs lisp and found no good
documentation (at least not good for me).
Is there any howto?

bye & Thanks
av.

Chris Gordon-Smith

unread,
Jul 24, 2012, 6:24:41 PM7/24/12
to
Andrea Venturoli <ml.die...@netfence.it>:

> > But I could have had one of several others. 'gnu', 'k&r', 'bsd',
> > 'whitesmith', 'ellemtel, 'linux'...
>
> Yes.
> Unless I'm missing something, none of them does what I asked.
> Am I missing something?
>

You're probably not missing anything. I just wondered whether you had
tried all the available options.

My approach was to look at all the supported indentation schemes and
decide which I liked best. Out of these, I preferred stroustrup. I
didn't feel strongly enough about it to think I needed to find or
invent another.

Best Regards
CHris Gordon-Smith
www.simsoup.info

Ludwig, Mark

unread,
Jul 26, 2012, 11:50:07 AM7/26/12
to Andrea Venturoli, help-gn...@gnu.org
> From: Andrea Venturoli
> Sent: Monday, July 23, 2012 7:08 AM
> To: help-gn...@gnu.org
> Subject: Re: C++ variable declaration alignment.
I had a need to make Emacs align C, C++, and Java code the way the rest of the organization was aligning by hand (with spaces in vi and other editors). The way I got it to do what I wanted was to create my own "style" -- and that requires writing a small amount of Emacs Lisp....

Cheers,
Mark


0 new messages