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

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

Re: Indenting in C++


From: exits funnel
Subject: Re: Indenting in C++
Date: Sun, 26 Oct 2003 11:19:04 -0800 (PST)

Thanks Alan!  The documentation you pointed me towards
was exactly what I was looking for.  I was thrown off
by the fact that it wasn't contained within the emacs
docs but at a 'higher' info level.  In any case, I've
almost got my indentation working how I want it to,
but I've run into one small snag.  I'd like the
following:

(1)class foo
(2){
(3)  public:
(4)    void print1( );
(5)}

(6)void foo::print1( )
(7){
(8)
(9)}

The changes I've made to my .emacs file include the
following lines:

(setq c-basic-offset 2)
(c-set-offset 'inclass '+)
(c-set-offset 'access-label 0)
(c-set-offset 'topmost-intro '+)

Life is good now in the example above except for line
(6) which emacs is indenting 2 spaces when I'd like it
not to be indented at all.  This is happening, of
course, because it identifies both lines syntactically
as 'topmost-intro'.  Does anyone have any suggestions
then about how I can get emacs to distinguish between
lines (4) and (6) so I can get it to indent them
differently?  Thank in advance.

-exits

--- Alan Mackenzie <none@example.invalid> wrote:
> 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").
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/




reply via email to

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