El domingo 22 de septiembre del 2019 a las 1850 horas, Jackson Ray Hamilton escribió: > Hola Jorge, > > Emacs’ JSX support is relatively new and could probably be optimized > to perform better at scale. I noticed similar slowdowns with files > containing 300+ lines of JSX. > > Before I contributed the JSX support code to Emacs, I used > (elp-instrument-package "js-") and (elp-results) to identify choke > points during editing. I felt like I was able to slightly improve > performance for large files, going from “unusable” to merely > “frustrating.” > > If you are familiar with Emacs Lisp and feel compelled to make things > stabler and faster, perhaps you can find some time to benchmark and > experiment in lisp/progmodes/js.el. Otherwise, please open a bug report. > > Some tips if you decide to help: you mentioned an AST, but there isn’t > one. Parsing starts in js-syntax-propertize. Years ago, Sebastian > Wiesner wrote some blog articles explaining how syntax highlighting > worked in Emacs, but he’s since removed those posts from his blog and > they aren’t available on Internet Archive. Maybe he will provide you > with the articles if you ask him for: > > * 2014, Mar 11 Overview of Emacs Font Locking > * 2014, Mar 12 Syntactic fontification in Emacs > * 2014, Mar 26 Search-based fontification with keywords > * 2014, Jun 16 Advanced syntactic fontification > > Also, maybe you could separate your JSX code into smaller modules. > That will make it easier for tools like Emacs, prettifiers, and > linters to process your code. Even though the code can probably be > optimized, since we care about accuracy parsing time will ultimately > be gated by file length regardless. Smaller modules are also > consistent with some programmers’ expectations for high quality code; > they are more likely to be below length thresholds permitting easy > comprehension. > > Jackson Hey, Jackson! Thanks for the pointers, I'm absolutely interested in making the JavaScript (and JSX) support in Emacs better.