* Indenting in C++
@ 2003-10-25 20:45 exits funnel
0 siblings, 0 replies; 3+ messages in thread
From: exits funnel @ 2003-10-25 20:45 UTC (permalink / raw)
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( );
};
void foo::print1( )
{
cout << "In print1" << endl;
}
void foo::print2( )
{
cout << "In print2" << endl;
}
void foo::print3( )
{
cout << "In print3" << endl;
}
int main( )
{
foo f;
f.print1( );
}
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. At this point I'm
quite confused for example about the difference
between a 'mode' and a 'style.' If anyone could point
me towards a source of information geared specifically
towards modifying c++ formatting, I"d be very
grateful.
-exits
__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Indenting in C++
[not found] <mailman.2448.1067114756.21628.help-gnu-emacs@gnu.org>
@ 2003-10-26 9:33 ` Alan Mackenzie
2003-10-26 19:19 ` exits funnel
0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2003-10-26 9:33 UTC (permalink / raw)
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").
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Indenting in C++
2003-10-26 9:33 ` Alan Mackenzie
@ 2003-10-26 19:19 ` exits funnel
0 siblings, 0 replies; 3+ messages in thread
From: exits funnel @ 2003-10-26 19:19 UTC (permalink / raw)
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-26 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-25 20:45 Indenting in C++ exits funnel
[not found] <mailman.2448.1067114756.21628.help-gnu-emacs@gnu.org>
2003-10-26 9:33 ` Alan Mackenzie
2003-10-26 19:19 ` exits funnel
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).