emacs/var/elfeed/db/data/e8/e8524fbe3313e1ceee15557bde068591c147a5f3
2022-01-03 12:49:32 -06:00

5 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>Mickey Petersen author of the <a href="https://masteringemacs.org/">the excellent book Mastering Emacs and the blog of the same name</a> has another of his comprehensive and informative articles on his blog. This time its about <a href="https://masteringemacs.org/">tree sitter and its application to syntax highlighting in Emacs</a>.</p>
<p>Even though we take it mostly for granted, syntax highlighting is actually a devilishly difficult problem. Emacs and almost every other editor does it with a witches brew of regular expressions and <i>ad hoc</i> functions. The results are usually, but not always, good enough. The correct method, of course, is to build a syntax tree of the code and use that to inform the highlighting. Theres a whole host of problems with that approach. In the first place, the code youre editing probably isnt syntactically correct because its incomplete. Secondly, the naive solution of rebuilding the tree with every keystroke is too slow to be practical and there are other problems as well.</p>
<p>Mickey has a solution: <a href="https://masteringemacs.org/article/tree-sitter-complications-of-parsing-languages">use tree sitter to drive the highlighting</a>. If you dont know about tree sitter or what its used for, head on over to Mickeys post for the details. Tree sitter can do more than just figure out syntax highlighting. Mickey mentions the excellent <a href="https://masteringemacs.org/article/tree-sitter-complications-of-parsing-languages">ParEdit</a> and its use in Lispy languages. Mickey wanted to extend that capability to other languages, Python in particular.</p>
<p>Hes built a package to do just that. He calls it <a href="https://github.com/mickeynp/combobulate">combobulate</a>. Its still alpha software but you can try it out if you like. Mickey says hell put it on Melpa as soon as he works out a few more issues. Mickey believes that the tree sitter approach is the future for addressing these types of problems.</p>
<p>I know I keep saying this but tree sitter and Emacs embrace of it once again puts the lie to the notion that Emacs is moribund technology. The reverse is true. Emacs keeps introducing new capabilities that other editors copy and then use to support their claims of superiority.</p>