Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

indentation for C++-namespaces

298 views
Skip to first unread message

Tony Sideris

unread,
Mar 31, 2000, 3:00:00 AM3/31/00
to
"Felix Natter" <f.na...@ndh.net> wrote in message
news:m3ln2yk...@mybaby.home.felix...
> hi,
> I have recently converted a program to namespace std, now the problem is
> that the enclosing namespace std { ... } causes the whole source-file to
be
> indented further.
>
> When I am in console-mode, this may not be what I want, especially
> when more than one namespace is active.
>
> Is there a way to turn this off ?
>
> The current emacs-20.5-documentation is a bit short on languages other
> than C. How about collecting some hints on C++-indentation (or maybe
> perl etc) ? - I'm not saying I volunteer, but I will help.
>

Try adding the following to your c-mode-common-hook (or whatever hook you
are using for C++ mode):

(c-set-offset 'innamespace 0)

-Tony


Felix Natter

unread,
Apr 1, 2000, 3:00:00 AM4/1/00
to
hi,
I have recently converted a program to namespace std, now the problem is
that the enclosing namespace std { ... } causes the whole source-file to be
indented further.

When I am in console-mode, this may not be what I want, especially
when more than one namespace is active.

Is there a way to turn this off ?

The current emacs-20.5-documentation is a bit short on languages other
than C. How about collecting some hints on C++-indentation (or maybe
perl etc) ? - I'm not saying I volunteer, but I will help.

thanks,

--
Felix Natter

Kai Großjohann

unread,
Apr 1, 2000, 3:00:00 AM4/1/00
to
Felix Natter <f.na...@ndh.net> writes:

> The current emacs-20.5-documentation is a bit short on languages other
> than C. How about collecting some hints on C++-indentation (or maybe
> perl etc) ? - I'm not saying I volunteer, but I will help.

Well, C, C++ and Objective C are all handled by CC mode. The generic
way to customize indentation in these modes is to type C-c C-o on the
first line which has wrong indentation, then to follow the prompts.
You can later recall the c-set-offset statements you need with C-x ESC
ESC and M-p/M-n.

Indentation in Perl is different, but I don't know how. And then
there's CPerl mode which has yet another way to customize
indentation. But I'd guess that M-x apropos-variable RET
perl.*\(indent\|offset\) RET would give you a start.

kai
--
~/.signature: No such file or directory

ni...@dgsdfgdfs.org

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to
HEAVENLY SENT ADVICE....Thank-you very very mucho...danke danek
schon???:-))

Nina

On 01 Apr 2000 21:44:55 +0200, Kai.Gro...@CS.Uni-Dortmund.DE

ni...@dgsdf.org

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to

I am new to this Emacs stuff, so could you please tell me how I can
put the recalled LISP statements into my .emacs file? I copied all
into my .emacs file, but they do not seem to have any effect.

I basically needs the configuration statements for my java-mode. I am
using Emacs 20.4.1 on Redhat Linux 6.1. Basically, I have a bunch of
(c-set-offset (....)) statements I don't know what to do with...

Thanks.

Kalle Olavi Niemitalo

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to
Also if there is a compiled version of .emacs (.emacs.elc), Emacs
loads that instead. You can remove it or recompile .emacs.

ni...@gsdgdf.org

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to
On 02 Apr 2000 17:50:16 +0300, Kalle Olavi Niemitalo
<to...@stekt.oulu.fi> wrote:

>Also if there is a compiled version of .emacs (.emacs.elc), Emacs
>loads that instead. You can remove it or recompile .emacs.

My .emacs file located in my home directory:

(require 'cc-mode)
(custom-set-variables '(c-basic-offset 2))
(c-set-offset (quote topmost-intro) 0 nil)
(c-set-offset (quote defun-block-intro) 2 nil)
(c-set-offset (quote substatement-open) 0 nil)
(c-set-offset (quote statement-block-intro) 2 nil)
(c-set-offset (quote case-label) 2 nil)
(c-set-offset (quote statement-case-intro) 2 nil)

The settings do not take effect when I start up Emacs, and I need to
do a M-x eval-buffer. Is there a way to make the settings take effect
automatically as soon as Emacs is started and I start to edit a JAVA
file? I need that for my Java mode. Thanks.

Nina


Tony Sideris

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to
<ni...@gsdgdf.org> wrote in message
news:38e7a5ad...@news-server.san.rr.com...

;; c-mode-common-hook is called for all cc-modes
(add-hook 'c-mode-common-hook
'(lambda ()
(setq c-basic-offset 2)
(c-set-offset 'topmost-intro 0)
(c-set-offset 'defun-block-intro 2)
(c-set-offset 'substatement-open 0)
(c-set-offset 'statement-block-intro 2)
(c-set-offset 'case-label 2)
(c-set-offset 'statement-case-intro 2)))

If you want all the items that end in 2 to be indented one more level then
you probably want '+ not 2.

-Tony


Tony Sideris

unread,
Apr 2, 2000, 4:00:00 AM4/2/00
to
"Tony Sideris" <tony...@erols.com> wrote in message
news:8c8ag1$1gd$1...@bob.news.rcn.net...

To clarify, I should have said all lines that end in 2 EXCEPT for the
c-basic-offset line, should be '+ not 2.

-Tony


ni...@gsdf.org

unread,
Apr 3, 2000, 3:00:00 AM4/3/00
to

Works great. Thanks everyone for helping out.

Nina

On Sun, 2 Apr 2000 16:31:17 -0700, "Tony Sideris" <tony...@erols.com>
wrote:

Kai Großjohann

unread,
Apr 3, 2000, 3:00:00 AM4/3/00
to
ni...@dgsdf.org writes:

> I am new to this Emacs stuff, so could you please tell me how I can
> put the recalled LISP statements into my .emacs file? I copied all
> into my .emacs file, but they do not seem to have any effect.

(defun my-c-indent-setup ()
...c-set-offset.statements.go.here...)
(add-hook 'c-mode-hook 'my-c-indent-setup)

0 new messages