From c014950f6d65e2c72927ca0d8d240706bfb86ad2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 3 Sep 2025 14:40:36 +0200 Subject: [PATCH] fix(cli): remove *-ts-mode {interpreter,auto}-mode-alist entries While generating the autoloads for the current profile (at `doom sync`), remove any `add-to-list` forms modifying `interpreter-mode-alist` or `auto-mode-alist` in autoloaded `(when (treesit-available-p) ...)` blocks. We want to fully rely on `major-mode-remap-defaults`. --- lisp/lib/autoloads.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/lib/autoloads.el b/lisp/lib/autoloads.el index e4546275d..34a18bf46 100644 --- a/lisp/lib/autoloads.el +++ b/lisp/lib/autoloads.el @@ -57,6 +57,16 @@ hoist buggy forms into autoloads.") (let ((func (car-safe form))) (cond ((memq func '(provide custom-autoload register-definition-prefixes)) nil) + ;; HACK: Remove modifications to `auto-mode-alist' and + ;; `interpreter-mode-alist' in *-ts-mode package. They are applied + ;; twice and often overwrite user or module configuration. + ((equal (list (car form) (cadr form)) '(when (treesit-available-p))) + (setf (nth 2 form) + (cl-loop for form in (nth 2 form) + if (or (not (eq (car-safe form) 'add-to-list)) + (not (memq (nth 1 form) '(auto-mode-alist interpreter-mode-alist)))) + collect form)) + form) ((and (eq func 'add-to-list) (memq (doom-unquote (cadr form)) doom-autoloads-cached-vars))