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

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

Re: Force spaces instead of tabs


From: Giorgos Keramidas
Subject: Re: Force spaces instead of tabs
Date: Wed, 11 Oct 2006 02:46:01 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix)

On 10 Oct 2006 00:04:46 -0700, "Martin" 
<loveslave@frustratedhousewives.zzn.com> wrote:
> I need to have emacs indent C++ code using only spaces, and no tab
> characters.
>
> I edited the options in the Programming/Languages/C group so that:
> C Basic Offset is 3
> C Tab Always Indent is "always indents"
> C Insert Tab Function is "insert-tab"
> C Syntactic Indentation is non-nil
> C Offsets Alist: substatement-open is 0

I used the following set of local variables in files recently edited in
one of the repositories I work with:

    // Local variables:
    // mode: c++
    // c-basic-offset: 4
    // c-tab-always-indent: t
    // indent-tabs-mode: nil
    // End:

The only one that you seem to have missed is `indent-tabs-mode'.

> In many cases, the indentation is correct, but when I have several
> levels of sub-statements, tab characters are inserted anyway. See the
> example below. What other options control this behaviour?

The `indent-tabs-mode' variable controls whether Emacs will use TAB
characters when indenting text or program sources.  Setting it to nil
tells Emacs to only indent using SPC characters, as described in the
documentation of this variable.  Try: `C-h v indent-tabs-mode RET'.
You should see something like this:

,----------------------------------------------------------------
| indent-tabs-mode is a variable defined in `C source code'.
| Its value is nil
| Local in buffer *followup to Martin on gnu.emacs.help*; global value is t
| Automatically becomes buffer-local when set in any fashion.
| 
| This variable is safe as a file local variable if its value
| satisfies the predicate `booleanp'.
| 
| Documentation:
| *Indentation can insert tabs if this is non-nil.
| Setting this variable automatically makes it local to the current buffer.
| 
| You can customize this variable.
`----------------------------------------------------------------



reply via email to

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