|
From: | Dmitry Gutov |
Subject: | Re: Turning on/off tree-sitter modes |
Date: | Wed, 4 Dec 2024 03:47:00 +0200 |
User-agent: | Mozilla Thunderbird |
On 03/12/2024 16:55, Stefan Monnier wrote:
+;;;###autoload (add-to-list 'major-mode-remap-defaults +;;;###autoload '(cmake-mode . cmake-ts-mode-maybe)) + +;;;###autoload +(defun cmake-ts-mode-maybe () + "Enable `cmake-ts-mode' if available." + (cond + ((treesit-ready-p 'cmake) (cmake-ts-mode)) + ((fboundp 'cmake-mode) (cmake-mode)) + (t (fundamental-mode))))
Should we do this switch if the grammar is not available? We could stay with the tree-sitter mode if it doesn't anything bad.
Take for example rust-ts-mode, or dockerfile-ts-mode: the body of the major mode function is wrapped in
(when (treesit-ready-p 'dockerfile) ... )which checks for the grammar, emits the warning and does nothing otherwise. So dockerfile-ts-mode behaves like prog-mode in this case, even highlighting strings using the default syntax table.
If there are downsides, they would probably be limited to having the mm keymap enabled, or dockerfile-ts-mode-hook run, which could be good too - depending on what the user expects to happen.
[Prev in Thread] | Current Thread | [Next in Thread] |