From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nevo Newsgroups: gmane.emacs.help Subject: Re: how to disable C++ namespace indentation Date: Thu, 28 Jan 2010 11:44:08 +0800 Message-ID: <5fe787a11001271944u14a971dfq7be47ea079dd50a2@mail.gmail.com> References: <18da3b5b-0da4-4d23-a13a-91591db7b2aa@a5g2000yqi.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd2e0a2da332c047e315495 X-Trace: ger.gmane.org 1264650286 12376 80.91.229.12 (28 Jan 2010 03:44:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Jan 2010 03:44:46 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: chun Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 28 04:44:43 2010 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.69) (envelope-from ) id 1NaLJB-0007cD-VM for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jan 2010 04:44:42 +0100 Original-Received: from localhost ([127.0.0.1]:37358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaLJB-0007Tt-Er for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jan 2010 22:44:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NaLIm-0007SY-3T for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:44:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NaLIh-0007Qg-KY for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:44:15 -0500 Original-Received: from [199.232.76.173] (port=45605 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaLIh-0007Qb-Co for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:44:11 -0500 Original-Received: from mail-px0-f192.google.com ([209.85.216.192]:52879) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NaLIg-0003zQ-Qc for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:44:11 -0500 Original-Received: by pxi30 with SMTP id 30so194493pxi.14 for ; Wed, 27 Jan 2010 19:44:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=rbmV31t/BX3HT+/tiUaAel988pWL0BNqCxiHy/Wd8BQ=; b=pH+i2LzOG9rmVYcliZD6D98kGYozZ6VmivIJeHh4u7RhFV6pl4jmF/5pF2DKOqc5nr AYnF0+2YoWtml4nMsDoUyfICVeUFxvdSjFTLB+7+p3RwHAimDTZRT0gTMqvemwazDu/N TTTUC8ZgQwSlvABoTEoFHn14zBkBReEAbM8aM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=TK90+5/VBYDtpp8q3Akf1p6IeFXORwIXN6SAx9OQWG0XkW6Or4eqbLNbTBacid0pKg NPLG81EB9urhWTeHFUWVsXodTR0tjiY+gs3leJHMYccGL5NE4WhHL9kC6m5NsNIDaFkv JWmTaqmmWPV7jTqfOckmu+aRGZMZXKunOOzE8= Original-Received: by 10.142.152.15 with SMTP id z15mr855871wfd.98.1264650248925; Wed, 27 Jan 2010 19:44:08 -0800 (PST) In-Reply-To: <18da3b5b-0da4-4d23-a13a-91591db7b2aa@a5g2000yqi.googlegroups.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 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:71528 Archived-At: --000e0cd2e0a2da332c047e315495 Content-Type: text/plain; charset=ISO-8859-1 I think the below is probably what you need. "c-offsets-alist" will be read to add to the base indentation which is default to zero if I remembered right. ;; your coding style (c-add-style "mycodingstyle" '((c-basic-offset . 3) (c-comment-only-line-offset . 0) (c-hanging-braces-alist . ((substatement-open before after))) (c-offsets-alist . ((topmost-intro . 0) (topmost-intro-cont . 0) (substatement . 3) (substatement-open . 0) (statement-case-open . 3) (statement-cont . 3) (access-label . -3) (inclass . 3) (inline-open . 3) (innamespace . 0) )))) ;; treat all tabs to spaces (defun my-c-mode-hook () (setq c-basic-offset 4) (setq indent-tabs-mode nil) (setq show-trailing-whitespace t)) ;; c++ uses mycodingstyle (defun my-c++-mode-hook () (c-set-style "mycodingstyle")) Nevo 2010/1/28 chun > In C++, I want to keep other indentations intact except for namespace > brackets, e.g. > namespace a { > struct A { > int b; > }; > > void c { > int d; > } > } > > The above is what I want. I tried (c-set-offset 'innamespace 0). > However it disables automatic indentation at every line when I hit > return. > --000e0cd2e0a2da332c047e315495 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think the below is probably what you need. "c-offsets-alist" wi= ll be read to add to the base indentation which is default to zero if=A0 I = remembered right.

;; your coding style
(c-add-style "mycodin= gstyle"
=A0=A0=A0 =A0=A0=A0=A0 '((c-basic-offset . 3)
=A0=A0=A0 =A0=A0=A0=A0= =A0=A0 (c-comment-only-line-offset . 0)
=A0=A0=A0 =A0=A0=A0=A0=A0=A0 (c-= hanging-braces-alist . ((substatement-open before after)))
=A0=A0=A0 =A0= =A0=A0=A0=A0=A0 (c-offsets-alist . ((topmost-intro=A0=A0=A0=A0=A0=A0=A0 . 0= )
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (topmost-intro-cont=A0=A0 . = 0)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (substatement=A0=A0=A0= =A0=A0=A0=A0=A0 . 3)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (sub= statement-open=A0=A0=A0 . 0)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0= =A0 (statement-case-open=A0 . 3)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0= =A0=A0 (statement-cont=A0=A0=A0=A0=A0=A0 . 3)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (access-label=A0=A0=A0=A0=A0= =A0=A0=A0 . -3)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (inclass= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 . 3)
=A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 =A0=A0 (inline-open=A0=A0=A0=A0=A0=A0=A0=A0=A0 . 3)
=A0=A0= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 (innamespace=A0=A0=A0=A0=A0=A0=A0= =A0=A0 . 0)
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0 ))))

;; treat all tabs to spaces
(defun my-c-mode-hook ()
=A0 (setq c-= basic-offset 4)
=A0 (setq indent-tabs-mode nil)
=A0 (setq show-traili= ng-whitespace t))
;; c++ uses mycodingstyle
(defun my-c++-mode-hook (= )
=A0 (c-set-style "mycodingstyle"))

Nevo

2010/1/28 chun <riverofdreams@gmail.com>
In C++, I want to keep other indentations intact except for namespace
brackets, e.g.
namespace a {
struct A {
=A0int b;
};

void c {
=A0int d;
}
}

The above is what I want. =A0I tried (c-set-offset 'innamespace 0).
However it disables automatic indentation at every line when I hit
return.

--000e0cd2e0a2da332c047e315495--