logo       

Re: C formatting: msg#00879

emacs.help

Subject: Re: C formatting

Oodini <svdbg@xxxxxxx> writes:

> I ma desesperatly playing in my .emacs with the following statements,
> but no luck:

I suggest to try C-c C-o on the first line that has wrong indentation
and to follow the prompts. Then hit TAB to reindent the line. When
you like the indentation, you can use C-x ESC ESC and then M-p/M-n to
retrieve the right c-set-offset statement. That's what you can put
in the hook, below:

> (setq c-mode-hook
> (function
> (lambda ()
> (setq c-basic-offset 0)
> (setq c-indent-level 5)
> (setq c-continued-statement-offset 5)
> (setq c-argdecl-indent 0)
> (setq c-brace-offset -5)
> (setq c-label-offset -5)
> )
> )
> )

This is not a good idea to do, either, as you are overriding old
values for the hook. Never use setq on a hook. Always use add-hook
instead. Here's my suggestion, fill in the missing c-set-offset
statements here:

(defun oodini-c-indent-setup ()
(setq c-basic-offset 5)
(c-set-offset ...))
(add-hook 'c-mode-hook 'oodini-c-indent-setup)

You didn't say which version of Emacs you are using. I'm assuming
Emacs 21. Probably the above works for Emacs 20, too.
--
Ambibibentists unite!


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise