help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ Classes, Access Identifiers indentation


From: Pascal J. Bourguignon
Subject: Re: C++ Classes, Access Identifiers indentation
Date: Sun, 21 Oct 2012 22:33:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

David Gomes <david@elementaryos.org> writes:

> Hello,
>
> class MyClass {
> public:
>   int a = 5;
>
> private:
> }
>
> On c++-mode, I was getting that kind of indentation on a class on a .hpp 
> file. I went to #emacs to
> look for help and a very kind man offered a couple of solutions:
>
> (c-set-offset 'access-label '+) ;This results in:
>
> class Yerkusk {
>     public:
>   int a = 5;
>
>     private:
> }
>
> (c-set-offset 'access-label '/) ; This results in:
>
> class Yerkusk {
>  public:
>   int a = 5;
>
>  private:
> }
>
> My c-basic-offset is 2 and ideally I want it to look like this:
>
> class Yerkusk {
>   public:
>     int a = 5;
>
>    private:
> }
>
> Any ideas? Thank you in advance.


You can learn what syntax the contents has with M-: (c-point-syntax) RET
with the point at the beginning of a contents line.  I see here that
it's inclass.  Then you can c-set-offset them as you wish.  Notice that
access-label is computed relative to inclass, so we set it to -2, and
set inclass to 4:

class MyClass {
  public:              // ((inclass 1) (access-label 1))
    int a = 5;         // ((inclass 1) (topmost-intro 1))
  private:
    int a = 5;
}

// Local Variables:
// eval: (c-set-offset 'access-label  -2)
// eval: (c-set-offset 'inclass        4)
// End:


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]