Reputation: 1474
Does anybody know how to inhibit emacs from indenting the name of functions or classes after a template clause?
Currenty the result is:
template <typename T>
class A {
/* ... */
};
where I would like to have:
template <typename T>
class A {
/* ... */
};
Thank you very much for your help.
EDIT 1 I'm using c++-mode with java as indent style for c++. I customized the c-offset-alist in this way:
(custom-set-variables
;;
'(c-offsets-alist (quote ((case-label . +) (innamespace . 0))))
Upvotes: 6
Views: 2087
Reputation: 28850
Go to the class
line and hit TAB
to perform the (unsolicited) indentation.
Then press Control-CControl-Oto display the indent mode for
topmost-intro-cont`
Press ENTER
, then you can change the indent number (3 to 0 for instance).
At the end of your .emacs
you can set permanently that instruction:
(c-set-offset 'topmost-intro-cont 0 nil)
Upvotes: 9
Reputation: 7048
A couple of different things to check:
I've seen similar issues when editing C++ .h files in C-mode instead of C++-mode. By default, .h files are C-mode, not C++-mode. [You can check this by looking for "C++" or "C" in parenthesis at the bottom of your window.] You can setup emacs to always open .h files as C++ by using the following in your .emacs
(setq auto-mode-alist (append '(("\\.h\\'" . c++-mode)
)
auto-mode-alist
))
The other thing to check is how you have setup your c-default-style. The info page for "CC Mode" goes into a lot more detail on all of the possibilities.
Upvotes: 1
Reputation: 47213
There are different styles for indentation for Emacs' C++ mode. Quoting EmacsWiki:
A partial list of the better known C styles:
The c-default-style
variable is what you need to change. Perhaps one of them will be what you need. Don't have Emacs right now, so I can't check them out.
Upvotes: 4
Reputation: 5459
I don't know, but I imagine your mode makes a difference. In what mode are you editing? I assume c++-mode cause you have c++
as a tag.
For me, in c++-mode, it turned out like this:
template <typename T>
class A {
/* ... */
};
With the comments indented, but class A
not indented.
Upvotes: 1