代码之家  ›  专栏  ›  技术社区  ›  user3729611

emacs目录变量,不包括特定子目录

  •  1
  • user3729611  · 技术社区  · 7 年前

    我有一个需要2个空格缩进的项目a,但它在使用4个空格的子文件夹B中嵌入了另一个项目。

    ((c-mode . ((indent-tabs-mode . nil)
                (c-basic-offset . 2))))
    

    ... 它很好地适用于目录A中的所有c文件。

    我当然可以创建一个a/B/。dir局部变量。el使用B的设置,但由于现在是A例外,我更愿意将设置保留在A/中。dir局部变量。el

    2 回复  |  直到 7 年前
        1
  •  2
  •   phils    7 年前

    引用手册:

       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-h 一、 (emacs)Directory Variables RET公司

    因此,在您的情况下,您可能会寻找以下内容:

    ((c-mode . ((indent-tabs-mode . nil)
                (c-basic-offset . 2)))
     ("B" . ((c-mode . ((c-basic-offset . 4))))))
    
        2
  •  0
  •   Jürgen Hötzel    7 年前

    .dir-locals 文件夹。

    我想 .editorconfig package 应用 .editorconfig 文件

    A 目录:

    # top-most EditorConfig file
    
    root = true
    # only match files in root folder
    [/*.c]
    indent_style = space
    indent_size = 2