From 2757a97a30e7c4a0c2a5d2de13f2214baf09b019 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 4 Mar 2024 05:08:14 -0500 Subject: [PATCH] fix(org): don't change tab-width in org-mode Recently, org-mode made a non-standard tab-width an error state. Unfortunately, it's way too easy for users to accidentally change it (e.g. with editorconfig, indiscriminate setter hooks, or other packages), and since there is zero reason to ever want a non-standard tab-width in org-mode, I not only exclude it from dtrt-indent as a global default (i.e. not only as part of :lang org), but I add a late org-mode-hook hook to reset tab-width, just in case. --- lisp/doom-editor.el | 7 ++++++- modules/lang/org/config.el | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/doom-editor.el b/lisp/doom-editor.el index 2827fde85..e9d460adc 100644 --- a/lisp/doom-editor.el +++ b/lisp/doom-editor.el @@ -2,7 +2,12 @@ ;;; Commentary: ;;; Code: -(defvar doom-detect-indentation-excluded-modes '(pascal-mode so-long-mode) +(defvar doom-detect-indentation-excluded-modes + '(pascal-mode + so-long-mode + ;; Automatic indent detection in org files is meaningless. Not to mention, a + ;; non-standard `tab-width' causes an error in org-mode. + org-mode) "A list of major modes where indentation shouldn't be auto-detected.") (defvar-local doom-inhibit-indent-detection nil diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 087f95cf6..f88057bf3 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -181,9 +181,6 @@ Is relative to `org-directory', unless it is absolute. Is used in Doom's default ("NO" . +org-todo-cancel) ("KILL" . +org-todo-cancel))) - ;; Automatic indent detection in org files is meaningless - (add-to-list 'doom-detect-indentation-excluded-modes 'org-mode) - (set-ligatures! 'org-mode :name "#+NAME:" :name "#+name:" @@ -1438,6 +1435,11 @@ between the two." :references #'+org-lookup-references-handler :documentation #'+org-lookup-documentation-handler) + ;; 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)) + ;; Save target buffer after archiving a node. (setq org-archive-subtree-save-file-p t)