GNU bug report logs - #74610
31.0.50; Submitting mhtml-ts-mode, treesitter alternative to mhtml-mode

Previous Next

Package: emacs;

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


Message #64 received at 74610 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Vincenzo Pupillo <v.pupillo <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 74610 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#74610: 31.0.50; Submitting mhtml-ts-mode, treesitter
 alternative to mhtml-mode
Date: Fri, 17 Jan 2025 17:37:53 -0800

> On Jan 14, 2025, at 1:41 PM, Vincenzo Pupillo <v.pupillo <at> gmail.com> wrote:
> 
> 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.

Yeah, that’s not pretty, I don’t have a good solution for now. Technically a major mode can use treesit-font-lock-recompute-features after treesit-major-mode-setup to do fine adjustments, but it’s ugly.

> 2. treesit-defun-type-regexp has the same problem as treesit-font-lock-
> feature-list, so I had to define it myself.

Maybe you can use treesit-thing-settings instead?

> 
> 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.

That’s what I had in mind. That’s also why I added a new variable treesit-aggregated-simple-imenu-settings instead of piggybacking on treesit-simple-imenu-settings. A separate variable is simpler to borrow settings from.

But I didn’t have time to think it though yet. (By language, or by mode and language? Should packages set it on load, or define a function that loads these settings? Etc.) 

Yuan



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.