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.
This commit is contained in:
Henrik Lissner 2024-03-04 05:08:14 -05:00
parent 183ab38926
commit 2757a97a30
No known key found for this signature in database
GPG Key ID: B60957CA074D39A3
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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)