From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Sun, 6 Jun 2021 20:08:55 +0300 Message-ID: References: <75162ded-1ae5-6a12-f730-691edb96e5e0@yandex.ru> 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="14005"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 Cc: Daniel Colascione , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 06 19:10:24 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 1lpwI4-0003UG-AX for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Jun 2021 19:10:24 +0200 Original-Received: from localhost ([::1]:34700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpwI3-00052N-9X for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Jun 2021 13:10:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpwGm-0004Ga-12 for emacs-devel@gnu.org; Sun, 06 Jun 2021 13:09:04 -0400 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:44856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpwGh-0002pQ-2e for emacs-devel@gnu.org; Sun, 06 Jun 2021 13:09:00 -0400 Original-Received: by mail-wr1-x436.google.com with SMTP id f2so14657947wri.11 for ; Sun, 06 Jun 2021 10:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cIm6+5PXo7eGfI91rbiSoJ7z7uDfsFDKCzoY+IxMxVc=; b=JFvTlM9bOPU+UCE6Eg68nCdmZnjJcoezMbPfQAMyFcN7IMBCrLZyBVe5Mq9Wo9Ho1s 6NNC+mavxaKmgTX42GB2bTOpkd93vWoIwksGo43hpF6vxXgsQKllgJKlqNZWH0u28VQY tPqjqVIfiMTBoAePXqE5noEOc7BGuqvEz7X5Wi3j9Vi7hbGiqhdEiCVBouZZmD+Er5JS aKWxmVb6aZRUg3nAgIki3LuwG2B/QcIU1emWYfykKlKUbLh4AcEuypnQFnAEwCpbQyCA MCcIYS/hv5/FAYm5Ul49dLrgMftBEz6Yp6VNDQESQ7kNxTcXpEkbqX7RQCOxNSTVZAvf lkkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cIm6+5PXo7eGfI91rbiSoJ7z7uDfsFDKCzoY+IxMxVc=; b=AbE7ocwZ+XUDgSa+mzqo/0bxjbA0fiKWOLqJM8YrPUf48cSW+4nX6epjowD+28ZPdg lpN5uxidiPOw6pL7o9kUfUxtcvuKmQ+idZ8ML0njawMDVv+joExQeMsCiVcU5Adc2CqE 44OZVX4igi/EUVodIE7cwcooZsxUYIi6AW/0e6mrrbqyiXGTTTETnUXgL8tbtueJFN9J fUtKkaq8oaOC9NmeOaPAFYWl3vTprjXZsWjTynpg45/F3cHOeUJt1R7vc5Yy/mggy05V vDap5q0QnlHBNneR4vRydlKGGlvvmrrgQFkj2sqVSzHz9ADsZUx+tjYH00uNndgBTnDj IzkQ== X-Gm-Message-State: AOAM532hInsZsL/OhYTLpfUp/2l8uH328/TcnUAD7bSBNC48NuCfoUlz ZhyRc4jaGCapCfPd7yd1XQ4eOKbtu4s= X-Google-Smtp-Source: ABdhPJyavh/wmQDZF0eWdtqZGKpRjlimGKE56jcADArI3FBpFlvXDiPkeiMRWqxfYJXOeqxb8qF/Nw== X-Received: by 2002:adf:8b91:: with SMTP id o17mr13223750wra.385.1622999337643; Sun, 06 Jun 2021 10:08:57 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id l10sm13070902wrm.2.2021.06.06.10.08.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Jun 2021 10:08:57 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=raaahh@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:270485 Archived-At: Hi Alan, On 06.06.2021 14:53, Alan Mackenzie wrote: >> Would it work much worse if you took the approach of not applying the >> highlighting when you frequently cannot be sure of what the type of the >> term is? > > Cases of "not being sure" are common indeed. The whole of CC Mode is > based on heuristics. I would differentiate between approaches like need to parse around the callsite/usage site [of identifier] and need to parse the identifier's definition itself and, as far as Emacs major modes go, only used the first approach, plus perhaps some predefined/customizable list of built-ins. Because it's pretty much a given that in a big enough project a lot of functions/classes/etc will be defined in files that the user will never visit in the current session. >> That would mean none of the types in brackets would be highlighted in >> the original example, but perhaps that is still better than the current >> result? > > That would mean adding complicated decision functions for "not being > sure". If the fontification of types where they are used (as opposed to > being declared) were to become less common, people would notice and > complain too. Some might be relieved, too, seeing more stability of what is highlighed and what is not (and when). > There's the idea I proposed in my post to Daniel C of today - when a > type is newly recognised, then go through the buffer fontifying > occurrences of it. That would probably help a lot, possibly at the cost > of slowing the mode down a bit. What about the types that are defined in files you never visited?