unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Preventing indentation of statements inside #ifdef __cplusplus....
@ 2007-06-14 14:13 Nordlöw
  2007-06-17  6:30 ` Ariel Shaqed (Scolnicov)
  0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2007-06-14 14:13 UTC (permalink / raw)
  To: help-gnu-emacs

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


Thanks,
Nordlöw

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

* Re: Preventing indentation of statements inside #ifdef __cplusplus....
  2007-06-14 14:13 Preventing indentation of statements inside #ifdef __cplusplus Nordlöw
@ 2007-06-17  6:30 ` Ariel Shaqed (Scolnicov)
  0 siblings, 0 replies; 2+ messages in thread
From: Ariel Shaqed (Scolnicov) @ 2007-06-17  6:30 UTC (permalink / raw)
  To: help-gnu-emacs

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.

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

end of thread, other threads:[~2007-06-17  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-14 14:13 Preventing indentation of statements inside #ifdef __cplusplus Nordlöw
2007-06-17  6:30 ` Ariel Shaqed (Scolnicov)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).