diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index f88057bf3..549f38c10 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -1438,7 +1438,12 @@ between the two." ;; HACK: Somehow, users/packages still find a way to modify tab-width in ;; org-mode. Since org-mode treats a non-standerd tab-width as an error ;; state, I use this hook to makes it much harder to change by accident. - (add-hook! 'org-mode-hook :depth 110 (setq-local tab-width 8)) + (add-hook! 'org-mode-hook + (add-hook! 'after-change-major-mode-hook :local + ;; The second check is necessary, in case of `org-edit-src-code' which + ;; clones a buffer and changes its major-mode. + (when (derived-mode-p 'org-mode) + (setq tab-width 8)))) ;; Save target buffer after archiving a node. (setq org-archive-subtree-save-file-p t) diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index e6d52b3c5..5fb5bfa87 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -48,6 +48,16 @@ extension, try to guess one." (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))))) + (when (and (not doom-inhibit-indent-detection) + (or (gethash 'indent_style props) + (gethash 'indent_size props))) + (setq doom-inhibit-indent-detection 'editorconfig))) + ;; I use a hook over `editorconfig-exclude-modes' because the option + ;; inhibits all settings, and I only want to inhibit indent_size. Plus modes + ;; in that option won't apply to derived modes, so we'd have to add *all* + ;; possible org-mode derivatives to it. + (defun +editorconfig-unset-tab-width-in-org-mode-h (props) + "A tab-width != 8 is an error state in org-mode, so prevent changing it." + (when (and (gethash 'indent_size props) + (derived-mode-p 'org-mode)) + (setq tab-width 8)))))