help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preventing indentation of statements inside #ifdef __cplusplus....


From: Ariel Shaqed (Scolnicov)
Subject: Re: Preventing indentation of statements inside #ifdef __cplusplus....
Date: Sun, 17 Jun 2007 09:30:12 +0300
User-agent: KNode/0.10.4

Nordlöw wrote:

> How can I instruct Emacs *not* to indent declarations and definitions
> such as the statement foo(); between the following standard snippets?:
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> 
> foo();
> 
> #ifdef __cplusplus
> }
> #endif

You can define and use the following style.

1. Add to your .emacs:
  ;;; C++ style: don't indent namespaces
  (c-add-style "my_style"
             '("user"
               (c-offsets-alist
                (inextern-lang . 0))))
2. In the buffer, try "C-c . my_style RET" to try it out, then if
satisfied "M-x customize-variable c-default-style RET" and set up c++-mode
to use my_style.

Note that the above *always* inhibits indentation of extern "C" bodies, not
just those #ifdef'ed out.  I consider this the right thing to do -- you
might not.

Hope this helps,
-- 
Ariel.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]