[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How do I make emacs indent treat #ifdef and #endif as if they were { and
From: |
Jules Colding |
Subject: |
How do I make emacs indent treat #ifdef and #endif as if they were { and }? |
Date: |
Fri, 3 Feb 2012 22:49:35 +0100 |
Hi,
I've tried to figure out how to make emacs indent #ifdef blocks just like it
would curly brace blocks. With a twist though… I'd prefer if I could convince
emacs to indent include statement half the amount of whitespace that normal
code would be indented.
My preference is to indent code with 8 spaces (or one tab of that size) and
then use 4 spaces for include statements. Within code my preference would be if
"#ifdef" was treated exactly as a "{" and "#endif" like a "}", indentation wise.
Like this:
#include <ifaddrs.h>
#ifdef __linux__
#include <sys/socket.h>
#endif
int
func(void)
{
int foo = 0;
#ifdef DO_STUFF
foo = do_stuff();
#endif
return foo;
}
instead of the current affair:
#include <ifaddrs.h>
#ifdef __linux__
#include <sys/socket.h>
#endif
int
func(void)
{
int foo = 0;
#ifdef DO_STUFF
foo = do_stuff();
#endif
return foo;
}
Messing around with the indentation functions in emacs seems like a black art.
Likely because I don't do lisp well...
Would anyone have code that solves this or pointers to something that is close
to what I want?
Thanks a lot,
jules
- How do I make emacs indent treat #ifdef and #endif as if they were { and }?,
Jules Colding <=