help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indenting in C++


From: Alan Mackenzie
Subject: Re: Indenting in C++
Date: Sun, 26 Oct 2003 09:33:51 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

exits funnel <exitsfunnel@yahoo.com> wrote on Sat, 25 Oct 2003 13:45:18
-0700 (PDT):
> Hello,

> I've just started using emacs for C++ and I'm trying
> to customize it to indent as follows:

> class foo
> {
>   public:
>     void print1( );

>   private:
>     void print2( );
>     void print3( );
> };

> I've spent most of the morning searching the web to no avail.  It's not
> that I can't find any information; rather that I've found too much.

I know that feeling _very_ well.  You can spend days searching through
reams of bumf, just to find those elusive few paragraphs which explain
everything.

> At this point I'm quite confused for example about the difference
> between a 'mode' and a 'style.'

A 'major mode' is something like C++ mode, or Text mode.  A 'minor mode'
is an add-on feature, like Font Lock mode (the thing that does "syntax
highlighting").  Normally when people just say "mode" they mean the major
mode.

As you've probably gathered, C++ mode is one of a family of modes
collectively known as "CC Mode", the others being Java, C, Pike, ....

The term 'style' is peculiar to CC mode, and it refers mainly to the way
indentation gets done.  For example, "GNU" style (the default factory
setting) looks like this:

    if (a++ >= 5)
      {
        insert_blank_line () ;
        a = 0 ;
      }

, whereas "Whitesmith" style would be

    if (a++ >= 5)
        {
        insert_blank_line () ;
        a = 0 ;
        }

You might really be wanting "Stroustrup" style.

> If anyone could point me towards a source of information geared
> specifically towards modifying c++ formatting, I"d be very grateful.

The CC Mode manual is exactly what you need.  It ought to be installed on
your system already.  Type "C-h i" (to get to Info), followed by "d" (to
make sure you're already at the directory page), followed by "m cc mode
<CR>" (which should get you to the manual).

The top level menu there has an item "Customizing Indentation", which is
what you're looking for.  There is a page "Styles" which tells you how to
set a style.  It's not light bedtime reading by any means, but the
information is all there.  (If it's not, or you can't figure something
out, please come back and tell us what's unclear, so that we can fix
it!).  

All the best!

> -exits

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

[Prev in Thread] Current Thread [Next in Thread]