; Improve documentation of EditorConfig support

* doc/emacs/custom.texi (EditorConfig support): Improve wording
and indexing.
* doc/emacs/emacs.texi (Top): Update @detailmenu.
This commit is contained in:
Eli Zaretskii 2024-06-22 09:01:12 +03:00
parent 60070d0d74
commit 4f03083499
2 changed files with 33 additions and 16 deletions

View file

@ -1557,25 +1557,35 @@ as Dired buffers (@pxref{Dired}).
@node EditorConfig support @node EditorConfig support
@subsubsection Per-Directory Variables via EditorConfig @subsubsection Per-Directory Variables via EditorConfig
@cindex EditorConfig support @cindex EditorConfig support
@cindex directory-local variables, via EditorConfig
@cindex per-directory local variables, via EditorConfig
The @uref{https://editorconfig.org/, EditorConfig standard} The @uref{https://editorconfig.org/, EditorConfig standard}
is an alternative to the @file{.dir-locals.el} is an alternative to the @file{.dir-locals.el}
files, which can control only a very small number of variables, but files, which can control only a very small number of variables, but
has the advantage of being editor-neutral. Those settings are stored in has the advantage of being editor-neutral, not specific to Emacs. Those
files named @file{.editorconfig}. settings are stored in files named @file{.editorconfig}, and affect the
files in that directory and its subdirectories.
If you want Emacs to obey those settings, you need to enable @findex editorconfig-mode
the @code{editorconfig-mode} minor mode. This is usually all that is @vindex enable-local-variables@r{, and EditorConfig settings}
needed: when the mode is activated, Emacs will look for @file{.editorconfig} If you want Emacs to obey the settings from @file{.editorconfig} files,
files whenever a file is visited, just as it does for @file{.dir-locals.el}. you need to enable the @code{editorconfig-mode} global minor mode. This
When both @file{.editorconfig} and @file{.dir-locals.el} files are is usually all that is needed: when the mode is activated, whenever a
found, their settings are combined, and in case of a conflict, the file is visited, Emacs will look for @file{.editorconfig} in the file's
setting coming from the closest file takes precedence. directory and its parent directories, just as it does for
If they are equally close, @file{.dir-locals.el} takes precedence. @file{.dir-locals.el}. When both @file{.editorconfig} and
In terms of security, those settings are subject to the same checks @file{.dir-locals.el} files are found, their settings are combined, and
as those coming from @file{.dir-locals.el} (and also honor in case of a conflict, the setting coming from the file closest in the
@code{enable-local-variables}). directory hierarchy takes precedence. If they are equally close,
@file{.dir-locals.el} takes precedence. In terms of security, the
@file{.editorconfig} settings are subject to the same checks as those
coming from @file{.dir-locals.el} and from file-local variables (and
also honor @code{enable-local-variables}). @xref{Safe File Variables}.
@cindex @code{indent_size} setting of EditorConfig
@vindex editorconfig-indent-size-vars
@vindex editorconfig-indentation-alist
The @code{indent_size} setting of the EditorConfig standard does not The @code{indent_size} setting of the EditorConfig standard does not
correspond to a fixed variable in Emacs, but instead needs to set correspond to a fixed variable in Emacs, but instead needs to set
different variables depending on the major mode. Ideally all major different variables depending on the major mode. Ideally all major
@ -1585,12 +1595,15 @@ effect because the major mode does not yet support it, you can customize
the @code{editorconfig-indentation-alist} variable to tell Emacs which the @code{editorconfig-indentation-alist} variable to tell Emacs which
variables need to be set in that major mode. variables need to be set in that major mode.
@cindex @code{trim_trailing_whitespace} setting of EditorConfig
@vindex editorconfig-trim-whitespaces-mode
@findex delete-trailing-whitespace, and EditorConfig settings
Similarly, there are several different ways to trim whitespace at Similarly, there are several different ways to trim whitespace at
the end of lines. When the EditorConfig @code{trim_trailing_whitespace} the end of lines. When the EditorConfig @code{trim_trailing_whitespace}
setting is used, by default @code{editorconfig-mode} simply calls setting is used, by default @code{editorconfig-mode} simply calls
@code{delete-trailing-whitespace} every time you save your file. @code{delete-trailing-whitespace} (@pxref{Useless Whitespace}) every
If you prefer some other behavior, You can customize time you save your file. If you prefer some other behavior, you can
@code{editorconfig-trim-whitespaces-mode} to the minor mode of customize @code{editorconfig-trim-whitespaces-mode} to the minor mode of
your preference, such as @code{ws-butler-mode}. your preference, such as @code{ws-butler-mode}.
@node Connection Variables @node Connection Variables

View file

@ -1169,6 +1169,10 @@ Local Variables in Files
* Specifying File Variables:: Specifying file local variables. * Specifying File Variables:: Specifying file local variables.
* Safe File Variables:: Making sure file local variables are safe. * Safe File Variables:: Making sure file local variables are safe.
Local Variables in Directories
* EditorConfig support:: Per-Directory Variables via EditorConfig
Customizing Key Bindings Customizing Key Bindings
* Keymaps:: Generalities. The global keymap. * Keymaps:: Generalities. The global keymap.