emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comprehensive JSX support in Emacs


From: Dmitry Gutov
Subject: Re: Comprehensive JSX support in Emacs
Date: Tue, 2 Apr 2019 04:07:15 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Thunderbird/66.0

Hi Jackson!

On 27.03.2019 10:03, Jackson Ray Hamilton wrote:

Following up on my long email from a month ago, wherein I announced my plan to fully support editing JSX in js-mode…

After many mornings and evenings of hacking (and many moonlight-melted candlesticks, and many moments spent meandering and muttering), I’ve finally got the JavaScript+JSX implementation to a state where I feel it’s worth sharing again.

I’ve added pretty comprehensive indentation and font-locking support, along with relatively simple automatic JSX detection support.

Thanks a lot!

I've checked out Marcin's branch and played with it a bit. To the untrained eye, at least, things work quite well. So as far as I'm concerned, you can just push the new code to master and continue refining it there. Especially since you seem to add tests quite regularly.

I personally don't work with JSX (or even JavaScript much, these days), so I hope others who do will provide more valuable feedback regarding missing features and regressions. It's probably still worth it to get the feature into master soon.

Do you have commit access?

The indentation and font-locking code complimented each other well.  In order to fix issues like the one with an unterminated quote inside JSX (https://github.com/mooz/js2-mode/issues/409) (which truly haunted me for the past years) I had to thoroughly parse the JSX code.  The information I gained from parsing eventually led to the resolution of all the failing indentation test cases I compiled, and some new ones I added along the way.

:thumbsup:

js-mode no longer relies on sgml-mode for any parsing or indentation. It’s all performed precisely according to the semantics of JSX now, borrowing just two blocks of code from sgml-mode as a basis for overlapping indentation logic.  Also, the JSX code has pretty colors now.

The colors are very nice to have. Do you think this approach is portable to js2-mode?

I mentioned that a “js-syntax-extensions” list might have some esoteric advantage by its ordering resolving theoretical conflicts between multiple syntax extensions, but I figure 1) we can cross that bridge when we get there, and 2) if we did add more syntax extensions for JS /and/ those syntax extensions did partially conflict /and/ users wanted to use conflicting extensions simultaneously, perhaps it’d be better to add some booleans that would resolve such conflicts on a case-by-case basis, anyway.

Maybe, yes.

Taking into consideration Dmitry’s ambivalence on deprecating js-jsx-mode and js-jsx-indent-line, I figured we could strike a compromise.  We can keep these APIs without marking them obsolete.

*shrug* The way you've implemented jsx-jsx-mode is basically begging for an obsoletion marker. I don't really mind, though.

However, I’ve tried to make the automatic detection of JSX—and the viable alternatives to manually enabling JSX support—/so effective/ and numerous as to render these functions superfluous relics.  The go-forward answer to “how to enable JSX support in Emacs?” should be “upgrade to Emacs 27—now it just works™”.

I also addressed the spelling / naming items that Stefan brought up.

I had a chance to play with the code in a few projects of mine over the past week, and generally it is working well for me—much better than before, in all the previously painful cases.  However, there is a noticeable delay when editing some lines in my 1000-line monolith.jsx file,

This sounds a bit worrisome. Slow font-lock rules?

But since you're working on this already, just let us know if you hit some strong obstacles there.

(Note that the patch “0015-Indent-broken-arrow-function-bodies-as-an-N-1th-arg.patch” isn’t really related to the JSX feature.  I was just editing some code in a project of mine, and found that this change provided more desirable behavior with the code I was writing then.  A lot of my code using JSX also uses arrow functions, so this was a convenient patch for me to lump in.)

LGTM.

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]