在Emacs中设置每个目录的c-basic-offset [英] Setting c-basic-offset per directory in Emacs

查看:261
本文介绍了在Emacs中设置每个目录的c-basic-offset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C项目使用2空格缩进(在 / projects / c )和一个具有4空格缩进的C ++项目(在 / projects / cpp )。我不知道如何使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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆