fix: exclude indent detection in derived modes

Changes what major modes we exclude from dtrt-indent's auto-detection.
Any mode in doom-detect-indentation-excluded-modes, plus derived modes,
will be excluded instead of only the parent modes.

This indirectly fixes an issue where org-mode derivatives (like
org-journal-mode) have their tab-width changed (#7670), causing the
`org-current-text-column` macro to throw the following error:

  Tab width in Org files must be 8, not N.  Please adjust your
  `tab-width' settings for Org mode.

I opted for this solution instead rather than adding all possibly
derivatives to `doom-detect-indentation-excluded-modes`.

Fix: #7670
Ref: 38dd882685/lisp/org-macs.el (L1154)
This commit is contained in:
Henrik Lissner 2024-02-13 12:36:20 -05:00 committed by Yann Esposito (Yogsototh)
parent ab85fd4322
commit 9a56a6feee
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -2,10 +2,8 @@
;;; Commentary:
;;; Code:
(defvar doom-detect-indentation-excluded-modes
'(fundamental-mode pascal-mode so-long-mode doom-docs-org-mode)
"A list of major modes in which indentation should be automatically
detected.")
(defvar doom-detect-indentation-excluded-modes '(pascal-mode so-long-mode)
"A list of major modes where indentation shouldn't be auto-detected.")
(defvar-local doom-inhibit-indent-detection nil
"A buffer-local flag that indicates whether `dtrt-indent' should try to detect
@ -502,8 +500,9 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(unless (or (not after-init-time)
doom-inhibit-indent-detection
doom-large-file-p
(memq major-mode doom-detect-indentation-excluded-modes)
(member (substring (buffer-name) 0 1) '(" " "*")))
(eq major-mode 'fundamental-mode)
(member (substring (buffer-name) 0 1) '(" " "*"))
(apply #'derived-mode-p doom-detect-indentation-excluded-modes))
;; Don't display messages in the echo area, but still log them
(let ((inhibit-message (not init-file-debug)))
(dtrt-indent-mode +1))))