[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Force spaces instead of tabs
From: |
Hadron Quark |
Subject: |
Re: Force spaces instead of tabs |
Date: |
Tue, 10 Oct 2006 13:43:18 +0200 |
"Martin" <loveslave@frustratedhousewives.zzn.com> writes:
> 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
>
> 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?
>
> void B::e()
> {
> if ()
> {
> ;
> if ()
> {
> ; // tab character at beginning of this line!
> }
> ;
> }
> }
>
My C programming .el file has the following section - the 6th line is
probably what you are looking for - (setq indent-tabs-mode nil).
,----
| (defun my-c-mode-common-hook ()
| (c-set-style "K&R") ; offset customizations not in my-c-style
| (setq tab-width 3) ;; change this to taste, this is what K&R uses :)
| (my-build-tab-stop-list tab-width)
| (setq c-basic-offset tab-width)
| (setq indent-tabs-mode nil)
|
| (defun find-tag-noconfirm ()
| (interactive)
| (find-tag (find-tag-default)))
|
| (defun find-tag-repeat ()
| (interactive)
| (find-tag nil t nil))
|
| (defun jump-man-page ()
| (interactive)
| (manual-entry (current-word)))
|
| (setq Man-notify-method 'newframe)
|
| (let ((dl '(
| ([f1] . jump-man-page)
| ([f5] . find-tag-noconfirm)
| ([f6] . find-tag-repeat)
| ([f7] . pop-tag-mark)
| ([f2] . gdb-restore-windows)
| ([f10] . compile)
| ([f11] . next-error)
| ([f12] . gdba))))
| (dolist (i dl)
| (define-key c-mode-map (car i) (cdr i))))
| )
|
| (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
`----
The last line is probably of interest to you.
--