all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* having problems with indentation in c++-mode
@ 2009-02-07 20:07 luca.pamparana
  2009-02-08  9:07 ` Alan Mackenzie
  0 siblings, 1 reply; 4+ messages in thread
From: luca.pamparana @ 2009-02-07 20:07 UTC (permalink / raw
  To: help-gnu-emacs

Hello everyone,

I would like to set the indentation level to 4 characters and I am
having trouble achieving this in the c++-mode. I have looked on the
web and used the most common template that is found but the smart
indentation always indents at 2 spaces...no matter what I set the tab-
width or the indent level.

The relevant bits of my .emacs file are:

(defun my-c++-mode-hook ()
;;  (setq-default indent-tabs-mode nil)
  (setq tab-width 4)
  (define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent)
  (define-key c++-mode-map "\C-ce" 'c-comment-edit)
  (setq c++-auto-hungry-initial-state 'none)
  (setq c++-delete-function 'backward-delete-char)
  (setq c++-tab-always-indent t)
  (setq tab-stop-list '(4 8 12 16))

  (setq c-indent-level 4)
  (setq c-continued-statement-offset 4)
  (setq c++-empty-arglist-indent 4))


;; Add all of the hooks...
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(add-hook 'c++-mode-hook 'turn-on-auto-fill)
(setq default-major-mode 'c++-mode)

I can set the tab-width or the indent-level to whatever number but it
does not help. It always indents at 2 spaces.

I am an emacs newbie, so I am sure I have missed something basic. I
would be grateful for any help you might give me.

Cheers,
Luca


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: having problems with indentation in c++-mode
  2009-02-07 20:07 having problems with indentation in c++-mode luca.pamparana
@ 2009-02-08  9:07 ` Alan Mackenzie
  2009-02-08 11:06   ` luca.pamparana
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2009-02-08  9:07 UTC (permalink / raw
  To: help-gnu-emacs

luca.pamparana@gmail.com wrote:
> Hello everyone,

> I would like to set the indentation level to 4 characters and I am
> having trouble achieving this in the c++-mode. I have looked on the
> web and used the most common template that is found but the smart
> indentation always indents at 2 spaces...no matter what I set the tab-
> width or the indent level.

[ .... ]
 
> I can set the tab-width or the indent-level to whatever number but it
> does not help. It always indents at 2 spaces.
> 
> I am an emacs newbie, so I am sure I have missed something basic. I
> would be grateful for any help you might give me.

The magic document is the CC Mode manual, chapter "Getting Started".

The variable you need to set is `c-basic-offset'.  Here's what this fine
manual says:

c-basic-offset
     This Lisp variable holds an integer, the number of columns CC Mode
     indents nested code.  To set this value to 6, customize
     `c-basic-offset' or put this into your `.emacs':

          (setq c-basic-offset 6)

If you can't get this working, come back again.

Best of luck!

> Cheers,
> Luca

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: having problems with indentation in c++-mode
  2009-02-08  9:07 ` Alan Mackenzie
@ 2009-02-08 11:06   ` luca.pamparana
  2009-02-08 14:18     ` Richard Riley
  0 siblings, 1 reply; 4+ messages in thread
From: luca.pamparana @ 2009-02-08 11:06 UTC (permalink / raw
  To: help-gnu-emacs

On Feb 8, 10:07 am, Alan Mackenzie <a...@muc.de> wrote:
> luca.pampar...@gmail.com wrote:
> > Hello everyone,
> > I would like to set the indentation level to 4 characters and I am
> > having trouble achieving this in the c++-mode. I have looked on the
> > web and used the most common template that is found but the smart
> > indentation always indents at 2 spaces...no matter what I set the tab-
> > width or the indent level.
>
> [ .... ]
>
> > I can set the tab-width or the indent-level to whatever number but it
> > does not help. It always indents at 2 spaces.
>
> > I am an emacs newbie, so I am sure I have missed something basic. I
> > would be grateful for any help you might give me.
>
> The magic document is the CC Mode manual, chapter "Getting Started".
>
> The variable you need to set is `c-basic-offset'.  Here's what this fine
> manual says:
>
> c-basic-offset
>      This Lisp variable holds an integer, the number of columns CC Mode
>      indents nested code.  To set this value to 6, customize
>      `c-basic-offset' or put this into your `.emacs':
>
>           (setq c-basic-offset 6)
>
> If you can't get this working, come back again.
>
> Best of luck!
>
> > Cheers,
> > Luca
>
> --
> Alan Mackenzie (Nuremberg, Germany).

That works. You are awesome!

Thanks,
Luca


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: having problems with indentation in c++-mode
  2009-02-08 11:06   ` luca.pamparana
@ 2009-02-08 14:18     ` Richard Riley
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Riley @ 2009-02-08 14:18 UTC (permalink / raw
  To: help-gnu-emacs

luca.pamparana@gmail.com writes:

> On Feb 8, 10:07 am, Alan Mackenzie <a...@muc.de> wrote:
>> luca.pampar...@gmail.com wrote:
>> > Hello everyone,
>> > I would like to set the indentation level to 4 characters and I am
>> > having trouble achieving this in the c++-mode. I have looked on the
>> > web and used the most common template that is found but the smart
>> > indentation always indents at 2 spaces...no matter what I set the tab-
>> > width or the indent level.
>>
>> [ .... ]
>>
>> > I can set the tab-width or the indent-level to whatever number but it
>> > does not help. It always indents at 2 spaces.
>>
>> > I am an emacs newbie, so I am sure I have missed something basic. I
>> > would be grateful for any help you might give me.
>>
>> The magic document is the CC Mode manual, chapter "Getting Started".
>>
>> The variable you need to set is `c-basic-offset'.  Here's what this fine
>> manual says:
>>
>> c-basic-offset
>>      This Lisp variable holds an integer, the number of columns CC Mode
>>      indents nested code.  To set this value to 6, customize
>>      `c-basic-offset' or put this into your `.emacs':
>>
>>           (setq c-basic-offset 6)
>>
>> If you can't get this working, come back again.
>>
>> Best of luck!
>>
>> > Cheers,
>> > Luca
>>
>> --
>> Alan Mackenzie (Nuremberg, Germany).
>
> That works. You are awesome!
>
> Thanks,
> Luca

Also look up c-set-style

e.g

(c-set-style "linux")


-- 
 important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday.  ~Dennis Gabor, Innovations:  Scientific, Technological and Social, 1970


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-08 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-07 20:07 having problems with indentation in c++-mode luca.pamparana
2009-02-08  9:07 ` Alan Mackenzie
2009-02-08 11:06   ` luca.pamparana
2009-02-08 14:18     ` Richard Riley

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.