GNU bug report logs -
#74610
31.0.50; Submitting mhtml-ts-mode, treesitter alternative to mhtml-mode
Previous Next
Reported by: Vincenzo Pupillo <v.pupillo <at> gmail.com>
Date: Fri, 29 Nov 2024 21:58:01 UTC
Severity: wishlist
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Ciao Yuan and Juri,
this is an updated version of mhtml-ts-mode.
I have tried to reduce as much as possible copies of parts of the major modes
from which it is derived.
To do this, I had to move some values that were assigned directly to treesit's
own variables (in ccs-mode.el, in js.el, and in html-ts-mode.el) into new
variables.
I also added three new functions to treesit.el to make it easier to combine
parts derived from the other major modes. So now any changes to these new
variables are directly reflected in the behavior of mhtml-ts-mode.
There are a few things I would like to highlight:
1. treesit-font-lock-feature-lists are not defined per parser, so simply
merging the different lists will cause display differences from the original
major-modes; for example “function” is defined at level 3 in css-ts-mode but
at level 4 in js-ts-mode.
2. treesit-defun-type-regexp has the same problem as treesit-font-lock-
feature-list, so I had to define it myself.
But other than that, it works pretty well.
IMHO, a global "list" where you can define "font-lock", "indent-list", "font-
lock-feature", etc. by language (perhaps with getter and setter methods) might
make it easier to define new multilingual major-modes. It could improve the
decoupling between multilingual major-modes and the major-modes they are
derived from. It could also better decouple the internal implementation of
treesit.el from the treesitter-based major-modes.
Let me know what you think.
Thanks.
Vincenzo
p.s. In this version I also added support for wich-function-mode, for flymake
and a pretty-print function.
In data martedì 24 dicembre 2024 23:18:39 Ora standard dell’Europa centrale,
Yuan Fu ha scritto:
> > On Dec 24, 2024, at 12:37 AM, Yuan Fu <casouri <at> gmail.com> wrote:
> >> On Dec 14, 2024, at 2:37 AM, Vincenzo Pupillo <v.pupillo <at> gmail.com>
> >> wrote:
> >>
> >> In data mercoledì 11 dicembre 2024 05:54:09 Ora standard dell’Europa
> >> centrale,>>
> >> Yuan Fu ha scritto:
> >>>> On Dec 3, 2024, at 6:29 AM, Vincenzo Pupillo <v.pupillo <at> gmail.com>
> >>>> wrote:
> >>>>
> >>>> In data domenica 1 dicembre 2024 07:01:21 Ora standard dell’Europa
> >>>> centrale,>
> >>>>
> >>>> Yuan Fu ha scritto:
> >>>>> It's not uncommon to see different indent offset for CSS and
> >>>>> Javascript, so it's a good idea to have separate control for them.
> >>>>
> >>>> Is the behavior the same as mhtml-mode, or would you like something
> >>>> like
> >>>> this?>
> >>>>
> >>>> <style>
> >>>>
> >>>> z {
> >>>>
> >>>> color: red;
> >>>>
> >>>> }
> >>>>
> >>>> </style>
> >>>> <script>
> >>>>
> >>>> function myFunction(p1, p2) {
> >>>>
> >>>> return p1 * p2;
> >>>>
> >>>> }
> >>>>
> >>>> </script>
> >>>>
> >>>> The mhtml-ts-mode-js-css-indent-offset variable controls only the
> >>>> indentation relative to the <style> and <script> tags.
> >>>
> >>> Ah, I see, it’s the offset from the enclosing tag. In that case it
> >>> should be fine to use a common variable.
> >>>
> >>> Yuan
> >>
> >> Thank you Yuan.
> >> 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.
> >>
> >> Vincenzo
> >> <0001-Add-mhtml-ts-mode.patch>
> >
> > Btw, mhtml-ts-mode--defun-name seems to contain some debugging code? And
> > also I think you should use treesit-node-language.
> >
> > Yuan
>
> I just added treesit-aggregated-simple-imenu-settings to master. This
> variable will allow you to setup Imenu for multiple languages. Please give
> it a try. I tested locally with mhtml-ts-mode and works well.
>
> Yuan
[0001-Add-mhtml-ts-mode.patch (text/x-patch, attachment)]
This bug report was last modified 98 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.