From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jules Colding Newsgroups: gmane.emacs.help 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 Message-ID: <1AEEB8AA-7A49-4338-B5EC-9234FE5C1CFD@venalicium.dk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1328306743 20618 80.91.229.3 (3 Feb 2012 22:05:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Feb 2012 22:05:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 03 23:05:43 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RtRGG-0002iP-KY for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Feb 2012 23:05:40 +0100 Original-Received: from localhost ([::1]:54829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtRGF-0002Se-N9 for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Feb 2012 17:05:39 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtR0s-0007Kc-3z for help-gnu-emacs@gnu.org; Fri, 03 Feb 2012 16:49:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtR0p-0006Mu-6C for help-gnu-emacs@gnu.org; Fri, 03 Feb 2012 16:49:46 -0500 Original-Received: from mail7.surf-town.net ([212.97.132.47]:32902 helo=mailgw21.surf-town.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtR0p-0006Lz-0S for help-gnu-emacs@gnu.org; Fri, 03 Feb 2012 16:49:43 -0500 Original-Received: by mailgw21.surf-town.net (Postfix, from userid 65534) id DF47042F5; Fri, 3 Feb 2012 22:49:40 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by mailgw21.surf-town.net (Postfix) with ESMTP id D187543D1 for ; Fri, 3 Feb 2012 22:49:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mailgw21.surf-town.net Original-Received: from mailgw21.surf-town.net ([127.0.0.1]) by localhost (mailgw21.surf-town.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 74nkrFHrfXm4 for ; Fri, 3 Feb 2012 22:49:34 +0100 (CET) Original-Received: from [192.168.0.43] (unknown [188.183.226.138]) by mailgw21.surf-town.net (Postfix) with ESMTPSA id 9A48442F5 for ; Fri, 3 Feb 2012 22:49:34 +0100 (CET) X-Mailer: Apple Mail (2.1257) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.97.132.47 X-Mailman-Approved-At: Fri, 03 Feb 2012 17:05:35 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83643 Archived-At: 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=85 I'd prefer if I = could convince emacs to indent include statement half the amount of = whitespace that normal code would be indented.=20 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 #ifdef __linux__ #include #endif int=20 func(void) { int foo =3D 0; #ifdef DO_STUFF foo =3D do_stuff(); #endif return foo; } instead of the current affair: #include #ifdef __linux__ #include #endif int=20 func(void) { int foo =3D 0; #ifdef DO_STUFF foo =3D 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...=20 Would anyone have code that solves this or pointers to something that is = close to what I want? Thanks a lot, jules