fix(editorconfig): prevent changes to tab-width in org-mode

- Add another measure for preventing changes to tab-width in org-mode.
  The hook introduced in 2757a97 runs too early and could be overwritten
  by editorconfig.
- Fix the hook in 2757a97 to run much later, ensuring (as a last resort)
  no other packages can overwrite tab-width either.

Amend: 2757a97a30
Ref: #7670
This commit is contained in:
Henrik Lissner 2024-03-10 23:50:14 -04:00
parent 198fe82b6d
commit 43870bf831
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 19 additions and 4 deletions

View file

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