[Top][All Lists]

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

Re: automatic indentation in C,C++ modes

From: Tony Harbin
Subject: Re: automatic indentation in C,C++ modes
Date: Mon, 15 Apr 2002 11:51:58 -0500

Not quite.  C/C++ mode binds open-paren, open-brace, colon, and slash (among

others) to "electric" functions that, when the key is typed, automatically
the spacing and/or indentation on the line.  I would like to
disable/override/turn off this behavior.  I was able to do this in an older
version where I had to explicitly load the C/C++ mode modules, but in my
current version (20.7.1), the stuff was already compiled in and the same
tricks no longer work.

Basically, I would just like those keys above to just self-insert and not
run the
"electric" functions.  Is there a way to do this?


Greg Hill wrote:

> At 5:56 PM -0500 4/12/02, Tony Harbin wrote:
> >How do I turn off all automatic indentation in C and C++ modes?  I find
> >this
> >behavior *VERY* annoying and would like to disable it permanently (i.e.
> >in the
> >.emacs file)
> >
> >Thanks for your time.
> Tony,
> If all you want is to insert a tab character at the beginning of a
> line when you type the tab key, try adding this to your .emacs file:
> (add-hook 'c-mode-hook
>         (function (lambda ()
>                 (substitute-key-definition
>                 'c-indent-command 'self-insert-command c-mode-map))))
> (add-hook 'c++-mode-hook
>         (function (lambda ()
>                 (substitute-key-definition
>                 'c-indent-command 'self-insert-command c++-mode-map))))
> If, while you are at it, you also want to define the size of a tab
> as, say, 3 spaces, make it:
> (add-hook 'c-mode-hook
>         (function (lambda ()
>                 (substitute-key-definition
>                 'c-indent-command 'self-insert-command c-mode-map)
>                 (setq tab-width 3))))
> --Greg

reply via email to

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