diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index 007b56879..895ad93de 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -20,9 +20,10 @@ (def-package! editorconfig :after-call (doom-switch-buffer-hook after-find-file) :config - (defun doom--editorconfig-smart-detection-a (orig-fn) + (def-advice! +editorconfig-smart-detection-a (orig-fn) "Retrieve the properties for the current file. If it doesn't have an extension, try to guess one." + :around #'editorconfig-call-editorconfig-exec (let ((buffer-file-name (if (and (not (bound-and-true-p org-src-mode)) (file-name-extension buffer-file-name)) @@ -32,22 +33,21 @@ extension, try to guess one." (concat "." ext) ""))))) (funcall orig-fn))) - (advice-add #'editorconfig-call-editorconfig-exec :around #'doom--editorconfig-smart-detection-a) - (defun +editorconfig|disable-ws-butler-maybe (props) - "Disable `ws-butler-mode' if trim_trailing_whitespace is true." - (when (and (equal (gethash 'trim_trailing_whitespace props) "true") - (bound-and-true-p ws-butler-mode)) - (ws-butler-mode -1))) - (add-hook 'editorconfig-after-apply-functions #'+editorconfig|disable-ws-butler-maybe) + (add-hook 'editorconfig-after-apply-functions + (defun +editorconfig-disable-ws-butler-maybe-h (props) + "Disable `ws-butler-mode' if trim_trailing_whitespace is true." + (when (and (equal (gethash 'trim_trailing_whitespace props) "true") + (bound-and-true-p ws-butler-mode)) + (ws-butler-mode -1)))) - (defun +editorconfig|disable-indent-detection (props) - "Inhibit `dtrt-indent' if an explicit indent_style and indent_size is + (add-hook 'editorconfig-after-apply-functions + (defun +editorconfig-disable-indent-detection-h (props) + "Inhibit `dtrt-indent' if an explicit indent_style and indent_size is specified by editorconfig." - (when (or (gethash 'indent_style props) - (gethash 'indent_size props)) - (setq doom-inhibit-indent-detection 'editorconfig))) - (add-hook 'editorconfig-after-apply-functions #'+editorconfig|disable-indent-detection) + (when (or (gethash 'indent_style props) + (gethash 'indent_size props)) + (setq doom-inhibit-indent-detection 'editorconfig)))) ;; Editorconfig makes indentation too rigid in Lisp modes, so tell ;; editorconfig to ignore indentation there. The dynamic indentation support