Subject: bug#74610: 31.0.50; Submitting mhtml-ts-mode, treesitter alternative to mhtml-mode

From: Vincenzo Pupillo <[email-masked]>
Date: Tue, 17 Dec 2024 22:25:59 +0100

Ciao Juri,

In data lunedì 16 dicembre 2024 18:37:35 Ora standard dell’Europa centrale, 
Juri Linkov ha scritto:
> Ciao Vincenzo,
> 
> > In data mercoledì 11 dicembre 2024 05:54:09 Ora standard dell’Europa
> > centrale,
> > 
> > Attached is the revised patch following your previous comments.
> > As I already wrote to Dmitry, I am doing some tests to see if html-ts-mode
> > can be extended and if there is a way to integrate one multi-language
> > mode into another multi-language mode.
> 
> I'm testing your patch with mhtml-ts-mode, and everything works nicely.
> 

Thanks

> At the same time I'm adding a new ts-thing named 'sexp-list' in bug#73404.
> While 'sexp' defines both lists and atoms, 'sexp-list' defines only lists.
> 
> So I added (sexp-list ,(regexp-opt '("element")) 'symbols)
> to treesit-thing-settings in html-ts-mode.el.
> 
> But then discovered surprisingly that it has no effect on mhtml-ts-mode.
> 
> The problem is that treesit-thing-settings should be duplicated
> from html-ts-mode to mhtml-ts-mode.
> 
> On the one hand, integrating multi-language mode to the exiting mode
> html-ts-mode could avoid the need to duplicate treesit-thing-settings
> for html.
> 
> But on the other hand, integrating mhtml-ts-mode to html-ts-mode
> doesn't help to avoid such duplication for other embedded modes.
> Because I needed to duplicate treesit-thing-settings for javascript
> as well.
> 
> So extending html-ts-mode doesn't help here, and maybe even better
> to add mhtml-ts-mode to keep the symmetry with existing mhtml-mode
> such as used in mode remapping:
> 
>   (add-to-list 'major-mode-remap-alist '(mhtml-mode .
>                                          mhtml-ts-mode))
> 
> What could really help is to try to get settings from html-ts-mode
> and js-ts-mode to avoid the need to duplicate settings in mhtml-ts-mode.

I think we need something like a generalized version of the 
`mhtml--construct-submode' function. I'm doing some testing on that and hope 
to have something decent after Christmas.

Vincenzo.