From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Perry E. Metzger" Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Thu, 15 Jul 2021 14:13:41 -0400 Message-ID: <286d815e-d1a1-07ca-6696-a7f51923ab4e@piermont.com> References: <83o8cge4lg.fsf@gnu.org> <62e438b5-d27f-1d3c-69c6-11fe29a76d74@dancol.org> <83fsxsdxhu.fsf@gnu.org> <179f22a44d8.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <179f38c0370.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <236e62c2-be9b-b26d-8cd0-4b5a1a86e19a@dancol.org> <86mtqsoh3f.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8250"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Thunderbird/90.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 15 20:14:26 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m45sQ-0001y6-03 for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 20:14:26 +0200 Original-Received: from localhost ([::1]:35778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m45sO-0006s9-V5 for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 14:14:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m45rt-0006C2-7T for emacs-devel@gnu.org; Thu, 15 Jul 2021 14:13:53 -0400 Original-Received: from hacklheber.piermont.com ([166.84.7.14]:39772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m45rr-00071D-Ew for emacs-devel@gnu.org; Thu, 15 Jul 2021 14:13:52 -0400 Original-Received: from snark.cb.piermont.com (localhost [127.0.0.1]) by hacklheber.piermont.com (Postfix) with UTF8SMTP id 5940ECE8 for ; Thu, 15 Jul 2021 14:13:42 -0400 (EDT) Original-Received: from [10.160.2.107] (jabberwock.cb.piermont.com [10.160.2.107]) by snark.cb.piermont.com (Postfix) with UTF8SMTP id 31C2D2DE727 for ; Thu, 15 Jul 2021 14:13:42 -0400 (EDT) Content-Language: en-US In-Reply-To: <86mtqsoh3f.fsf@stephe-leake.org> Received-SPF: pass client-ip=166.84.7.14; envelope-from=perry@piermont.com; helo=hacklheber.piermont.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271271 Archived-At: 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