如何在 Emacs 的注释中设置代码缩进?

How to set code indentation in comment in Emacs?

我在做不同的项目,不同项目的人有不同的缩进偏好。我想知道是否可以使用 Emacs 的模式行来设置每个文件的缩进。有什么想法吗?

复制并粘贴@phlis 的评论

Both file-local and directory-local variables can resolve this. For a per-project basis, directory-local variables are usually best.

If you're running a version of Emacs prior to 24.3 then see emacswiki.org/emacs/DirectoryVariables for a workaround and example usage. With 24.3+ you can use the enable-remote-dir-locals variable (as Thomas points out).

另一个交叉 IDE 选项是 editorconfig。例如:

root = true

[*]
end_of_line = crlf
insert_final_newline = true
charset = gb18030
indent_style = space
indent_size = 2

参考:http://editorconfig.org/