From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Newsgroups: gmane.emacs.help Subject: Re: Changing Emacs indentation behavior Date: Sat, 19 Jul 2008 04:13:01 +0200 Message-ID: <200807190413.01436.juanma_bellon@yahoo.es> References: <18539174.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216433620 31340 80.91.229.12 (19 Jul 2008 02:13:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Jul 2008 02:13:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 19 04:14:27 2008 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 1KK1xq-0006oe-OI for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Jul 2008 04:14:27 +0200 Original-Received: from localhost ([127.0.0.1]:48193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KK1wx-0005Re-Kd for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Jul 2008 22:13:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KK1wY-0005Pd-SW for help-gnu-emacs@gnu.org; Fri, 18 Jul 2008 22:13:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KK1wW-0005M2-9o for help-gnu-emacs@gnu.org; Fri, 18 Jul 2008 22:13:05 -0400 Original-Received: from [199.232.76.173] (port=58563 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KK1wW-0005Lm-5f for help-gnu-emacs@gnu.org; Fri, 18 Jul 2008 22:13:04 -0400 Original-Received: from n16a.bullet.mail.mud.yahoo.com ([68.142.207.126]:43328) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KK1wV-0007H1-3a for help-gnu-emacs@gnu.org; Fri, 18 Jul 2008 22:13:03 -0400 Original-Received: from [209.191.108.96] by n16.bullet.mail.mud.yahoo.com with NNFMP; 19 Jul 2008 02:13:02 -0000 Original-Received: from [68.142.201.241] by t3.bullet.mud.yahoo.com with NNFMP; 19 Jul 2008 02:13:02 -0000 Original-Received: from [127.0.0.1] by omp402.mail.mud.yahoo.com with NNFMP; 19 Jul 2008 02:13:02 -0000 X-Yahoo-Newman-Id: 403765.18096.bm@omp402.mail.mud.yahoo.com Original-Received: (qmail 68454 invoked from network); 19 Jul 2008 02:13:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.es; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=dSVToZ1tlGqg/ysM70O7VXK/ihRQhrXY80OYO9JI3QAeE+zxij926GRuBkPJtkL4etyswr6vqfaqyw1ssf/9S1DBqH8eiKnSZmhbvzyUI3IVnJ688gr9d1ew1H9u2BelQ2RjyZsphJkJW0XxTZKwU2fsXSDVXlSUm9wK6N+FV2A= ; Original-Received: from unknown (HELO 084202170072.customer.alfanett.no) (juanma_bellon@84.202.170.72 with plain) by smtp113.plus.mail.mud.yahoo.com with SMTP; 19 Jul 2008 02:13:01 -0000 X-YMail-OSG: cXRvGjIVM1mofmT.rgt9Uc37BIxbj6TtTyT4Ut6DO6.ZCG9IDWHqaZ36Z55swcc2awCLRnoICQb2uVAU9SI8L9OrS9rvnP6B5HECrDanMb_swRNkKlM5_8vJU7tgn0oG4bM- X-Yahoo-Newman-Property: ymail-3 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) In-Reply-To: <18539174.post@talk.nabble.com> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) 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:55722 Archived-At: On Saturday 19 July 2008, Nonni wrote: >[...] > If I write the if-statement my way, the indentation of the braces are wrong, > emacs produces: > > if (version < FMOD_VERSION) > { > return 0; > } > > Is there any way to get emacs to auto-indent my code the way I want it to ? > > Thanks. Yes. It's all about the cc-mode style. You can find CC-Mode in Info and look for styles. This is how I configured it: ;; Style I want to use in C/C++ mode (c-add-style "mi-estilo" '("stroustrup" ; style to inherit from. There are many others (indent-tabs-mode . nil) ; use spaces rather than tabs (c-basic-offset . 4) ; indent by four spaces (tab-width . 4) ; if the file specifies tabs, make them 4 chars wide (c-tab-always-indent . 1) ; tabs when in literals & comments, indent otherwise (c-offsets-alist . ; custom indentation rules ((inline-open . 0) (brace-list-open . 0) (statement-case-open . +))))) (add-hook 'c++-mode-hook (lambda () (c-set-style "mi-estilo"))) I'm sure that 'c-offsets-alist' defines the indentation rules, but I don't remember if I really need that, after having inherited the style form "stroustrup" style. If you care, check the Info. Best regards, -- Juanma "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr