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:53:53 +0800 Message-ID: <5fe787a11001271953h9b99526h4e28fd37fb55414@mail.gmail.com> References: <18da3b5b-0da4-4d23-a13a-91591db7b2aa@a5g2000yqi.googlegroups.com> <5fe787a11001271944u14a971dfq7be47ea079dd50a2@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=00504502b443b76f15047e3177a0 X-Trace: ger.gmane.org 1264650901 13655 80.91.229.12 (28 Jan 2010 03:55:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Jan 2010 03:55:01 +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:54:58 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 1NaLT6-0003FU-AM for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jan 2010 04:54:56 +0100 Original-Received: from localhost ([127.0.0.1]:39462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaLT5-00028K-6n for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jan 2010 22:54:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NaLSC-00021Q-QE for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:54:00 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NaLS7-00021D-Qv for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:54:00 -0500 Original-Received: from [199.232.76.173] (port=59870 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaLS7-00021A-OM for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:53:55 -0500 Original-Received: from mail-pz0-f188.google.com ([209.85.222.188]:39873) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NaLS7-0005Ft-18 for help-gnu-emacs@gnu.org; Wed, 27 Jan 2010 22:53:55 -0500 Original-Received: by pzk26 with SMTP id 26so239703pzk.26 for ; Wed, 27 Jan 2010 19:53:54 -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=BMmZS5TFCi37rgq9mnb41k26rtJH6G4Uz5UB+niPiY4=; b=JY0joabPTO3ZGMJtZC8mpg0iZVp9NyNIMn79aAnIe9EftUI3SDk31IUC0eTo94RQkZ wID6ZIus0O6SHYyGtv7+C2yIK1IcMIx3VskRmWzs01oIb+OtBi47lY9LZVuiYLHB52Om SGMDe5HvIWb8NRh9fU9DxlClhY8ZCuelhh14k= 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=AL7282DXoZz0JU87MQ6iRL+EKwXg5UhCu4wQquk0Sg+1AS2HswNy0+gtaxho3De4fC /BbegT35hNaX671CmQEMF1TJ5QIUOsDJlrJxdFQcrbh1nzFr3rKClr3uodzgl6QUUlmN q9ITZSpPO7MNtqQ55yp0GzCPmov6zduH+d/O0= Original-Received: by 10.142.4.41 with SMTP id 41mr886434wfd.123.1264650833849; Wed, 27 Jan 2010 19:53:53 -0800 (PST) In-Reply-To: <5fe787a11001271944u14a971dfq7be47ea079dd50a2@mail.gmail.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:71529 Archived-At: --00504502b443b76f15047e3177a0 Content-Type: text/plain; charset=ISO-8859-1 2010/1/28 Nevo > 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. > Sorry, forget my last words . "c-offsets-alist" will be read to find a match for offset to add to the base indentation which is the last anchor position of the last syntactic element. > > ;; 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. >> > > --00504502b443b76f15047e3177a0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2010/1/28 Nevo <sakur.deagod@gmail.com>
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.

=A0Sorry,=A0 forget my last word= s . "c-offsets-alist" will be read to find a match for offset to = add to the base indentation which is the last anchor position of the last s= yntactic element.

;; your= coding style
(c-add-style "mycodingstyle"
=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.


--00504502b443b76f15047e3177a0--