From 94a1fe64a8d3fffee4160e397d320e3850c95b6d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 31 Aug 2025 12:30:49 +0200 Subject: [PATCH] fix(tree-sitter): suppress "Can't find grammar" warnings In Emacs <=30, top-level `treesit-ready-p` calls in various *-ts-mode packages (like lua-ts-mode or ruby-ts-mode) are commonplace, and they throw up a warning popup if the grammar isn't available at load time. This is intrusive. Instead, this forces it to log to *Messages* instead before falling back to the normal major mode. Fortunately, these top-level `treesit-ready-p` calls have been removed in most *-ts-mode packages in 31+, but this still impacts users on <=30 or using third party *-ts-modes that haven't adapted. However, this doesn't suppress the warning when opening a *-ts-mode.el file (thanks to the byte-compiler). --- modules/tools/tree-sitter/config.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/tools/tree-sitter/config.el b/modules/tools/tree-sitter/config.el index 09845c365..d45aa88c9 100644 --- a/modules/tools/tree-sitter/config.el +++ b/modules/tools/tree-sitter/config.el @@ -51,7 +51,12 @@ (memq fallback-mode treesit-enabled-modes)) ;; Lazily load autoloaded `treesit-language-source-alist' ;; entries. - (let ((fn (symbol-function mode))) + (let ((fn (symbol-function mode)) + ;; Silence "can't find grammar" warning popups from + ;; `treesit-ready-p' calls in Emacs <=30.1. We'll + ;; log it to *Messages* instead. + (warning-suppress-types + (cons '(treesit) warning-suppress-types))) (or (not (autoloadp fn)) (autoload-do-load fn mode))) ;; Only prompt once, and log other times.