Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Emacs indenting CPP directives/region in C++ [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
tenspd137
Guru
Guru


Joined: 22 Aug 2006
Posts: 391

PostPosted: Thu Nov 22, 2012 3:04 am    Post subject: Emacs indenting CPP directives/region in C++ [solved] Reply with quote

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
View user's profile Send private message
paulj
Guru
Guru


Joined: 30 Sep 2004
Posts: 507
Location: Wales, UK

PostPosted: Sun Nov 25, 2012 11:53 am    Post subject: Reply with quote

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
View user's profile Send private message
tenspd137
Guru
Guru


Joined: 22 Aug 2006
Posts: 391

PostPosted: Fri Nov 30, 2012 1:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum