在Emacs中设置每个目录的c-basic-offset [英] Setting c-basic-offset per directory in Emacs
问题描述
我可以告诉它使用 c-mode
(2个空格)。
有什么我可以把我的 .emacs 文件缩进.h文件不同的空格或更改模式,在目录下?
目录本地变量:
http://www.emacswiki.org/emacs/DirectoryVariables
你可以使用.dir-locals.el文件,或者您可以在.emacs文件中使用 dir-locals-set-class-variables
和 dir-locals-set-directory-class
函数。
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-variables
and dir-locals-set-directory-class
functions.
这篇关于在Emacs中设置每个目录的c-basic-offset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!