unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Giorgos Keramidas <keramida@ceid.upatras.gr>
Subject: Re: Force spaces instead of tabs
Date: Wed, 11 Oct 2006 02:46:01 +0300	[thread overview]
Message-ID: <868xjnu43q.fsf@gothmog.pc> (raw)
In-Reply-To: 1160463886.894724.96810@i42g2000cwa.googlegroups.com

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.
`----------------------------------------------------------------

      parent reply	other threads:[~2006-10-10 23:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-10  7:04 Force spaces instead of tabs Martin
2006-10-10  8:20 ` ext-chunye.wang
2006-10-10  8:32   ` Martin
2006-10-10 11:43 ` Hadron Quark
2006-10-10 14:30 ` martin
2006-10-10 23:46 ` Giorgos Keramidas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=868xjnu43q.fsf@gothmog.pc \
    --to=keramida@ceid.upatras.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).