From: Water Lin <WaterLin@ymail.invalid>
To: help-gnu-emacs@gnu.org
Subject: Re: How to auto set the c style while editing C file?
Date: Thu, 27 May 2010 09:40:28 +0800 [thread overview]
Message-ID: <87zkzm3ywj.fsf@ymail.invalid> (raw)
In-Reply-To: 44r5ky8z0x.fsf@be-well.ilk.org
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
prev parent reply other threads:[~2010-05-27 1:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zkzm3ywj.fsf@ymail.invalid \
--to=waterlin@ymail.invalid \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.