applies only to some modes in revert-buffer
(let ((modehooks '(prog-mode-hook text-mode-hook read-only-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 'insert-file-contents :around 'editorconfig--advice-insert-file-contents) (dolist (hook modehooks) (add-hook hook 'editorconfig-major-mode-hook t))) (advice-remove 'find-file-noselect 'editorconfig--advice-find-file-noselect) (advice-remove 'insert-file-contents 'editorconfig--advice-insert-file-contents) (dolist (hook modehooks) (remove-hook hook 'editorconfig-major-mode-hook))))
If I revert an emacs lisp file, because this mode is define as.
(define-derived-mode emacs-lisp-mode lisp-data-mode [...] (define-derived-mode lisp-data-mode prog-mode "Lisp-Data"
prog-mode is part of its hierarchy, therefore editorconfig-major-mode-hook is run and the style is applied.
But, if I revert a go.work file, because go-dot-work-mode is defined as
(define-derived-mode go-dot-work-mode fundamental-mode "Go Work"
editorconfig-major-mode-hook is not applied.
The style is apply during the initial opening, because editorconfig–advice-find-file-noselect runs it. Unfortunately, only editorconfig–advice-insert-file-contents is called during a revert-buffer and it does not sets the style.