all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nevo <sakur.deagod@gmail.com>
To: chun <riverofdreams@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: how to disable C++ namespace indentation
Date: Thu, 28 Jan 2010 11:44:08 +0800	[thread overview]
Message-ID: <5fe787a11001271944u14a971dfq7be47ea079dd50a2@mail.gmail.com> (raw)
In-Reply-To: <18da3b5b-0da4-4d23-a13a-91591db7b2aa@a5g2000yqi.googlegroups.com>

[-- Attachment #1: Type: text/plain, Size: 1450 bytes --]

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 <riverofdreams@gmail.com>

> 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.
>

[-- Attachment #2: Type: text/html, Size: 1892 bytes --]

  reply	other threads:[~2010-01-28  3:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 20:53 how to disable C++ namespace indentation chun
2010-01-28  3:44 ` Nevo [this message]
2010-01-28  3:53   ` Nevo
     [not found]   ` <mailman.340.1264650842.14305.help-gnu-emacs@gnu.org>
2010-01-28  4:16     ` chun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fe787a11001271944u14a971dfq7be47ea079dd50a2@mail.gmail.com \
    --to=sakur.deagod@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=riverofdreams@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.