Variable: editorconfig-mode-hook
editorconfig-mode-hook is a customizable variable defined in
editorconfig.el.gz.
Value
nil
Documentation
Hook run after entering or leaving editorconfig-mode(var)/editorconfig-mode(fun).
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
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))))))