From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ariel Shaqed (Scolnicov)" Newsgroups: gmane.emacs.help Subject: Re: Preventing indentation of statements inside #ifdef __cplusplus.... Date: Sun, 17 Jun 2007 09:30:12 +0300 Organization: Correlix Message-ID: <4674d1f4@news.bezeqint.net> References: <1181830420.350207.47690@z28g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit X-Trace: sea.gmane.org 1182076301 3813 80.91.229.12 (17 Jun 2007 10:31:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Jun 2007 10:31:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 17 12:31:40 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hzs2e-0000h9-RT for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2007 12:31:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hzs2e-0007B3-CX for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2007 06:31:32 -0400 Original-Newsgroups: gnu.emacs.help Original-Lines: 34 User-Agent: KNode/0.10.4 Original-NNTP-Posting-Host: 82.81.156.225 Original-X-Trace: news.bezeqint.net 1182061049 82.81.156.225 (17 Jun 2007 09:17:29 +0300) Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!nx02.iad01.newshosting.com!newshosting.com!news.bezeqint.net!not-for-mail Original-Xref: shelby.stanford.edu gnu.emacs.help:149537 X-Mailman-Approved-At: Sun, 17 Jun 2007 06:31:15 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45127 Archived-At: 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.