all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How do I make emacs indent treat #ifdef and #endif as if they were { and }?
@ 2012-02-03 21:49 Jules Colding
  2012-02-08 21:57 ` Ken Goldman
       [not found] ` <mailman.3503.1328738521.15002.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Jules Colding @ 2012-02-03 21:49 UTC (permalink / raw)
  To: help-gnu-emacs

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






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-04  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 21:49 How do I make emacs indent treat #ifdef and #endif as if they were { and }? Jules Colding
2012-02-08 21:57 ` Ken Goldman
2012-02-08 22:01   ` Jules Colding
     [not found] ` <mailman.3503.1328738521.15002.help-gnu-emacs@gnu.org>
     [not found]   ` <jjh1pi$7kb$4@reader1.panix.com>
     [not found]     ` <icpqcjye2l.fsf@home.home>
2012-04-04  7:41       ` David Combs

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.