不包括特定子目录的 emacs 目录变量
emacs directory variables excluding particular subdir
我有一个需要 2 个空格缩进的项目 A,但它在使用 4 个空格的子文件夹 B 中嵌入了另一个项目。
我在 A/.dir-locals.el 中有以下内容:
((c-mode . ((indent-tabs-mode . nil)
(c-basic-offset . 2))))
...它很好地适用于目录 A 中的所有 c 文件。
问题:我可以在同一个 dir-locals.el 文件中排除子文件夹 B 不受 2 个空格缩进的影响吗?
我当然可以用 B 的设置创建一个 A/B/.dir-locals.el,但是因为现在 A 是例外,所以我宁愿保留设置在 A/.dir-locals.el
您不能在 .dir-locals
个文件中指定路径。
我想 .editorconfig is a better solution anyway. Because it allows you to share coding styles with users of other editors. Emacs has a nice package 应用 .editorconfig
文件的设置。
将此放在您的 A
目录中:
# top-most EditorConfig file
root = true
# only match files in root folder
[/*.c]
indent_style = space
indent_size = 2
引自手册:
Here’s an example of a ‘.dir-locals.el’ file:
((nil . ((indent-tabs-mode . t)
(fill-column . 80)))
(c-mode . ((c-file-style . "BSD")
(subdirs . nil)))
("src/imported"
. ((nil . ((change-log-default-name
. "ChangeLog.local"))))))
This sets ‘indent-tabs-mode’ and ‘fill-column’ for any file in the
directory tree, and the indentation style for any C source file. The
special ‘subdirs’ element is not a variable, but a special keyword which
indicates that the C mode settings are only to be applied in the current
directory, not in any subdirectories. Finally, it specifies a different
‘ChangeLog’ file name for any file in the ‘src/imported’ subdirectory.
-- C-hig (emacs)Directory Variables
RET
所以在你的情况下,你可能正在寻找类似的东西:
((c-mode . ((indent-tabs-mode . nil)
(c-basic-offset . 2)))
("B" . ((c-mode . ((c-basic-offset . 4))))))
我有一个需要 2 个空格缩进的项目 A,但它在使用 4 个空格的子文件夹 B 中嵌入了另一个项目。
我在 A/.dir-locals.el 中有以下内容:
((c-mode . ((indent-tabs-mode . nil)
(c-basic-offset . 2))))
...它很好地适用于目录 A 中的所有 c 文件。
问题:我可以在同一个 dir-locals.el 文件中排除子文件夹 B 不受 2 个空格缩进的影响吗?
我当然可以用 B 的设置创建一个 A/B/.dir-locals.el,但是因为现在 A 是例外,所以我宁愿保留设置在 A/.dir-locals.el
您不能在 .dir-locals
个文件中指定路径。
我想 .editorconfig is a better solution anyway. Because it allows you to share coding styles with users of other editors. Emacs has a nice package 应用 .editorconfig
文件的设置。
将此放在您的 A
目录中:
# top-most EditorConfig file
root = true
# only match files in root folder
[/*.c]
indent_style = space
indent_size = 2
引自手册:
Here’s an example of a ‘.dir-locals.el’ file:
((nil . ((indent-tabs-mode . t)
(fill-column . 80)))
(c-mode . ((c-file-style . "BSD")
(subdirs . nil)))
("src/imported"
. ((nil . ((change-log-default-name
. "ChangeLog.local"))))))
This sets ‘indent-tabs-mode’ and ‘fill-column’ for any file in the
directory tree, and the indentation style for any C source file. The
special ‘subdirs’ element is not a variable, but a special keyword which
indicates that the C mode settings are only to be applied in the current
directory, not in any subdirectories. Finally, it specifies a different
‘ChangeLog’ file name for any file in the ‘src/imported’ subdirectory.
-- C-hig (emacs)Directory Variables
RET
所以在你的情况下,你可能正在寻找类似的东西:
((c-mode . ((indent-tabs-mode . nil)
(c-basic-offset . 2)))
("B" . ((c-mode . ((c-basic-offset . 4))))))