From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Fri, 4 Jun 2021 15:54:06 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24139"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 04 18:12:33 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 1lpCQv-00061m-6m for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 18:12:29 +0200 Original-Received: from localhost ([::1]:45184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCQu-0001PG-6a for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 12:12:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpC9F-00050E-HF for emacs-devel@gnu.org; Fri, 04 Jun 2021 11:54:13 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:58875 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1lpC9D-0000Uu-4b for emacs-devel@gnu.org; Fri, 04 Jun 2021 11:54:13 -0400 Original-Received: (qmail 71904 invoked by uid 3782); 4 Jun 2021 15:54:07 -0000 Original-Received: from acm.muc.de (p4fe15a70.dip0.t-ipconnect.de [79.225.90.112]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 04 Jun 2021 17:54:06 +0200 Original-Received: (qmail 15286 invoked by uid 1000); 4 Jun 2021 15:54:06 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de 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, 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:270389 Archived-At: Hello, Daniel. On Thu, Jun 03, 2021 at 20:16:53 -0700, Daniel Colascione wrote: > As long as I can remember, cc-mode fontification has felt totally > random, ..... Hmmm. It is anything but totally random. > ..... with actual faces depending on happenstance of previously-parsed > types, ..... Whether a type is recognised as such depends on that, yes. It's hard to think of a better way without having the resources of a compiler, particularly for ill-behaved languages like C++. > ..... luck of the draw in jit-lock chunking, ..... That should be a thing of the past, much effort having been put into eradicating such errors. That is one of the main reasons for the relative slowness of CC Mode, as compared with, say, Emacs Lisp Mode. > ..... and so on. And so on??? > Is there any *general* way that we can make fontification more robust > and consistent? Like other people have said on the thread, rewriting CC Mode to use an LSP parser. Less drastically, it would be possible to fix the specific bug you allude to, by the user making a list of types and configuring CC Mode with them, rather than attempting to recognise such types. This feels as though it would be tedious to use, though. > For years and years now, I've been thinking we just need more > deterministic parser-and-based mode support, and I still think that, but > on a realistic level, that doesn't seem to be coming any time soon. What does "parser-and-based" mean? > In the meantime, is there any general approach we might be able to use > to get stuff like the attached to stop happening? Probably none that we'd like. Fontifying types only at their point of declaration would be one, but I don't think people would want that. My impression is that the approach taken by CC Mode, like that of most language modes in Emacs, has pretty much reached the limits of what's possible, and it is unreasonable to expect perfect fontification (and indentation) from languages like C++ in all cases. -- Alan Mackenzie (Nuremberg, Germany).