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

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

Re: How to auto set the c style while editing C file?


From: Water Lin
Subject: Re: How to auto set the c style while editing C file?
Date: Wed, 08 Dec 2010 15:10:10 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Lowell Gilbert <lgusenet@be-well.ilk.org> writes:

> Water Lin <WaterLin@ymail.invalid> writes:
>
>> I am using Emacs to edit for C/C++ code in some cases.
>>
>> But the default gnu style is not fit my requirement.
>>
>> 1. 
>>
>> I want to use stroustrup style as default.
>>
>> I tried to use following code in my .emacs:
>> -----------
>> (c-set-style "stroustrup")
>>
>> But Emacs will remind me that some files are not in C-mode.
>>
>> How can I enable stroustrup style automatically while I am using
>> c-mode/c++-mode. 
>
> (add-hook 'c-mode-common-hook
>             (function (lambda ()
>                             (c-set-style "gnu")))) ; gnu is default
>
>
>> 2. 
>>
>> Another question, after I input one line code and use C-i to indent the
>> code, Emacs will insert a TAB for me which is TAB-width 8.
>>
>> I want to set TAB-width as 4 and in this case I don't want Emacs to
>> inset TAB automatically but insert 4 blackspaces instead.
>
> Also in c-mode-common-hook:
>  (setq indent-tabs-mode nil)
> and probably
>  (setq c-basic-offset 4) 
>
> See the c-mode manual for more details on how this works and what else
> you can set.

Ok. Thanks, I am studying elisp right now.

I will check the manual for detail.

Thanks

Water Lin

-- 
Water Lin's notes and pencils: http://en.waterlin.org
Email: WaterLin@ymail.com


reply via email to

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