tools/editorconfig: conform to new conventions

This commit is contained in:
Henrik Lissner 2019-07-22 23:28:12 +02:00
parent 8e09b8b7fe
commit 28aead72ef
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

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