[Top][All Lists]

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

Re: Stop autoindenting!

From: Alan Mackenzie
Subject: Re: Stop autoindenting!
Date: Thu, 27 May 2004 20:42:26 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

SomeDude <address@hidden> wrote on 26 May 2004 19:52:24 -0700:
> I've got a pretty unique coding style for C\C++ that I like. I think
> it makes my code easy to read and understand (especially once syntax
> highlighting is enabled). Unfortunatly, it doesn't conform to any of
> the predefined styles set by emacs. What I'd like to do is turn off
> all forms of autoindentation and get the tab key to work like it would
> in any normal word processor so that I can manually format my code.

The variable you need to set is c-syntactic-indentation.  Either do it
via customize, with M-x customize-group <ret> c <ret> then look for "C
Syntactic Indentation" or put this into your .emacs:

(setq c-syntactic-indentation nil)

> Things like braces seem to jump around to odd places whenever I type
> them in.

Once you've disabled the auto-indentation, and you feel you've got some
semblance of control back, I'd recomment you to start experimenting
gently with auto-indentation.  It's one of those things which is
maddening when you're fighting against it all the time, but once you've
got it working how you want, you wonder how you ever managed without it.

> Rebinding tab and entering text mode makes it work exactly
> like I want it to except text mode doesn't include syntax highlighting
> which I'd like to have. If it were possible to somehow program emacs to
> my own style that'd be cool too, but I don't know how to do that\if
> it'd be possible.

It is most definitely possible, just as you'd expect in the world's most
configurable program.  :-)  It's all described in the CC Mode manual
(look for "CC Mode" in the Info directory node) on the page "Customizing
Indentation" and its subpages.  It can seem a bit heavy going, though.

I'd recommend you try one of the built-in styles to start with.  From a
C++ buffer, do C-c . (that's "control-c dot"), then <tab> to get a list
of alternatives.  Try "bsd" style or maybe "ellemtel".  If you like one
of these styles, then put (e.g.) the following into your .emacs:

(setq c-default-style "bsd")

(or use the customization feature).

[ .... ]

Alan Mackenzie (Munich, Germany)
Email: address@hidden; 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]