[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Comprehensive JSX support in Emacs
Re: Comprehensive JSX support in Emacs
Tue, 2 Apr 2019 04:07:15 +0300
Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Thunderbird/66.0
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
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.
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.
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
The colors are very nice to have. Do you think this approach is portable
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
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
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
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
Re: Comprehensive JSX support in Emacs, Jackson Ray Hamilton, 2019/04/06
- Re: Comprehensive JSX support in Emacs,
Dmitry Gutov <=