unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: exits funnel <exitsfunnel@yahoo.com>
Subject: Re: Indenting in C++
Date: Sun, 26 Oct 2003 11:19:04 -0800 (PST)	[thread overview]
Message-ID: <20031026191904.47589.qmail@web40503.mail.yahoo.com> (raw)
In-Reply-To: <vd4gnb.r5.ln@acm.acm>

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	other threads:[~2003-10-26 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2448.1067114756.21628.help-gnu-emacs@gnu.org>
2003-10-26  9:33 ` Indenting in C++ Alan Mackenzie
2003-10-26 19:19   ` exits funnel [this message]
2003-10-25 20:45 exits funnel

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=20031026191904.47589.qmail@web40503.mail.yahoo.com \
    --to=exitsfunnel@yahoo.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).