llemaitre19 / jtsx

Extends Emacs JSX/TSX built-in support.
GNU General Public License v3.0
69 stars 2 forks source link

Consider contributing some parts to `tsx-ts-mode` in Emacs core #2

Closed mekeor closed 11 months ago

mekeor commented 11 months ago

Hello and thanks for this package! I wonder which parts of it could be upstreamed, i.e. contributed to Emacs-core's tsx-ts-mode. Have you ever considered so?

Just recently, Emacs maintainer Stefan Kangas mentioned in his talk on Emacsconf 2023 that contributions to the Tree-Sitter based modes are very welcome and much appreciated. In case of contribution, the much broader community would benefit from the improvements.

llemaitre19 commented 11 months ago

Hi @mekeor ,

Have you ever considered so?

I started writing this package because I cannot find any existing one that gives me satisfaction for all theses requirements :

Since I use Emacs releases (as many users), it was not an option to directly contribute to the Emacs core.

I consider contributing to Emacs core as a next step but with a lower priority. Because some significant extra time is needed while sharing and maintaining such a package is already time consuming.

There is also a blocking point: in Emacs core, Javascript and Typescript do not share a common code although 90% of the logic is the same (I think the reason is that behind the scene Tree-sitter languages are not the same). As a result if I want to contribute to Emacs core, for each contribution, same code (same doc, same tests, ...) is likely to be added for js-ts-mode and for tsx-ts-mode. In jtsx, code that applies to JSX and TSX is shared.

That said, jtsx code is public, so everyone is free to pick up some parts of it to integrate into Emacs core. 🙂

I wonder which parts of it could be upstreamed

I think we can divide into 3 groups what this package provides :

  1. Some patches to improve the user experience with JSX on Emacs releases starting 29.1 and on the master branch. The targeted bugs are mostly already fixed on master branch (and if not I reported them in the Emacs bug tracker).
  2. Missing integrations with built-in Emacs features : JSX comments and code folding (with hideshow).
  3. Additional handy features, mostly not intended to be in Emacs core, I think.

For me, only point 2. is candidate to be upstreamed. I believe that Emacs major mode should not be too sophiticated and let user use additional package if needed (and available).

mekeor commented 11 months ago

Very few incompatibilities when linting with Eslint and airbnb preset

Personally, I think that users ideally should not need an external package for this, but rather be able to use some variables. But of course Emacs maintainers are to decide about this.

I consider contributing to Emacs core as a next step

Glad to hear. I'll close this issue then.

There is also a blocking point: in Emacs core, Javascript and Typescript do not share a common code

typescript-ts-mode.el requires js.el. Does that help?

That said, jtsx code is public, so everyone is free to pick up some parts of it to integrate into Emacs core. 🙂

Emacs requires FSF copyright assignment whereas you are the holder of the copyright of jtsx.el. Only if you assign the copyright to the FSF (i.e. change the linked line and do the paper work), people can incorporate parts into Emacs core.

I reported them in the Emacs bug tracker

Thanks for reporting!

llemaitre19 commented 11 months ago

Very few incompatibilities when linting with Eslint and airbnb preset

Personally, I think that users ideally should not need an external package for this, but rather be able to use some variables. But of course Emacs maintainers are to decide about this.

Me too. But if you need to meet this requirement now in the Emacs release, as far as the only solution is doing some patches in elisp. And making these patches available for other users can make them save time.

There is also a blocking point: in Emacs core, Javascript and Typescript do not share a common code

typescript-ts-mode.el requires js.el. Does that help?

Yes, as soon as code shared is not Tree-sitter language specific (that in fact is almost the same for Javascript and Typescript), I guess. But here is the limit of my understanding of the underlying code structure...

That said, jtsx code is public, so everyone is free to pick up some parts of it to integrate into Emacs core. 🙂

Emacs requires FSF copyright assignment whereas you are the holder of the copyright of jtsx.el. Only if you assign the copyright to the FSF (i.e. change the linked line and do the paper work), people can incorporate parts into Emacs core.

Thanks for the tips. It sounds that Elpa has quite similar requirements. I put a reminder in my notes to look deeper into FSF copyright and what it implies.