[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Comprehensive JSX support in Emacs
From: |
Jackson Ray Hamilton |
Subject: |
Re: Comprehensive JSX support in Emacs |
Date: |
Sat, 6 Apr 2019 08:55:30 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
Hi Dmitry,
First of all, thanks for taking the time to review my work. Regarding
your comments/questions…
It's probably still worth it to get the feature into master soon.
I agree. I’ll see if I can tackle the performance issue first, then
I’ll rebase/merge the branch into master.
Do you have commit access?
I’m not sure. If not, will someone please grant it to me?
The colors are very nice to have. Do you think this approach is
portable to js2-mode?
Possibly… js-mode is using font-lock keywords to add the colors, but
js2-mode apparently isn’t. js2-mode would need to pay attention to the
js-jsx-* text properties like in js-jsx--font-lock-keywords and apply
colors like in the associated matcher functions (js-jsx--match-tag-name,
js-jsx--match-attribute-name, et al).
I get the feeling from looking at the js2-mode code that it colors
solely according to the AST structure. Perhaps in the long run, the
best solution for that mode will be to extend or replace the ESX parsing
with JSX parsing, adding JSXElement nodes to the AST and coloring them
along the way, and suppressing JS coloring in the JSXText nodes.
Until someone steps up to add proper JSX parsing to the JS2 AST… perhaps
a fusion of the keywords-style and AST-style colorings could provide JSX
and JS coloring (respectively) in JS2.
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?
I’ll check for that. I’m also planning on analyzing the results of
elp-instrument-package and doing some step-debugging to deduce where and
why it’s lagging.
I’ve already found that it’s lagging when I’m editing a large chunk of
JSX code or the code before it. However, if I edit code in the buffer
following the chunk of JSX, then the lag noticeably drops. You can see
this by opening the attached “Slow JSX.jsx” file and editing it. This
might be related to how I extended syntax propertization and
font-locking to the boundaries of a root enclosing JSXElement; if a root
is hundreds of lines long, there could be negative consequences. Maybe
we can be more conservative with the parsing/coloring, somehow.
Jackson
Slow JSX.jsx
Description: Text document
Re: Comprehensive JSX support in Emacs,
Jackson Ray Hamilton <=