Reputation: 3850
I am using C++ mode to write some code.
I found that for some function without a return type, the indentation is wrongly done (indented to start of line). One frequent case is the constructor for class type, e.g.
class Person {
public:
Person(const std::string &s): name(s) { }
Person(const std::string &s0, const std::string &s1): name(s0), address(s1) { }
private:
std::string name = "Default_Name";
std::string address = "Default_Addr";
}
The colon before initializer list may also be a cause.
Question:
Is there away to fix this?
Upvotes: 2
Views: 73
Reputation: 557
The formatting for comments is not very good so I'm answering here:
Yeah, I've been bitten by that before, too. Best solution depends on whether you think you will be writing a lot of C code,too. If you will be, then you can name your C++ headers with ".hh" at the end, so Emacs knows.
Or, you can set a file local variable that sets the mode: file local variables
Or, if you will not be writing a lot of C code, you can modify auto-mode-alist in your .emacs so that .h defaults to c++ mode:
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
Upvotes: 4