Note that there are some explanatory texts on larger screens.

plurals
  1. POemacs public/protected/private label indentation of C++ header file not working for zero offset
    primarykey
    data
    text
    <p>I cannot get zero offset for some things for my C++ header files in emacs even if I have it defined in my .emacs file. </p> <p>The header file below shows a class definition inside two namespaces and most importantly the public keyword I would like to have with zero offset like below.</p> <pre><code>namespace n1 { namespace n2 // no offset { class SomeClass // no offset from namespace open curly { public: // this line with zero offset SomeClass(); // offset 4 ... }; inline SomeClass::SomeClass() // no offset { } } // n2 } // n2 </code></pre> <p>In my .emacs file I have added label like this:</p> <pre><code>(c-set-offset 'label 0) </code></pre> <p>I used Ctrl-C Ctrl-S to find out what to modify. Other offsets I have defined in the .emacs file are working fine and also values other than 0 work for label.</p> <p>When I set offset 0 for label it turns out to be 1 when hitting tab for that line. This is strange and looks like something else is overriding or adding a minimum of 1.</p> <p>Can anyone explain how I can achieve what I want and maybe also an explanation what is happening currently?</p> <p>Phew, this was my first question here. Thanks :)</p> <p>UPDATE:</p> <p>Thanks to the answers I have been able to get a bit farther, but still no solution overall, because changing the things necessary to get total offset 0 for the accessors result in other things I don't want. Thsi is where I'm currently:</p> <pre><code>(c-set-offset 'access-label 0) </code></pre> <p>I also needed to get the .h file to be understoor as C++, so I added:</p> <pre><code>(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) </code></pre> <p>This alone is not removing the 1 offset I was seeing, but it seems there is also inclass for the accessor. Setting this to 0 actually results in total 0 offset.</p> <pre><code>(c-set-offset 'inclass 0) </code></pre> <p>Problem is that now other things such as members are with total of 0 like below:</p> <pre><code>class Foo { public: Foo(); ~Foo(); </code></pre> <p>To remedy this I changed topmost-intro to offset 4</p> <pre><code>(c-set-offset 'topmost-intro 4) </code></pre> <p>Which in turn resulted in other changes for e.g. inline function declarations in the same file. All in all, I'm not sure how to tweak this the way I want it.</p> <p>UPDATE2:</p> <p>Added inline declaration of SomeClass ctor with no offset.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload