Function: editorconfig-mode
editorconfig-mode is an autoloaded, interactive and byte-compiled
function defined in editorconfig.el.gz.
Signature
(editorconfig-mode &optional ARG)
Documentation
Toggle EditorConfig feature.
This is a global minor mode. If called interactively, toggle the
Editorconfig mode mode. If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=editorconfig-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 30.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/editorconfig.el.gz
;;;###autoload
(define-minor-mode editorconfig-mode
"Toggle EditorConfig feature."
:global t
(if (boundp 'hack-dir-local-get-variables-functions) ;Emacs≥30
(if editorconfig-mode
(progn
(add-hook 'hack-dir-local-get-variables-functions
;; Give them slightly lower precedence than settings from
;; `dir-locals.el'.
#'editorconfig--get-dir-local-variables t)
;; `auto-coding-functions' also exists in Emacs<30 but without
;; access to the file's name via `auto-coding-file-name'.
(add-hook 'auto-coding-functions
#'editorconfig--get-coding-system))
(remove-hook 'hack-dir-local-get-variables-functions
#'editorconfig--get-dir-local-variables)
(remove-hook 'auto-coding-functions
#'editorconfig--get-coding-system))
;; Emacs<30
(let ((modehooks '(prog-mode-hook
text-mode-hook
;; Some modes call `kill-all-local-variables' in their init
;; code, which clears some values set by editorconfig.
;; For those modes, editorconfig-apply need to be called
;; explicitly through their hooks.
rpm-spec-mode-hook)))
(if editorconfig-mode
(progn
(advice-add 'find-file-noselect :around #'editorconfig--advice-find-file-noselect)
(advice-add 'find-auto-coding :after-until
#'editorconfig--advice-find-auto-coding)
(dolist (hook modehooks)
(add-hook hook
#'editorconfig-major-mode-hook
t)))
(advice-remove 'find-file-noselect #'editorconfig--advice-find-file-noselect)
(advice-remove 'find-auto-coding
#'editorconfig--advice-find-auto-coding)
(dolist (hook modehooks)
(remove-hook hook #'editorconfig-major-mode-hook))))))