I have a C project that uses 2-space indents (in /projects/c) and a C++ project with 4-space indents (in /projects/cpp). I can’t figure out how to make Emacs automatically do the right spacing depending on where the file I open lives.
I can tell it to use c++-mode (4 spaces) for the .cpp files, but the .h files (in the cpp project) still default to c-mode (2 spaces).
Is there something I can put in my .emacs file to either indent .h files a different number of spaces or change the mode, depending on the directory?
Directory Local Variables:
http://www.emacswiki.org/emacs/DirectoryVariables
You can either use .dir-locals.el files, or alternatively you can configure it entirely in your .emacs file with the
dir-locals-set-class-variablesanddir-locals-set-directory-classfunctions.