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: Tree sitter support for C-like languages Date: Mon, 14 Nov 2022 21:54:01 +0200 Message-ID: <8d36534e-7fad-fde2-5cf0-ce7c42d4ee35@yandex.ru> References: <87tu36em9t.fsf@thornhill.no> <45FD2F78-F15B-488B-9348-A8E298D8AD35@gmail.com> <87v8nmyqqp.fsf@thornhill.no> <834jv4nz2g.fsf@gnu.org> <871qq8hsj1.fsf@thornhill.no> <83iljklzmo.fsf@gnu.org> <87v8nkgcqj.fsf@thornhill.no> <87sfiogcbm.fsf@thornhill.no> <83pmdrkyj7.fsf@gnu.org> <87v8njw5th.fsf@thornhill.no> <83leofkwjm.fsf@gnu.org> <9E9244D3-2EFB-4621-91E0-FC8B8C1C2D52@gmail.com> <09869DDB-2C3D-4064-81B0-0E6902C46396@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25660"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: Eli Zaretskii , Theodor Thornhill , emacs-devel , monnier@iro.umontreal.ca To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 15 02:27:23 2022 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 1oukjT-0006UQ-MQ for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Nov 2022 02:27:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouiio-0002Kv-MI; Mon, 14 Nov 2022 18:18:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouieM-00039s-Tk for emacs-devel@gnu.org; Mon, 14 Nov 2022 18:13:59 -0500 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oufXB-0002Mf-CN; Mon, 14 Nov 2022 14:54:22 -0500 Original-Received: by mail-wr1-x42e.google.com with SMTP id w14so20257463wru.8; Mon, 14 Nov 2022 11:54:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=oOf3y38OIMVHEaKHwCw793bljZWSOSikbt+OGAlpOI8=; b=fac0hLonjyTuECRQQoLBueeRqgQgXGHdrjO/IeXT4OlVmSzh4FEgHGvwPVKne3yeMl NNojkBIUz7UjeQ7/cfVFUUjddxngo7cw4pZNA7zn56C9IAOiIg8UFLORZD3G+ZOJCE+I ve8p4CO+ABw9AaW4ryRhDV/yplea8Woy9mTnuui3KhwNNqRdHqf1X2yYhnSUk41jmEje fv4OseBaSNH7qFRUlltxG8QCn1T3va988q1j90ZVyAG5Qa/B8DQN+CsF2rhi7U7TlGKP 3+rJQ+rqRyloXPbqjr3QKgqxNLC7lvDReFg79RQuwVCROqIAfWvU+69+g9iiXysyYA+9 Qfgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oOf3y38OIMVHEaKHwCw793bljZWSOSikbt+OGAlpOI8=; b=ZIvu4aJNBEtVlgYDQHh9DAmRUgS0e4yNTBF5fuplb9yWLe2QcKkXg8HrqXc4D2bpTZ QYDuzt64+cXMvWmTJ/CCP8dVd/2HERGUKVm5QWdWnenlPbBWURlB+4AWRorBjtOpY6Rw SfOlM+R1WvsuU7vlotCxK4prQl+QFTZS9ahmQkPdwBwD5CcfzXuC73bQHoFPA5zahWc+ IaUhkJ1DpkUIH6UYp2WZUmAkhLlTOwP005kyeatDXXDv1v1pBnQCBldmJHG9v5/Dho4t XN71OSyD56+9F3DcAObVP/wLcypNWI2OgI85UnkzZo1kvHWn/Ju5F9b2M86X6Tk5zJai 5sPw== X-Gm-Message-State: ANoB5pn/MFCZy4R+SML+uHWm+zgZa60Prhc9i5/GsfcK+4+QBBN5JyKz FPmarRjLHJbobEwYDfY2FnE= X-Google-Smtp-Source: AA0mqf4xjIxr6rJ1WsHPWzHsHF5Eqd4Riw4mV6qsPcpzuy6E2b2VvRuRGAMj0FwfJU7GQ3mHyJD8PQ== X-Received: by 2002:adf:e78c:0:b0:236:704f:29f4 with SMTP id n12-20020adfe78c000000b00236704f29f4mr8847117wrm.11.1668455643619; Mon, 14 Nov 2022 11:54:03 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id h8-20020a05600c2ca800b003b4a699ce8esm19790687wmc.6.2022.11.14.11.54.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Nov 2022 11:54:03 -0800 (PST) Content-Language: en-US In-Reply-To: <09869DDB-2C3D-4064-81B0-0E6902C46396@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299816 Archived-At: On 14.11.2022 10:35, Yuan Fu wrote: > > >> On Nov 13, 2022, at 5:26 PM, Dmitry Gutov wrote: >> >> On 14.11.2022 02:22, Yuan Fu wrote: >>> So if we want the warning face to automatically disappear, we need to record these warning faces and remember to come back to refontify them later. We need to know when to refontify them, and know when to stop trying to refontify them (maybe the error isn’t transient). For now I think it’s best to just not fontify the error nodes. >> >> I'm guessing the situation could be the reverse as well: after the user typing some chars, the warning would need to be *added* rather than removed, in some cases. > > That’s a good perspective. But from what I see I think it’s best not to fontify these “errors”, at least for C and C++. Because a lot of things could be marked “error” in a C file, like stuff around macros. And in extreme cases the whole file is marked “error”, even though if we ignore the error everything is parsed fine. I guess tree-sitter isn’t happy about some tiny thing in that file but never the less can parse everything correctly. I attached that file below. Perhaps not in C/C++, but other langs could use them. Also (and here I'm really guessing, not sure what the limitations/benefits of TS grammars are) there might be other nodes which could change due to the user writing or deleting code on subsequent lines. >> Any chance tree-sitter gives you some info/callbacks to convey the earliest node (closes to bob) which has changed after the most recent buffer modification? So we'd refontify starting with its beginning position. > > Yes and no, I explained in more detail in another message. If you're referring to this grandparent message: > jit-lock doesn’t know it needs to be refontified ...then I suppose it's a matter of letting it know somehow. I haven't read the TS integration code yet, so I'm not sure at which level it integrates with jit-lock. But jit-lock-functions are allowed to fontify more than the passed in boundaries, for example.