|
From: | Perry E. Metzger |
Subject: | Re: cc-mode fontification feels random |
Date: | Thu, 15 Jul 2021 14:13:41 -0400 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Thunderbird/90.0 |
On 7/11/21 14:12, Stephen Leake wrote:
The ELPA package wisi provides a parser-based fontification engine, which makes things like this more consistent. It is currently used for ada-mode. Note that syntax errors in the source can cause bad fontification, but the wisi parser has very robust error-correction, so it usually does a good job even with syntax errors. However, parsing C and C++ is complicated by macros; wisi makes no provision for that. Another option is an LSP based system via the EPLA package eglot; that delegates fontification to the language server. I don't know how well the C/C++ language servers perform for this.
Using LSP for fontification is unfortunately not sufficiently high performance. LSP is really intended for things like providing type information or enabling refactorings.
I note that several other modern editors now make use of the "Tree Sitter" library (see https://github.com/tree-sitter/tree-sitter ) which was designed explicitly to provide a C library for incremental programming language parsing for text editors. It allows for very consistent fontification in other editors like Atom, and is available under the MIT license, which would permit it to be included in Emacs.
A very good presentation a few years ago by the author, including an explanation of how Tree Sitter enables high quality fontification in editors like Atom, can be viewed on youtube: https://www.youtube.com/watch?v=Jes3bD6P0To
Perry
[Prev in Thread] | Current Thread | [Next in Thread] |