From 9a56a6feee7a55ef3d87f16f24d13b14ffb34071 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 13 Feb 2024 12:36:20 -0500 Subject: [PATCH] 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: https://github.com/emacs-straight/org-mode/blob/38dd882685e3cc5843a9cf30155432b4ebce8514/lisp/org-macs.el#L1154 --- lisp/doom-editor.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lisp/doom-editor.el b/lisp/doom-editor.el index 2159b885c..2827fde85 100644 --- a/lisp/doom-editor.el +++ b/lisp/doom-editor.el @@ -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))))