[Top][All Lists]

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

Emacs crashes when writting JavaScript

From: Jackson Ray Hamilton
Subject: Emacs crashes when writting JavaScript
Date: Sun, 22 Sep 2019 17:50:29 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

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.


reply via email to

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