* Re: How to auto set the c style while editing C file?
[not found] <877hmryrsh.fsf@ymail.invalid>
@ 2010-05-26 15:26 ` Lowell Gilbert
2010-05-27 1:40 ` Water Lin
0 siblings, 1 reply; 2+ messages in thread
From: Lowell Gilbert @ 2010-05-26 15:26 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to auto set the c style while editing C file?
2010-05-26 15:26 ` How to auto set the c style while editing C file? Lowell Gilbert
@ 2010-05-27 1:40 ` Water Lin
0 siblings, 0 replies; 2+ messages in thread
From: Water Lin @ 2010-05-27 1:40 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-27 1:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <877hmryrsh.fsf@ymail.invalid>
2010-05-26 15:26 ` How to auto set the c style while editing C file? Lowell Gilbert
2010-05-27 1:40 ` Water Lin
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.