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

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

Stop autoindenting!


From: SomeDude
Subject: Stop autoindenting!
Date: 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.
Things like braces seem to jump around to odd places whenever I type
them in. 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.

As an example of my style would be something like this:

This would be in a .h file:

class LIB_SomeClass : public LIB_BaseClass
{
    public:
    //const
        const int LIB_SomeClass__SOME_CONSTANT = 0xFF;
    //type
        enum LIB_SomeClass__Colors
        {
            COLOR_RED = 0,
            COLOR_GREEN,
            COLOR_BLUE
        };

        struct LIB_SomeClass__ImaginaryNum
        {
            int a, b;
        };

    //- [Constructor] -
    LIB_SomeClass();

    //- [Methods] -
    bool ExampleMethod();
    int  AnotherMethod(int i, double d, string str);

    private:
    //Vars
        int _i, _j, _k;
        string _exampleMember;
}

This would be in a .cpp:
/* Program: <ProgName>
   Author:  <Name>
   Descr:   <Description of this class>
   Other:   <Other header info>
*/

//---------------------------------------------- [Constructor] -
LIB_SomeClass::LIB_SomeClass
{
    //Vars
        int functionVariable;
        string anotherVariable;

    //Loop through a for loop, just as an example
        for(int i = 0; i < 300; i++)
        {
            SomeFunction();
            ReallyLongFunctionWithManyParameters(_i, _j, _k,
                _examplemember, functionVariable, anotherVariable);
            );
        }
}
//--------------------------------------------------- [Methods] -
bool LIB_SomeClass::ExampleMethod()
{
    //Do something to make this method look legit
        CallAnotherFunction();
}
//... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
int LIB_SomeClass::AnotherMethod(int i, double d, string str)
{
    //Const
        const int A_CONSTANT = 500;

    //Another random loop:
      while(_j != A_CONSTANT)
      {
          ExampleMethod();
          i++;
      }
}


reply via email to

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