View previous topic :: View next topic |
Author |
Message |
tenspd137 Guru
Joined: 22 Aug 2006 Posts: 391
|
Posted: Thu Nov 22, 2012 3:04 am Post subject: Emacs indenting CPP directives/region in C++ [solved] |
|
|
Hi all,
I was wondering if anyone knew how to get emacs to turn code like this:
Code: |
#indef _SOMETHING_
typedef struct {
float a;
float b;
};
#endif
|
into this:
Code: |
#indef _SOMETHING_
typedef struct {
float a;
float b;
};
#endif
|
So far, I can't seem to get it to indent what is between the preprocessor directives, and I don't know what that would be called in elisp.
Thanks in advance!
Last edited by tenspd137 on Fri Nov 30, 2012 1:53 am; edited 1 time in total |
|
Back to top |
|
|
paulj Guru
Joined: 30 Sep 2004 Posts: 507 Location: Wales, UK
|
Posted: Sun Nov 25, 2012 11:53 am Post subject: |
|
|
I just typed your example in, and it did exactly what you want.
Are you in C mode? If you start typing in the scratch buffer, it won't know you have a C file unless you set it (<meta>-x c-mode). Alternatively, if you start a new file, use "Visit New File" (C-x C-f) and name the file.
I can share my .emacs with you if that helps, but I don't have anything there which changes the default behaviour of the C-mode. I am using emacs 2.24.13.
edit: just thought - the other thing which screws up auto indenting is errors further up the file (assuming this is not at the top) |
|
Back to top |
|
|
tenspd137 Guru
Joined: 22 Aug 2006 Posts: 391
|
Posted: Fri Nov 30, 2012 1:53 am Post subject: |
|
|
Thanks for the reply! Actually, I just restarted it and it worked as well. I don't know what was messed up :/ |
|
Back to top |
|
|
|