I usually use 4 white spaces to indent C programs, but in order to keep in consistent with some open source projects, I have to change to 2-white-space indenting sometimes.
Currently my indenting style is assigned in my .emacs file with
(setq c-basic-offset 4)
And when I want to work on those 2-white-space indenting projects. I have to close my Emacs, modify the value, and start again. Is there any simpler way to do this?
Many thanks.
PS.
Setting c-basic-offset variable every time I open a source file is too much work, is it possible to choose different value depending on working directory?
Create a file in the directory you want to customize named
.dir-locals.el, and edit it to contain:Note: This is new functionality in Emacs 23.1.
This takes advantage of the Per-Directory Local Variables. From the documentation in the link: