treesit-auto
treesit-auto copied to clipboard
Guard against empty :ext on treesit-auto-add-to-auto-mode-alist
An unguarded (add-to-list 'auto-mode-alist ...) introduces a bug in 'auto-mode-alist e.g. the following entry
'(nil . glsl-mode)
This miserably fails at every file visitation, because
(set-auto-mode) would eventually do
(assoc-default filename auto-mode-alist #'string-match) wherein
(string-match nil filename) raises the following error:
(wrong-type-argument stringp nil)
PS: In treesit-auto.el:
(add-to-list 'auto-mode-alist
(cons (treesit-auto-recipe-ext r) (treesit-auto-recipe-ts-mode r)))
Locally, I introduced this correction instead,
(when (treesit-auto-recipe-ext r)
(add-to-list 'auto-mode-alist
(cons (treesit-auto-recipe-ext r) (treesit-auto-recipe-ts-mode r))))
Hope this suggestion aligns with the intended design.