From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 01 17:32:12 2025 Received: (at submit) by debbugs.gnu.org; 1 Sep 2025 21:32:12 +0000 Received: from localhost ([127.0.0.1]:58698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utC8K-0007yT-7L for submit@debbugs.gnu.org; Mon, 01 Sep 2025 17:32:12 -0400 Received: from lists.gnu.org ([2001:470:142::17]:49566) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1utC8I-0007yB-EI for submit@debbugs.gnu.org; Mon, 01 Sep 2025 17:32:11 -0400 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 1utC8B-0003qn-7p for bug-gnu-emacs@gnu.org; Mon, 01 Sep 2025 17:32:04 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1utC87-0000ez-1u for bug-gnu-emacs@gnu.org; Mon, 01 Sep 2025 17:32:01 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3b9edf4cf6cso3976909f8f.3 for ; Mon, 01 Sep 2025 14:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756762317; x=1757367117; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=87e+WNE7KskdH4gs7MfUXGxJFsLy7W0BIXTsMRsmckM=; b=IxD5aMTcE0rKWaRtlQNlVGwoY+gzoeH0LYPSRsQuEiPxbJTNBViH6omcAPgH21v9Aq rJ8Qavk3bkNJP1ABWkpjkYzWK3PhvWb1CIu9eib+d9EOnR/xFDl7ielwskR3bQHM4zKO JXcZg2opiEfbbYTL+y9wrBxjrHpyNMq1HI2vSWiDaQ83lXSdjRVnQ9V5n+OOBAAtaT3G BqAE2vAH/rP0OGSO8/sVrWyM97p+Rw0IdfuUUvVTBvLiHORVCut7e9diiIBTE1BKNoMZ pI2Po4y7qWPet5ysFKN+Ecftg3xBvi4AjcvWb27vpX5Gc4CS6PRKzYfbO4KyM3X3Ipjl yHsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756762317; x=1757367117; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=87e+WNE7KskdH4gs7MfUXGxJFsLy7W0BIXTsMRsmckM=; b=rqsW5OOTQSycvMwPQIbjLAS/gIb71rdRnDkBObElqberqUzw2/pSyKdPVEmfoRoxfa YwcA1aRBBIrNgEooFZpKbDu0jZOl//dXeIToMHIPdjKhGZim2IaukryiqYptl7KaggSM LQIG4Pbkw0lQkYD8b2J5uZwc63ZmdNRNlD/dRDWvAT3ejLx6cx7RNytNEFfSKxPxwGuD dzoEroVYNJRxqsRrkkmCWyIJZE7s1RDrTXTQ20IMFWEy+nz6pOi2Dw0MoQ8CxlMnYJhH m3E9W0AuCOK0AYJ6VJoUVNy9B972aV99d/4TBO2tpeAxDTbaKDruGI50A/5zM5JwziFo kafw== X-Gm-Message-State: AOJu0YwxLFFeq7ozFJ8QZnFiRcSmCqqFfro4jXmsc7P4sn02kPbJyfTP CYPCiRHwuGrZW9l2xkoLSoX42Qa4RKf6BS5sV/AK91roQ8uCJLm+E0GEM7e3wA== X-Gm-Gg: ASbGncvETEr8iT4Vy0tTE8v1d9EmJvsVqUqLo0yKd5CRMF94JlDNkbARbyzV0eTUlg1 knt8SpB1f6LvyelUKKBRXUWA8DAB/30qIri9vGitkOmrv7qJoE6Zl43kgYoIL0c5aaWPhumekMC eXn5Gc8MnAKBqHjaWZ5x+1aU9jwHtOK1yj/ARFPFDXauPANUrl+EVA/5QiviJ8yRxS/yzjuc2l/ FuftlFMoEqOve0sgNMtvltG8MCAZ+dPuSDEOvML8rYkyMnZlhLe6G4Wr6RgKGxbbUt1JN3tCHya 23oEeT+dKfgkw8v56MzL2R7HhPzTBZ02zVtZv74N5FjnamSS1mA/NCHSGmtkGn+wN7j1x7cHiPu bG76QDCK92ZomOVq0yIWCqQ== X-Google-Smtp-Source: AGHT+IGAPY5Aj4LB8+Mo3bqkhaoAk4UO/reRWH9N8GY6a17pxFbLBHYClp8eM6oXix3pCNVbujSK4g== X-Received: by 2002:a05:6000:2dc7:b0:3c0:7e02:8677 with SMTP id ffacd0b85a97d-3d1df53ba96mr7170516f8f.62.1756762316871; Mon, 01 Sep 2025 14:31:56 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d64ba4ff83sm6309731f8f.4.2025.09.01.14.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 14:31:56 -0700 (PDT) From: Roi Martin To: bug-gnu-emacs@gnu.org Subject: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed X-Debbugs-Cc: Date: Mon, 01 Sep 2025 23:31:52 +0200 Message-ID: <87a53deu5z.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=jroi.martin@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Steps to reproduce: 1. Run emacs -Q --init-directory=3D/tmp/go-ts-mode-bug 2. Eval (setopt treesit-enabled-modes '(go-ts-mode)) 3. Open .go file 4. Answer y to the question Tree-sitter grammar for `go' is missing; install it? (y or n) 5. go-ts-mode emits the following warning and definitions are not highlighted correctly. =E2=9B=94 Warning (treesit-font-lock-rules-mismatch): Emacs cannot com= pile every font-lock rules because a mismatch between the grammar and the rules. This is most likely due to a mismatch between the font-lock rules defined by the major mode and the tree-sitter grammar. =20=20=20=20=20 This error can be fixed by either downgrading the grammar (tree-sitter-go) on your system, or upgrading the major mode package. The following are the temporarily disabled features: =20=20=20=20=20 - `definition' for go. In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.49, cairo version 1.18.2) Repository revision: 3c94ae5a37eac0191fe5d8bd85164b190ac10244 Repository branch: master I took a quick look and I think this is caused by the following issue: 1. `go-ts-mode--font-lock-settings' depends on the following functions: (defun go-ts-mode--iota-query-supported-p () "Return t if the iota query is supported by the tree-sitter-go gramm= ar." (ignore-errors (or (treesit-query-string "" '((iota) @font-lock-constant-face) 'g= o) t))) =20=20=20=20=20 (defun go-ts-mode--method-elem-supported-p () "Return t if Go grammar uses `method_elem' instead of `method_spec'." (ignore-errors (or (treesit-query-string "" '((method_elem) @cap) 'go) t))) 2. In this sceneario we don't have the Go grammar installed yet. So, `treesit-query-string' returns a `not-found' error. 3. Because of the previous error, `go-ts-mode--method-elem-supported-p' returns `nil'. Thus, the "definition" rule uses "method_spec" which is not supported by the default grammar (commit "12fe553fdaaa7449f764bc876fd777704d4fb752"). (defvar go-ts-mode--font-lock-settings (treesit-font-lock-rules ... :language 'go :feature 'definition `(... (,(if (go-ts-mode--method-elem-supported-p) 'method_elem 'method_spec) name: (field_identifier) @font-lock-function-name-face) Please, take this analysis with a pinch of salt. I'm not familiar with the code base. But I hope it makes sense. Roi From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 02 02:34:01 2025 Received: (at 79363) by debbugs.gnu.org; 2 Sep 2025 06:34:01 +0000 Received: from localhost ([127.0.0.1]:59535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utKaf-0007dl-6f for submit@debbugs.gnu.org; Tue, 02 Sep 2025 02:34:01 -0400 Received: from mout-p-102.mailbox.org ([80.241.56.152]:33426) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1utKab-0007dO-Im for 79363@debbugs.gnu.org; Tue, 02 Sep 2025 02:33:59 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4cGGCv5HB6z9tm4; Tue, 2 Sep 2025 08:33:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756794827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sShNKL22g2tSzDEYKKXO4PwgM5TgaHRFy4I0CYhHksE=; b=fHnYyx6Ib/h9THaLiAALOirTrpYjI8WWFy6DdQEkOqX77smFPGv14F/0A6qC0ZT1dG4TTi tIgjyGvw4CucEqny4jPW0oe/4XH4F0CFdIaCFYskEOr2sygK66/PwyRBzlHvIQfQihHXDE PBJpimHvRqQMzYkohtsz2W0NTzpf+bPuypAg/wNzN96k2e1vd5EJ4kz3smlMV10ZyHt++l tPt2B/jbL0lTRcfEs9+hQOG3cxzb7R55G2bAymHiNMYx/nUl6oyyEybKfsJrEP/PLJ7IN3 vQhd73pZMBjAv4zVz7HC/ZXdFuidTEizfolfe9/eeSX2Qa9ffOlm0/anjyIx0w== From: Juri Linkov To: Roi Martin Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <87a53deu5z.fsf@gmail.com> Organization: LINKOV.NET References: <87a53deu5z.fsf@gmail.com> Date: Tue, 02 Sep 2025 09:31:52 +0300 Message-ID: <871pop4b6v.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 1. `go-ts-mode--font-lock-settings' depends on the following functions: > > (defun go-ts-mode--iota-query-supported-p () > "Return t if the iota query is supported by the tree-sitter-go grammar." > (ignore-errors > (or (treesit-query-string "" '((iota) @font-lock-constant-face) 'go) t))) > > (defun go-ts-mode--method-elem-supported-p () > "Return t if Go grammar uses `method_elem' instead of `method_spec'." > (ignore-errors > (or (treesit-query-string "" '((method_elem) @cap) 'go) t))) > > 2. In this sceneario we don't have the Go grammar installed yet. So, > `treesit-query-string' returns a `not-found' error. > 3. Because of the previous error, `go-ts-mode--method-elem-supported-p' > returns `nil'. Thus, the "definition" rule uses "method_spec" which > is not supported by the default grammar (commit > "12fe553fdaaa7449f764bc876fd777704d4fb752"). > > (defvar go-ts-mode--font-lock-settings > (treesit-font-lock-rules > ... > :language 'go > :feature 'definition > `(... > (,(if (go-ts-mode--method-elem-supported-p) > 'method_elem > 'method_spec) > name: (field_identifier) @font-lock-function-name-face) > > Please, take this analysis with a pinch of salt. I'm not familiar with > the code base. But I hope it makes sense. Thanks for the analysis, it's absolutely correct. Manually re-evaluating `go-ts-mode--font-lock-settings' after installing the grammar fixes this. Thus we have to find a way to re-evaluate it automatically. The same problem exists in some other ts-modes, so the solution should be quite general. One idea is to turn defvar into defun that memoizes its return value. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 02 06:18:12 2025 Received: (at 79363) by debbugs.gnu.org; 2 Sep 2025 10:18:12 +0000 Received: from localhost ([127.0.0.1]:60145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utO5c-00028M-93 for submit@debbugs.gnu.org; Tue, 02 Sep 2025 06:18:12 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:49345) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1utO5Z-000288-Ko for 79363@debbugs.gnu.org; Tue, 02 Sep 2025 06:18:10 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45b8b7ac427so12273395e9.2 for <79363@debbugs.gnu.org>; Tue, 02 Sep 2025 03:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756808283; x=1757413083; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=S9aSiDyK9z87Hy/h3DXq0Y7yV5yRqBIyHyugLF0mIbY=; b=KryNq4A5cOdBA0ScIuPRcyjs/RUWgHTUVPiVxSrVpOpcG95HLoKD/7EN2FfNDpv5ul C5Y6iaAY9XU4jqhIMFKV/rPlTtNnZW2498L3LDG/QbwlqaBzzmox8ZLOA8f5hoLgGARn e+g0iobaA8yRIAyJJKIRZ6WKyzn4dNNmSozb6+cUMwbvAFFrSrGEM78RU/QUMwLHDNs2 lfsKulfwyXjau5IYIA5BL30KR6J6g6ae9AR5hZydED/CsEHkVTniAKldBrPMK99hGnrH oCRmWKtZHXKluBs4b4/MP9NGV+0Jm2YYSBtSv+0dWsTVRMWmK0TWOhbHllJy2gXPpO7y 928w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756808283; x=1757413083; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S9aSiDyK9z87Hy/h3DXq0Y7yV5yRqBIyHyugLF0mIbY=; b=kXXQ33pPcE6qG7jPoJ7fZH4XJhoua4STHdcOnqUZ2a9155wZwcEnkMY9tjm856AhS9 0/DNj9s7pgbqgC+if4YvKNPWYClwqtrNl5rduUKmvVzSKyda5I2vQXI0BdYY0LQMHtxF 2S+x5dR1ATjLIdJv2irI85ezlr85dbEdbdQhyE3y3Ed16gQjXIpbnYCiOOqxXFbv3EG/ 5/HzXUTKV4mu/qN+t8LKTeohbUcQPrrB1AgtyJ/6RPjqm0gJw6ZOxy8pkMz5H31zOfKD Z8TpuHGqeoDMAGWW6tStEMM81uZ8vsWUkMR5uOC0CLg9lWiqo+SNee4dI4tAYgideTLj ZUbw== X-Gm-Message-State: AOJu0YwTb/sVhbm5btO4uARYk/zbsjqF99g/6hJvODBA/uOlgHM1SOOG 4dpH7u6kbx4C4eIwvgXER5w63nliU7EIRvjwU4deXsktjAksrGG31ToX X-Gm-Gg: ASbGncuH2k3GIhSBmO6pg+V6lzew2/dD69kx1TByjVk4VPA3PZVPtYmghmN1w6p2cXW 5MgE4kuE18114Sv6HOEiYc0HOXsFuMUPi8cnzkK7nkodS0GHujZEDB/iOkWY4ka+XVQhkx9bFMu O7X1ndcHQv42vu9hPxCl2j+AKP7h96NUML3NrSai4XRf5/sOm6c395FAXPygLXtrMrRvOK+8czE wRB0oMBqzvYbqDQKj4uh3Z/E4Upg50BIlOhL1mmTfOelQPWDNkd+5bTHXsX5eBhbCx4Pz6XCrrp qs6StIV1kPQ1VcZuRLBZl4p1Jmz8NaBa3KKgP4DDb0O66Gs0/TugN7OWWeZeVg++EwHaE9QcvtP acYe0oUVZN1ytKT4sIqp8eQ== X-Google-Smtp-Source: AGHT+IEV8Dx6m8krDHjfgVa6IG1APd75pBHwnuAvFzw71YdKwvxsaTSDGsfoTS1SQCJ9VOSNb7zSug== X-Received: by 2002:a05:600c:3145:b0:45b:64bc:56ea with SMTP id 5b1f17b1804b1-45b8557055dmr88750455e9.23.1756808282887; Tue, 02 Sep 2025 03:18:02 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b8a980011sm61136335e9.0.2025.09.02.03.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 03:18:02 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pop4b6v.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> Date: Tue, 02 Sep 2025 12:17:58 +0200 Message-ID: <877byhdup5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > One idea is to turn defvar into defun that memoizes its return value. Do you mean something like this? (defvar go-ts-mode--font-lock-settings nil "Tree-sitter font-lock settings for `go-ts-mode'.") (defun go-ts-mode--font-lock-settings () "Return tree-sitter font-lock settings for `go-ts-mode'. Tree-sitter font-lock rules are evaluated the first time this function is called. Subsequent calls return the first evaluated value." (or go-ts-mode--font-lock-settings (setq go-ts-mode--font-lock-settings (treesit-font-lock-rules ...)))) (define-derived-mode go-ts-mode prog-mode "Go" ... (when (treesit-ensure-installed 'go) ... (setq-local treesit-font-lock-settings (go-ts-mode--font-lock-settings)) ...)) I tried and I can confirm it works fine. I can work on a patch for all the affected ts modes if you want. BTW is this a common pattern? If it is, does the Elisp core library provide something similar? At the end of the day it is a sort of "lazy defvar", isn't it? Roi From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 02 07:24:43 2025 Received: (at 79363) by debbugs.gnu.org; 2 Sep 2025 11:24:43 +0000 Received: from localhost ([127.0.0.1]:60579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utP7y-0006KK-NU for submit@debbugs.gnu.org; Tue, 02 Sep 2025 07:24:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56256) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1utP7v-0006K0-If for 79363@debbugs.gnu.org; Tue, 02 Sep 2025 07:24:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utP7p-0000HJ-VH; Tue, 02 Sep 2025 07:24:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=leBvbvJJv4NBYkNDSgkEnDB0+l+2rTFP4wMD6JVIlCc=; b=gLCwykVQbr5IQZRIS2bk 45qq8eAH97q1fzPB6v24JTEr39JM7o2ND7KCGOffQdD5BBISLesaBVZb7139ebAzP6Si8a1tN2CH+ rAk9SnyIbzxcTpBSI6mmGaLQVe9k0A/K+BgzOyHA2JquiWHAOttm2OpypqgPSMJNjXGQsiJPM7VVq ArSPhsejoyKSqtA0PSOZtsFEo1E9Cvs/apQi+l1wgQZfuwomrLHbnCMqEOESLF1yhW/cGG896OMT0 uI35JwdJm8Ylx8hFpYhO+4iIWK91PsLxRKOp3wnoovXTL0+Y/LSlhT8ocRKeCoj9oUFfRnyYbqiAo 6DMf6VO8A6TAPg==; Date: Tue, 02 Sep 2025 14:24:30 +0300 Message-Id: <86a53dm70x.fsf@gnu.org> From: Eli Zaretskii To: Roi Martin , Randy Taylor In-Reply-To: <87a53deu5z.fsf@gmail.com> (message from Roi Martin on Mon, 01 Sep 2025 23:31:52 +0200) Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed References: <87a53deu5z.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79363 Cc: Yuan Fu , 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Roi Martin > Date: Mon, 01 Sep 2025 23:31:52 +0200 > > Steps to reproduce: > > 1. Run > emacs -Q --init-directory=/tmp/go-ts-mode-bug > 2. Eval > (setopt treesit-enabled-modes '(go-ts-mode)) > 3. Open .go file > 4. Answer y to the question > Tree-sitter grammar for `go' is missing; install it? (y or n) > 5. go-ts-mode emits the following warning and definitions are not > highlighted correctly. > > ⛔ Warning (treesit-font-lock-rules-mismatch): Emacs cannot compile > every font-lock rules because a mismatch between the grammar and the > rules. This is most likely due to a mismatch between the font-lock > rules defined by the major mode and the tree-sitter grammar. > > This error can be fixed by either downgrading the grammar > (tree-sitter-go) on your system, or upgrading the major mode package. > The following are the temporarily disabled features: > > - `definition' for go. > > In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.49, cairo version 1.18.2) > Repository revision: 3c94ae5a37eac0191fe5d8bd85164b190ac10244 > Repository branch: master > > I took a quick look and I think this is caused by the following issue: > > 1. `go-ts-mode--font-lock-settings' depends on the following functions: > > (defun go-ts-mode--iota-query-supported-p () > "Return t if the iota query is supported by the tree-sitter-go grammar." > (ignore-errors > (or (treesit-query-string "" '((iota) @font-lock-constant-face) 'go) t))) > > (defun go-ts-mode--method-elem-supported-p () > "Return t if Go grammar uses `method_elem' instead of `method_spec'." > (ignore-errors > (or (treesit-query-string "" '((method_elem) @cap) 'go) t))) > > 2. In this sceneario we don't have the Go grammar installed yet. So, > `treesit-query-string' returns a `not-found' error. > 3. Because of the previous error, `go-ts-mode--method-elem-supported-p' > returns `nil'. Thus, the "definition" rule uses "method_spec" which > is not supported by the default grammar (commit > "12fe553fdaaa7449f764bc876fd777704d4fb752"). > > (defvar go-ts-mode--font-lock-settings > (treesit-font-lock-rules > ... > :language 'go > :feature 'definition > `(... > (,(if (go-ts-mode--method-elem-supported-p) > 'method_elem > 'method_spec) > name: (field_identifier) @font-lock-function-name-face) > > Please, take this analysis with a pinch of salt. I'm not familiar with > the code base. But I hope it makes sense. Thanks. Randy and Yuan, could you please take a look? From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 02 12:59:46 2025 Received: (at 79363) by debbugs.gnu.org; 2 Sep 2025 16:59:47 +0000 Received: from localhost ([127.0.0.1]:36377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utUME-0001z7-Hz for submit@debbugs.gnu.org; Tue, 02 Sep 2025 12:59:46 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:59494) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1utUMC-0001ys-6n for 79363@debbugs.gnu.org; Tue, 02 Sep 2025 12:59:45 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4cGX5y3hC1z9tbV; Tue, 2 Sep 2025 18:59:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756832374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KpSzoqDOvUgLZ54qhahmzsEiWpwd002RWOZSBPBJqxw=; b=QTj/d5VU2mt2ad5AQfwPi/wfFn6QmL/x1T5SWnULRDLKZBq62ib6y4TmaksszOtkZ4WsW7 qFjfUlWOHvPzzV/nCOdI++DhQmTKJkIHszeKgQ5b7ga9b0ZIHS3d3pnVL5hiyfFcdmeGU1 KIjouCzg0ecKTZFyLdRG/xdR2WFW0dP9AqHIWCECoHPhvH1gIRHpwz44LnbR9aZ7vGAm7o vkcN1T6l8sVqhh0ctioFm5BVLP1ZveJcHKQRJWjs3t3Jg+Xfmkf3ruZHSyLV+BwUW32uNP lT9ysErOmaIdgamCZgfYr7Sir42J0DoqYyoDzq4tH/BS2NszmlbqkT//wyQHRQ== From: Juri Linkov To: Roi Martin Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <877byhdup5.fsf@gmail.com> Organization: LINKOV.NET References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <877byhdup5.fsf@gmail.com> Date: Tue, 02 Sep 2025 19:56:51 +0300 Message-ID: <871poo3i98.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> One idea is to turn defvar into defun that memoizes its return value. > > Do you mean something like this? Exactly. > (defvar go-ts-mode--font-lock-settings nil > "Tree-sitter font-lock settings for `go-ts-mode'.") > > (defun go-ts-mode--font-lock-settings () > "Return tree-sitter font-lock settings for `go-ts-mode'. > > Tree-sitter font-lock rules are evaluated the first time this function > is called. Subsequent calls return the first evaluated value." > (or go-ts-mode--font-lock-settings > (setq go-ts-mode--font-lock-settings > (treesit-font-lock-rules > ...)))) > > (define-derived-mode go-ts-mode prog-mode "Go" > ... > (when (treesit-ensure-installed 'go) > ... > (setq-local treesit-font-lock-settings (go-ts-mode--font-lock-settings)) > ...)) > > I tried and I can confirm it works fine. I can work on a patch for all > the affected ts modes if you want. Thanks, this would be nice. > BTW is this a common pattern? If it is, does the Elisp core library > provide something similar? At the end of the day it is a sort of > "lazy defvar", isn't it? At the moment I don't see a better solution. For example, like the existing `with-eval-after-load' we could add `with-eval-after-grammar-installed' with some hook called when the grammar gets installed, e.g.: (defun go-ts-mode--font-lock-settings () (with-eval-after-grammar-installed 'go (setq go-ts-mode--font-lock-settings (treesit-font-lock-rules ...)))) But even with this additional complexity its usage is not simpler than you suggested above. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 03 04:52:39 2025 Received: (at 79363) by debbugs.gnu.org; 3 Sep 2025 08:52:39 +0000 Received: from localhost ([127.0.0.1]:38515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utjEM-0001t7-WF for submit@debbugs.gnu.org; Wed, 03 Sep 2025 04:52:39 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:46387) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1utjEL-0001sm-1X for 79363@debbugs.gnu.org; Wed, 03 Sep 2025 04:52:37 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45b627ea685so52684175e9.1 for <79363@debbugs.gnu.org>; Wed, 03 Sep 2025 01:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756889550; x=1757494350; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=B8WOvIMcYFL2YEcBW13aKCQLnxTFhke7oxdDDq4K04g=; b=f/BO9ngIJty/b/sUzXPopYgvY9UFzIBbx4wWsCCrBI/+akIRjUZk58u12fqCjwjJZ7 HQC+6kf2ohQdkIMUNCXX5SmOyvFXc7AkpDwMM5k4kyMOyPzLI/3n7QehzqVkzTnUrisC byIoAgONAe5JSEH+6Qr+6uXCeK4Ykk9F1hydHBxVy2PBUG8lr0fgTZWhB/F21xY8Sc2u g1Q3NSK/FcmWemDWZnePZWub7Kv25kM1Pkguoa5icPhf1y4AebxTWIriSre9n9ykHTKF f1gj4NjDVP5zHZjAHFPc34/Zn4kgPdZwu/q/AV0ctXPiZPzzo3yCx5TiWtHFWbzhCn3j VOmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756889550; x=1757494350; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B8WOvIMcYFL2YEcBW13aKCQLnxTFhke7oxdDDq4K04g=; b=Ae8s6d2xXhWQKbhDrUtUS4aLGomKH92ZwDFFjFfNiuI3yWTs+gJqQMfN2ySZs17we0 yZMbwL6Ej6hyDOdcHWVsL7YxIci/Rj4Hj/yaDThTh0t2x7dB8ppJVCPQwLb54msAA5cJ QU7pQsMuz+wvOsdvy5iQ4vU3etKoEbMEUCm55/nx3yoTNCgzNRthjPM90p8s8AxGMjiM KgLaPjgCG5pwtiOZ4gphWmbvd8BpxEtPmpgFMoVo+N9G4kPzQPh3q4kTu7BmhtJ2wa5+ b9H+b0YUT7NwNuE6Ji2BXECvJwCyyRsO93YRBEiHQg3DrSk1WA39tJJMYIlVV1cQGoUx Sn6Q== X-Gm-Message-State: AOJu0YxgzC+LjJHIEM/A+0jv5pY95vekztH0xCiJ8o7SpGc+RJds+Slr vnpmyO8S4hAMoW2zJt0eXDJfpsPHnPT/ONDN8ruJCb2DRYKeZIMqcfqN X-Gm-Gg: ASbGncuhIEV1OnhJnUd72IhR+ZytuThFP5T6jsUf324hxxqPkoKufSMvDpprRHlxQEA O9lfvFPoCzc2wn/gGwvWbDL8gb9sLbNU5h2VktFVK/N5lkPJCAU0d7nOu8R2xkHedPgFVpaJRnV NKbevNODdxGgyTuBodR1z51Cg54OkQW45X6GM53c3bb5T6K56lBWWqtxl06ZZrKOmdFNuT7YlVP z/Og3XlU14f8PN9i8oJfsgogU4GHrNScQ1p2VOUR2xK1sgdom3/s/P2b/6Nf2VYgGGBKMW1MH0c UV4T7loqDm4MUkonlWDctCUs6iZUUs2IpTOVfzi6RPqFg6yFBkIteFKmAc512KvrRcvohfRes6N Jj5i9PYaGoQWKYB/W+RCh95jxw4sCSLBf X-Google-Smtp-Source: AGHT+IHh+71T0xrJngYLWxjfxOWMd0dkOf2kP9zO9xP0n3Gw+EZ2QyW6fynhVHuLKWNh7abI9pgreQ== X-Received: by 2002:a05:600c:1e87:b0:45b:47e1:f5fe with SMTP id 5b1f17b1804b1-45b855c0d3dmr100654915e9.34.1756889550301; Wed, 03 Sep 2025 01:52:30 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b814da51esm208209625e9.8.2025.09.03.01.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Sep 2025 01:52:29 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871poo3i98.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <877byhdup5.fsf@gmail.com> <871poo3i98.fsf@mail.linkov.net> Date: Wed, 03 Sep 2025 10:52:25 +0200 Message-ID: <874itjex4m.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> I can work on a patch for all the affected ts modes if you want. > > Thanks, this would be nice. Great. I'll try to send a patch during this week. Roi From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 06:04:52 2025 Received: (at 79363) by debbugs.gnu.org; 4 Sep 2025 10:04:52 +0000 Received: from localhost ([127.0.0.1]:45679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uu6pn-0002NX-MI for submit@debbugs.gnu.org; Thu, 04 Sep 2025 06:04:51 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51626) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uu6pj-0002NC-Tn for 79363@debbugs.gnu.org; Thu, 04 Sep 2025 06:04:49 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45b87bc67a4so6111355e9.3 for <79363@debbugs.gnu.org>; Thu, 04 Sep 2025 03:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756980280; x=1757585080; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Fc+sWZB6bpWKpg6MoCae+V1yiwtiikZt8fNXNE7cWPo=; b=Jg0RALpDTyiIsw/M3jPt0NNUj31nK+a7fhyDuvoqHTWA22myScgc/5sJjc4HSyo5dJ ScRUg2Ooc5d0vT6E6DHwREeMNYKEpLT/WdQnlKhOIPv0pqU3j44bwbJcWi5xfJwxSTGh aG+C0ZdY3gw5cGRQhICwp0HbJYJMjVeJWowEwvaRdcq2e8BZTvxKx7G87wMJ+LFshWyq NFQ3XQqucfEHQuh1gqtaWBuVtt0ugHmtiP8uPLQSjH1CCrJ679zEos1Vq8qUZMTPpAQX 9NdcgMYbXBAXxnCj/MxdSstLFuI9568Hlpma88qq2Z/RCFGy8ZkOoWWuHpSGih+pGmJY aeCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756980280; x=1757585080; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fc+sWZB6bpWKpg6MoCae+V1yiwtiikZt8fNXNE7cWPo=; b=StrEe8u8ZiS73fcnoNu7rQPmQIKUKkeWeHlzeg2X3ef9TPXjdy44DVdQBJkZD81sU+ qxEvHcz3iGnyqPE4zLuuStjay+x4RxNsNjdTzpdP4euGsiFo8hHOPdt83GPTaYsT8wzq ksWb6Ct6+okXVkQgdvw9I/EXyHgnQkiZF8gMvvu1EpbFBPNRwcLuNJPwUW+wLBKqR/7r MVGcSdzFAlglQZ/hG1NpkLoPlyGBkVFl9CfIEz5mUe1BjQd/i4yr37TbzYC+0fQp6+Du CM4en+0R7IdK0DvAVEEYoBKZ159+KQRe7Ku8UdTdkgLxuZM2Ffdm1ilgl1zTHqhPMbGr L9IA== X-Gm-Message-State: AOJu0YxrNHBR5aXVgvXS1nVr3UleDqnrTjogp4bawrlRrGh3rBywSh22 OKucWH85ouc4USO154xwjNFYuQxcPAf1zSbPv1gTizqV9A/EIuwCRP2x X-Gm-Gg: ASbGncsl8ufu0V8eAF8YYRi5lDL2ZOS69Fs45ILFL9mQgxEXIf3b+LhNHrrWDqAfHgt 2w1w6A2c1ALC6Ux0Xu/A13Ga8RsIlt+vk/wC5rgCsc8IhyBQFaA0JkJZdDnJ/mv1+uH+NhHmXIE wqLJFAtUcQZtq9YFghp+WIfocahPgkQOtacU1RRAr048PsWTEnKWUIKErdDV4jLbRS7qXP7iHLu xIEQG+22b7KdUhHi63clUPOs3Wl6aOEFms3gTjwOvPUB0rkDshQB4Qt6eOMuqww2AlOFX2QQL/q w/dTxKeGWXJA52tks76VrZ3NESQht3e3hSYX3MPm5eEOASB7z/8jMgcWPaGFObQTNYSplgSj7Lj zGUCWbF6m7yjrAtbDzsiLzg== X-Google-Smtp-Source: AGHT+IE2HJZiQNnV6NXx06sfKqtP47mEEjQDvDpSMmIHuqS+TscMBipGWzPkzEuA3dAEX62aAChcLg== X-Received: by 2002:a05:600c:1c23:b0:45b:8914:7a9d with SMTP id 5b1f17b1804b1-45dd2439301mr9012415e9.36.1756980279681; Thu, 04 Sep 2025 03:04:39 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d21a32dbc5sm24278367f8f.11.2025.09.04.03.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 03:04:39 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <874itjex4m.fsf@gmail.com> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <877byhdup5.fsf@gmail.com> <871poo3i98.fsf@mail.linkov.net> <874itjex4m.fsf@gmail.com> Date: Thu, 04 Sep 2025 12:04:34 +0200 Message-ID: <871pomedot.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Roi Martin writes: > Juri Linkov writes: > >>> I can work on a patch for all the affected ts modes if you want. >> >> Thanks, this would be nice. > > Great. I'll try to send a patch during this week. Hi Juri, I'm going through all the tree-sitter modes checking that automatic grammar installation works as expected, reviewing the relevant code and fixing the issues I find. The thing is that merging everything in one single patch and reviewing everything together seems a bit too much. For instance, I found issues in elixir-ts-mode and heex-ts-mode that we would probably want to discuss separately. Are you OK with splitting the patch per ts mode? That would also allow us to fix things incrementally instead of having to wait until every single mode is fixed. What do you think? Can we use this bug to keep track of all this work? I would really prefer to split it. So I can also "split" the work better. BTW I already have some patches I can send. Thanks for your help! Roi From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 06:35:38 2025 Received: (at 79363) by debbugs.gnu.org; 4 Sep 2025 10:35:38 +0000 Received: from localhost ([127.0.0.1]:45826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uu7Ja-0004Rq-EL for submit@debbugs.gnu.org; Thu, 04 Sep 2025 06:35:38 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:49300) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uu7JU-0004RU-5u for 79363@debbugs.gnu.org; Thu, 04 Sep 2025 06:35:33 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3d965477dc0so608043f8f.2 for <79363@debbugs.gnu.org>; Thu, 04 Sep 2025 03:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756982125; x=1757586925; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=h4TF0XDF93VfJij1v1Zx9DZyClxv/0qtiCGO6oLebAo=; b=DnDJ93mGQGo7n3qbUqKTNcRiiOrU1a8JxHcfsXHo/X/HjwRnIPTt2SKoSFmLoBOrXP hfLXG4T0myKSmsqqF5WOKN58Zb1MhCDnu2WV+QkbzG4Tl20xURFGb8qzfP/inL+lbeSW zBX57EOhSOOgnYwCvczWNc693dY1bX1tDzuJwP+aes7wvjCyChbvPvDYbHW3dXcMUwYU 2VNck0bkxvFcR1pwb8HyhpK4CQnBJbC0m4cXoxZ/IstbAvnwgEeCGuIIQgOClu2lAW+1 DunSY48Or1Wi6QWEegmTQRgo0dhBO0jp4pdu3lwecT1DwdLllxHPohqRDWEx2txvoRpH h47g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756982125; x=1757586925; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h4TF0XDF93VfJij1v1Zx9DZyClxv/0qtiCGO6oLebAo=; b=iIGsuo4cUxvfFW09WODNyEx7xh7Bw0I4LsixonbSTWZS6tQmEFuEqgYuL0UQ+qlZlG 6EL0u6QJAGtmjclbA2ydZKE0+ov1QetifDnO0byc+Gbcht+zpjaazOEI/f03PE78tLHZ OE7bs3Lj1ZhPR8hNTRUq0VwhHBNRbYLBso92Z0slcMPYvHJBX50ZAaKFr7De/eVWVb2W EKX54fHK6M/YnzzyoeZvxPwoNouSg0Ap1ubZEuSEPJ3eAzmNEGU9IsNbd/H+nGblF2m3 SN3RRhJdDL5aQumtGQSVh0zEjtPhRrW3GpIeAj2WZNZjJrzkdr6N5LnTfXhp7o/j5UIy Q6Fw== X-Gm-Message-State: AOJu0YynyYttC2xlAOrt6n7du7S7QomlgXemVddYNJ7XWzQPJbPPs4Ah 5F3bApH8UGQUInmqQ/SDkbBZh0Ih7XtF4jITXA/ac/2u8YGcqi//Mk5FSRz/aw== X-Gm-Gg: ASbGncs/ZuZWTscw3OHCb8+4wPvWNHflDX1NEFRqAeJDEY+0xkny0+kDOpnmN4chjcy 9qOLvrEhZEXgR5j/OY9Ipd+XPOOUH42bM7qO2YEpbHDeH35PyTM2QyDKvM5o8WtP0YPLoiOVcUC 2sQG//Sl69r3vIIBgskb8YvVZbpQ11UE5stTp97ivx3u2dLrcU5T/t+PhzbVlPG6TXDfzpbn05T XLgV/IBRC03tvapytUt++0ZlBsBCNJ776RoQvG7qVnFS+1YZcfgRdZJxnswDCdpOc8FRdJ1Z76x HCAc23vKOnyXjFbLwFgKDmJPqSEpbPK1/OjXcl/ocyL18eCG/UTQoKS9/aytPXkGZItyXewYiDr 5DeC2kIW4T0CSri9BxR3Lrx+E/4i0vtVr X-Google-Smtp-Source: AGHT+IEV3sTxN/JCzY8rsLUpsF3xPju3ZoaY7zOdjqgvErFSmevuXusgA6DJ1l+NLq9bTSpWHCh87A== X-Received: by 2002:a5d:5d10:0:b0:3d4:1acb:aed1 with SMTP id ffacd0b85a97d-3d41acbb238mr11211107f8f.44.1756982124980; Thu, 04 Sep 2025 03:35:24 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d729a96912sm15059406f8f.8.2025.09.04.03.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 03:35:24 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pomedot.fsf@gmail.com> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <877byhdup5.fsf@gmail.com> <871poo3i98.fsf@mail.linkov.net> <874itjex4m.fsf@gmail.com> <871pomedot.fsf@gmail.com> Date: Thu, 04 Sep 2025 12:35:23 +0200 Message-ID: <87wm6ecxp0.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Roi Martin writes: > I would really prefer to split it. I meant splitting the patch. Having one single issue in the bug tracker for me is OK. Sorry for the noise. Roi From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 02:24:02 2025 Received: (at 79363) by debbugs.gnu.org; 5 Sep 2025 06:24:02 +0000 Received: from localhost ([127.0.0.1]:50642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuPrd-0001rp-Kv for submit@debbugs.gnu.org; Fri, 05 Sep 2025 02:24:02 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]:59770) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uuPrb-0001rT-3S for 79363@debbugs.gnu.org; Fri, 05 Sep 2025 02:24:00 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4cJ5s04RWXz9tg3; Fri, 5 Sep 2025 08:23:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1757053428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y+nPWyp68OknYQe0u6JB/W//i2s8SRImKhBiURJ2k7w=; b=rUAwSBdh4owl2GsCrC4upOXS9wNX/ZDoVxSDkyXXylvmPG/CwtkHmO8nr6KFfUgZAGQr2L h1F7s0+YDBpikSRpg7NDT8+51Exk/rthIrLTO6v44N461QRTja04sNcsHwVF9ULm8fgfKh KwDgFIiHU/ezmKaCp4CnsVVGQxrLK2x8KN8w3p1ZfalgFd5UL6pdvM/80nYi+wAtnHLS1g yFG8kPsPZbtNHc6A0NbTR61E9jnOGKQ1FmM/yyyGHTPNt75acy7uGJNTgvBFCmnEUnfPOq 8MeYioR5isq8zldnwe9v+15jiamn6WUqDtSCcAbX8QKVwtzT4bg6XLer75gfug== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: Roi Martin Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pomedot.fsf@gmail.com> Organization: LINKOV.NET References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <877byhdup5.fsf@gmail.com> <871poo3i98.fsf@mail.linkov.net> <874itjex4m.fsf@gmail.com> <871pomedot.fsf@gmail.com> Date: Fri, 05 Sep 2025 09:10:50 +0300 Message-ID: <87bjnpa23h.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4cJ5s04RWXz9tg3 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I'm going through all the tree-sitter modes checking that automatic > grammar installation works as expected, reviewing the relevant code and > fixing the issues I find. > > The thing is that merging everything in one single patch and reviewing > everything together seems a bit too much. For instance, I found issues > in elixir-ts-mode and heex-ts-mode that we would probably want to > discuss separately. Are you OK with splitting the patch per ts mode? Splitting the patch per ts mode would be nicer to review. And you can send all patches in the same current issue. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 04:56:32 2025 Received: (at 79363) by debbugs.gnu.org; 5 Sep 2025 08:56:32 +0000 Received: from localhost ([127.0.0.1]:51240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuSFA-0002ln-37 for submit@debbugs.gnu.org; Fri, 05 Sep 2025 04:56:32 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:50205) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uuSF3-0002kY-H7 for 79363@debbugs.gnu.org; Fri, 05 Sep 2025 04:56:22 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-45b7d485173so12642275e9.0 for <79363@debbugs.gnu.org>; Fri, 05 Sep 2025 01:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757062574; x=1757667374; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=NY+CGb+XgcEX0sntf1OLV4gkYhKmKD3TWe7+Pvu6G+I=; b=EKHPtBevpMntWu2fDLGIQX0c6sv/HGY3w5eqjAMzBfWdz785UqNYaQIiIgX993d7KX aicRm1ATmYUYR9Ab9GQ4y1j8c5ud5X0jJbb9E47JxQpKluz81fzVGVzH/p+EHw9/BmlE 25y3fibO8JSd2Kx9EyG9n2ZrVUoB8C+hJK7MUP1sWvbMgWzS7+/3xFTKU7X/tgn4hS1d Q4Hojplwrom8Z82ZUZ4APcRGyvn26IH03fujfT3JfCudZ7/G4QBjw2uN7z5yNUPhy1az uM4nIvn5KQKOq2XFl8MY+z0iSBeWP2ZYCj2cUs6iHSAZx5wXyJ9iQ3nJS1I0/6UNHHOY MNsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062574; x=1757667374; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NY+CGb+XgcEX0sntf1OLV4gkYhKmKD3TWe7+Pvu6G+I=; b=lvmw5Mzg+V+JzlX427zz+oTk4SdZc33cjy/ZLyVAJLm6/psopOnnEhPrDqEDqeOuUO sQIBvj5Ncg+Cz9O8kCFG04T/Y4qNsM5E9qwnbzF6C7irHpvuROFuoGgJ8vTAcAdHRzP4 Kt7TuyxGkvn/sVWXrqPR1bM9OalQeCCS/IeQoBifbDU+wEapEOrPaYQ7CVJaq1eMyrrv wACAglxPSL6YPvNAc3ZMU3vc+1WfqBjm4MEYoCzTg7kISuED0ersI63IYiWZSGvA7/b2 6pUVA4R981l+oWB2FB7/vFVV56Yml7jeOyERy3GvaF5mjcV4UD2ILCunEAyfdKFymgiN HJhw== X-Gm-Message-State: AOJu0Yx3edlxTcV3gwub/RAJlrh4hSBk0nMbGPqhWyDeDDGzF4J8zl28 t6Eu6FYqPv5YiiI8FheYQTDkr8YQvqkVYqWIdGpweg5ejMHHcCNFgj8/ X-Gm-Gg: ASbGncsKzKHANrQgLIWYXdX6RN80aurPWsyUGNpJ7OM3wYr2CMqvYH7LvzhOMr1gKql CXQzhQtFqP7BjDu/70+wIQ0I9zA5xLRfdBRGQgjgPw0uqFlsFQ3H/vJ65gCem2KaGqz7qaXpb7b zgnZOsbtyTXS5d4c4MIeChYy9muKJc7kbHcJLTbnZOwe92JFHwesgbMN9bAN7KhVq/C4NYPQsJX 6RnxyhTsbtgIKtd94XkOcLkUKlLxjA4mYp3/NqSaTKQoW3682WBH3q762gnDoSUL/nUsmHCJwCp 4BJQIyaGFkQ/Xa6PbiX7mfjMPhiLArlkKk2mnU/YMAho80nTpYZ8kTJFwhcoveJGkuyfFhlqEyj RCu+4n6xcvou+L03U6Fgjwg== X-Google-Smtp-Source: AGHT+IGxErq0jZeiZCTkuf4bULFIb2d0CWBj6vxkxbVIbYNSWNavHOzBqKjpw+DQJ0XVqUvXPF1NNA== X-Received: by 2002:a05:600c:a44:b0:45b:72a9:28b0 with SMTP id 5b1f17b1804b1-45b8557d227mr187053875e9.28.1757062574315; Fri, 05 Sep 2025 01:56:14 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45dd2304e16sm60272025e9.7.2025.09.05.01.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:56:13 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pop4b6v.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> Date: Fri, 05 Sep 2025 10:56:09 +0200 Message-ID: <87plc5cm6u.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Fix font lock and indentation in cmake-ts-mode when the tree-sitter grammar is automatically installed. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-font-lock-and-indentation-in-cmake-ts-mode.patch >From ab579a84dc6ebd35fffa62c641872b7d0b2151fc Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Thu, 4 Sep 2025 07:40:32 +0200 Subject: [PATCH] Fix font lock and indentation in cmake-ts-mode Fix font lock and indentation in cmake-ts-mode when the tree-sitter grammar is automatically installed (Bug#79363). * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--indent-rules) (cmake-ts-mode--font-lock-settings): Evaluate the rules only after the tree-sitter grammar is installed. (cmake-ts-mode): Call the new `cmake-ts-mode--indent-rules' and `cmake-ts-mode--font-lock-settings' functions. --- lisp/progmodes/cmake-ts-mode.el | 182 +++++++++++++++++--------------- 1 file changed, 99 insertions(+), 83 deletions(-) diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index 84589b1eb73b..8e49b18f7313 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el @@ -61,28 +61,36 @@ cmake-ts-mode--syntax-table table) "Syntax table for `cmake-ts-mode'.") -(defvar cmake-ts-mode--indent-rules - `((cmake - ((node-is ")") parent-bol 0) - ((node-is "else_command") parent-bol 0) - ((node-is "elseif_command") parent-bol 0) - ((node-is "endforeach_command") parent-bol 0) - ((node-is "endfunction_command") parent-bol 0) - ((node-is "endif_command") parent-bol 0) - ((parent-is "foreach_loop") parent-bol cmake-ts-mode-indent-offset) - ((parent-is "function_def") parent-bol cmake-ts-mode-indent-offset) - ((parent-is "if_condition") parent-bol cmake-ts-mode-indent-offset) - ((parent-is "normal_command") parent-bol cmake-ts-mode-indent-offset) - ;;; Release v0.4.0 wraps arguments in an argument_list node. - ,@(ignore-errors - (treesit-query-capture 'cmake '((argument_list) @capture)) - `(((parent-is "argument_list") grand-parent cmake-ts-mode-indent-offset))) - ;;; Release v0.3.0 wraps the body of commands into a body node. - ,@(ignore-errors - (treesit-query-capture 'cmake '((body) @capture)) - `(((parent-is "body") grand-parent cmake-ts-mode-indent-offset))))) +(defvar cmake-ts-mode--indent-rules nil "Tree-sitter indent rules for `cmake-ts-mode'.") +(defun cmake-ts-mode--indent-rules () + "Return tree-sitter indent rules for `cmake-ts-mode'. + +Tree-sitter indent rules are evaluated the first time this function +is called. Subsequent calls return the first evaluated value." + (or cmake-ts-mode--indent-rules + (setq cmake-ts-mode--indent-rules + `((cmake + ((node-is ")") parent-bol 0) + ((node-is "else_command") parent-bol 0) + ((node-is "elseif_command") parent-bol 0) + ((node-is "endforeach_command") parent-bol 0) + ((node-is "endfunction_command") parent-bol 0) + ((node-is "endif_command") parent-bol 0) + ((parent-is "foreach_loop") parent-bol cmake-ts-mode-indent-offset) + ((parent-is "function_def") parent-bol cmake-ts-mode-indent-offset) + ((parent-is "if_condition") parent-bol cmake-ts-mode-indent-offset) + ((parent-is "normal_command") parent-bol cmake-ts-mode-indent-offset) + ;; Release v0.4.0 wraps arguments in an argument_list node. + ,@(ignore-errors + (treesit-query-capture 'cmake '((argument_list) @capture)) + `(((parent-is "argument_list") grand-parent cmake-ts-mode-indent-offset))) + ;; Release v0.3.0 wraps the body of commands into a body node. + ,@(ignore-errors + (treesit-query-capture 'cmake '((body) @capture)) + `(((parent-is "body") grand-parent cmake-ts-mode-indent-offset)))))))) + (defvar cmake-ts-mode--constants '("ON" "TRUE" "YES" "Y" "OFF" "FALSE" "NO" "N" "IGNORE" "NOTFOUND") "CMake constants for tree-sitter font-locking.") @@ -140,69 +148,77 @@ cmake-ts-mode--font-lock-compatibility-fe9b5e0 eol)) @font-lock-constant-face)))))))) -(defvar cmake-ts-mode--font-lock-settings - (treesit-font-lock-rules - :language 'cmake - :feature 'bracket - '((["(" ")"]) @font-lock-bracket-face) - - :language 'cmake - :feature 'builtin - (cmake-ts-mode--font-lock-compatibility-fe9b5e0) - - :language 'cmake - :feature 'comment - '([(bracket_comment) (line_comment)] @font-lock-comment-face) - - :language 'cmake - :feature 'constant - `(((argument) @font-lock-constant-face - (:match ,(rx-to-string - `(seq bol - (or ,@cmake-ts-mode--constants) - eol)) - @font-lock-constant-face))) - - :language 'cmake - :feature 'function - '((normal_command (identifier) @font-lock-function-call-face)) - - :language 'cmake - :feature 'keyword - `([,@cmake-ts-mode--keywords] @font-lock-keyword-face) - - :language 'cmake - :feature 'number - '(((unquoted_argument) @font-lock-number-face - (:match "\\`-?[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'" - @font-lock-number-face))) - - :language 'cmake - :feature 'string - '([(bracket_argument) (quoted_argument)] @font-lock-string-face) - - :language 'cmake - :feature 'escape-sequence - :override t - '((escape_sequence) @font-lock-escape-face) - - :language 'cmake - :feature 'misc-punctuation - ;; Don't override strings. - :override 'nil - '((["$" "{" "}"]) @font-lock-misc-punctuation-face) - - :language 'cmake - :feature 'variable - :override t - '((variable) @font-lock-variable-use-face) - - :language 'cmake - :feature 'error - :override t - '((ERROR) @font-lock-warning-face)) +(defvar cmake-ts-mode--font-lock-settings nil "Tree-sitter font-lock settings for `cmake-ts-mode'.") +(defun cmake-ts-mode--font-lock-settings () + "Return tree-sitter font-lock settings for `cmake-ts-mode'. + +Tree-sitter font-lock rules are evaluated the first time this function +is called. Subsequent calls return the first evaluated value." + (or cmake-ts-mode--font-lock-settings + (setq cmake-ts-mode--font-lock-settings + (treesit-font-lock-rules + :language 'cmake + :feature 'bracket + '((["(" ")"]) @font-lock-bracket-face) + + :language 'cmake + :feature 'builtin + (cmake-ts-mode--font-lock-compatibility-fe9b5e0) + + :language 'cmake + :feature 'comment + '([(bracket_comment) (line_comment)] @font-lock-comment-face) + + :language 'cmake + :feature 'constant + `(((argument) @font-lock-constant-face + (:match ,(rx-to-string + `(seq bol + (or ,@cmake-ts-mode--constants) + eol)) + @font-lock-constant-face))) + + :language 'cmake + :feature 'function + '((normal_command (identifier) @font-lock-function-call-face)) + + :language 'cmake + :feature 'keyword + `([,@cmake-ts-mode--keywords] @font-lock-keyword-face) + + :language 'cmake + :feature 'number + '(((unquoted_argument) @font-lock-number-face + (:match "\\`-?[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'" + @font-lock-number-face))) + + :language 'cmake + :feature 'string + '([(bracket_argument) (quoted_argument)] @font-lock-string-face) + + :language 'cmake + :feature 'escape-sequence + :override t + '((escape_sequence) @font-lock-escape-face) + + :language 'cmake + :feature 'misc-punctuation + ;; Don't override strings. + :override 'nil + '((["$" "{" "}"]) @font-lock-misc-punctuation-face) + + :language 'cmake + :feature 'variable + :override t + '((variable) @font-lock-variable-use-face) + + :language 'cmake + :feature 'error + :override t + '((ERROR) @font-lock-warning-face))))) + (defun cmake-ts-mode--defun-name (node) "Return the defun name of NODE. Return nil if there is no name or if NODE is not a defun node." @@ -238,10 +254,10 @@ cmake-ts-mode (setq-local which-func-functions nil) ;; Indent. - (setq-local treesit-simple-indent-rules cmake-ts-mode--indent-rules) + (setq-local treesit-simple-indent-rules (cmake-ts-mode--indent-rules)) ;; Font-lock. - (setq-local treesit-font-lock-settings cmake-ts-mode--font-lock-settings) + (setq-local treesit-font-lock-settings (cmake-ts-mode--font-lock-settings)) (setq-local treesit-font-lock-feature-list '((comment) (keyword string) -- 2.51.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 04:57:32 2025 Received: (at 79363) by debbugs.gnu.org; 5 Sep 2025 08:57:32 +0000 Received: from localhost ([127.0.0.1]:51255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuSGB-0002ob-Bi for submit@debbugs.gnu.org; Fri, 05 Sep 2025 04:57:32 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:54443) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uuSG4-0002nf-Vv for 79363@debbugs.gnu.org; Fri, 05 Sep 2025 04:57:29 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3e3aafe06a7so359696f8f.0 for <79363@debbugs.gnu.org>; Fri, 05 Sep 2025 01:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757062638; x=1757667438; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=bFWajduZWL1rx80jxl3dgBlVZLyfZLaOgQg4XOxOHV4=; b=m5DOI2SB+jx/iyZV0RkWK+6pIlwm7kR0o6+BeziN3tEJqzIMWOS5U0Lx+qJ6IJAKzk jbyGXXDVfxpjVQaLaerU5u3zR+9SFjRdfTJa0/wC0KEZt1Qv1jLI3sxwxNa/ku4rHGr6 I+nMjxztl12iQqF5bbyJZyPcq3GbOw3har2+9bUzT1EI132OBVE8BcOTxR4+edvBo1wq qe/aqwIJGRq3hzkXKTo8y0THj3EJB7cUrFd9vCy0EqCHHERH76ATd+11D3szCuWa5jKP tYjvKqxYyVOGbDzTIwlGjkd9fNlkJsWv1263bSI7j+495fa0x/hEjjtqkXQ++RW78+dF kymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062638; x=1757667438; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bFWajduZWL1rx80jxl3dgBlVZLyfZLaOgQg4XOxOHV4=; b=cra4TTgv9ryOinASNyQJnTlW4xsLpRSKc5m0NQbs9b7sxQDmC8VirVATZUCEvZHbjP /Ho2dVDVjKD2TLsfOnR4L4+2kmbhebxR/FhYgoaZocClj/Wa/b3rP7nea2Q9z20VL+pB mTbwBFc7DaN8BuY2PN8oUe8B2jQRuOdrFdU+r7nbAbEZukEs17Iq3p46qoGVYNAdus71 cTO6Xugiyg8HJtxaw8vAS91UPV9EhpGxWEEktleZdUJCo7yO0uYnwV2lbazXxeVA3jY7 YxfdYuQ3oMq63oSZZIMs6QHnpV2G2cnXzeZl1H7puyJP1Sd0amr11tR6AYoDtDJEiGSM ukaQ== X-Gm-Message-State: AOJu0YwjOgkLhw41gcqrGP5c61T2wTn0DbMQdVNF8N2OYhhyVWSUkX1O FB6K38XFGgm7OG9wbXivwQbIlhllB9JnaHSU0UAsIOklHBWd0UJrDjgLIH2yhQ== X-Gm-Gg: ASbGncs739EjvZE9h0Z7RJ7+a8Ro+8XgXqKKCxEd4V2q895jjyh9RNx0fOLEo6cUq+T XRM0AW6qj8Az+PcHBykRX70q59ItzEqOnmiKzG/5w6OuchEUqvrHY8WrtO57wK3eL2FpH0RPKEi EaH/ITgfQ4bC/MCH2B9CT8YgPHlNiixWRk4U9NsMtFLdIrn0iEVSQ8DMTlTZ+NBFtdoS5S07z5/ 4DaPLH5aB2/jvIlRBzweawmYo8yL0JFEhPjf4k3SQpZxSC5bMdJGDpkrZH3opwOnEwyWhtZbXK/ GcU+ronKbfl8gVVK3T0D08apfo0wja/NNYHOrLC34aJclhV7z0W4EiKzEMwGgUxaBBJG1zv+hPJ SR363lTfYMUzG4Ik6P9gYaQ== X-Google-Smtp-Source: AGHT+IGCIruNskYuYS2jbghHBtnxAdibxL7t3HjIK542EBka4j2P4oRBOPQwaFbFUs8jXGnlIZuqHg== X-Received: by 2002:a05:6000:230f:b0:3dc:1473:18be with SMTP id ffacd0b85a97d-3dc14731935mr7824735f8f.0.1757062637537; Fri, 05 Sep 2025 01:57:17 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e18537589dsm5038608f8f.54.2025.09.05.01.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:57:16 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pop4b6v.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> Date: Fri, 05 Sep 2025 10:57:15 +0200 Message-ID: <87ms79cm50.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Fix font lock in go-ts-mode when the tree-sitter grammar is automatically installed. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-font-lock-in-go-ts-mode.patch >From 1df5ddbb86947f4113f98c73ba85a1ba32dd388d Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 3 Sep 2025 15:30:14 +0200 Subject: [PATCH] Fix font lock in go-ts-mode Fix font lock in go-ts-mode when the tree-sitter grammar is automatically installed (Bug#79363). * lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings): Evaluate the rules only after the tree-sitter grammar is installed. (go-ts-mode): Call the new `go-ts-mode--font-lock-settings' function. --- lisp/progmodes/go-ts-mode.el | 236 ++++++++++++++++++----------------- 1 file changed, 122 insertions(+), 114 deletions(-) diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index e149e9230ece..1b44478f41af 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -162,121 +162,129 @@ go-ts-mode--method-elem-supported-p (ignore-errors (or (treesit-query-string "" '((method_elem) @cap) 'go) t))) -(defvar go-ts-mode--font-lock-settings - (treesit-font-lock-rules - :language 'go - :feature 'bracket - '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) - - :language 'go - :feature 'comment - '((comment) @font-lock-comment-face) - - :language 'go - :feature 'builtin - `((call_expression - function: ((identifier) @font-lock-builtin-face - (:match ,(rx-to-string - `(seq bol - (or ,@go-ts-mode--builtin-functions) - eol)) - @font-lock-builtin-face)))) - - :language 'go - :feature 'constant - `([(false) (nil) (true)] @font-lock-constant-face - ,@(when (go-ts-mode--iota-query-supported-p) - '((iota) @font-lock-constant-face)) - (const_declaration - (const_spec name: (identifier) @font-lock-constant-face - ("," name: (identifier) @font-lock-constant-face)*))) - - :language 'go - :feature 'delimiter - '((["," "." ";" ":"]) @font-lock-delimiter-face) - - :language 'go - :feature 'operator - `([,@go-ts-mode--operators] @font-lock-operator-face) - - :language 'go - :feature 'definition - `((function_declaration - name: (identifier) @font-lock-function-name-face) - (method_declaration - name: (field_identifier) @font-lock-function-name-face) - (,(if (go-ts-mode--method-elem-supported-p) - 'method_elem - 'method_spec) - name: (field_identifier) @font-lock-function-name-face) - (field_declaration - name: (field_identifier) @font-lock-property-name-face) - (parameter_declaration - name: (identifier) @font-lock-variable-name-face) - (variadic_parameter_declaration - name: (identifier) @font-lock-variable-name-face) - (short_var_declaration - left: (expression_list - (identifier) @font-lock-variable-name-face - ("," (identifier) @font-lock-variable-name-face)*)) - (var_spec name: (identifier) @font-lock-variable-name-face - ("," name: (identifier) @font-lock-variable-name-face)*) - (range_clause - left: (expression_list - (identifier) @font-lock-variable-name-face))) - - :language 'go - :feature 'function - '((call_expression - function: (identifier) @font-lock-function-call-face) - (call_expression - function: (selector_expression - field: (field_identifier) @font-lock-function-call-face))) - - :language 'go - :feature 'keyword - `([,@go-ts-mode--keywords] @font-lock-keyword-face) - - :language 'go - :feature 'label - '((label_name) @font-lock-constant-face) - - :language 'go - :feature 'number - '([(float_literal) - (imaginary_literal) - (int_literal)] @font-lock-number-face) - - :language 'go - :feature 'string - '([(interpreted_string_literal) - (raw_string_literal) - (rune_literal)] @font-lock-string-face) - - :language 'go - :feature 'type - '([(package_identifier) (type_identifier)] @font-lock-type-face) - - :language 'go - :feature 'property - '((selector_expression field: (field_identifier) @font-lock-property-use-face) - (keyed_element (_ (identifier) @font-lock-property-use-face))) - - :language 'go - :feature 'variable - '((identifier) @font-lock-variable-use-face) - - :language 'go - :feature 'escape-sequence - :override t - '((escape_sequence) @font-lock-escape-face) - - :language 'go - :feature 'error - :override t - '((ERROR) @font-lock-warning-face)) +(defvar go-ts-mode--font-lock-settings nil "Tree-sitter font-lock settings for `go-ts-mode'.") +(defun go-ts-mode--font-lock-settings () + "Return tree-sitter font-lock settings for `go-ts-mode'. + +Tree-sitter font-lock rules are evaluated the first time this function +is called. Subsequent calls return the first evaluated value." + (or go-ts-mode--font-lock-settings + (setq go-ts-mode--font-lock-settings + (treesit-font-lock-rules + :language 'go + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'go + :feature 'comment + '((comment) @font-lock-comment-face) + + :language 'go + :feature 'builtin + `((call_expression + function: ((identifier) @font-lock-builtin-face + (:match ,(rx-to-string + `(seq bol + (or ,@go-ts-mode--builtin-functions) + eol)) + @font-lock-builtin-face)))) + + :language 'go + :feature 'constant + `([(false) (nil) (true)] @font-lock-constant-face + ,@(when (go-ts-mode--iota-query-supported-p) + '((iota) @font-lock-constant-face)) + (const_declaration + (const_spec name: (identifier) @font-lock-constant-face + ("," name: (identifier) @font-lock-constant-face)*))) + + :language 'go + :feature 'delimiter + '((["," "." ";" ":"]) @font-lock-delimiter-face) + + :language 'go + :feature 'operator + `([,@go-ts-mode--operators] @font-lock-operator-face) + + :language 'go + :feature 'definition + `((function_declaration + name: (identifier) @font-lock-function-name-face) + (method_declaration + name: (field_identifier) @font-lock-function-name-face) + (,(if (go-ts-mode--method-elem-supported-p) + 'method_elem + 'method_spec) + name: (field_identifier) @font-lock-function-name-face) + (field_declaration + name: (field_identifier) @font-lock-property-name-face) + (parameter_declaration + name: (identifier) @font-lock-variable-name-face) + (variadic_parameter_declaration + name: (identifier) @font-lock-variable-name-face) + (short_var_declaration + left: (expression_list + (identifier) @font-lock-variable-name-face + ("," (identifier) @font-lock-variable-name-face)*)) + (var_spec name: (identifier) @font-lock-variable-name-face + ("," name: (identifier) @font-lock-variable-name-face)*) + (range_clause + left: (expression_list + (identifier) @font-lock-variable-name-face))) + + :language 'go + :feature 'function + '((call_expression + function: (identifier) @font-lock-function-call-face) + (call_expression + function: (selector_expression + field: (field_identifier) @font-lock-function-call-face))) + + :language 'go + :feature 'keyword + `([,@go-ts-mode--keywords] @font-lock-keyword-face) + + :language 'go + :feature 'label + '((label_name) @font-lock-constant-face) + + :language 'go + :feature 'number + '([(float_literal) + (imaginary_literal) + (int_literal)] @font-lock-number-face) + + :language 'go + :feature 'string + '([(interpreted_string_literal) + (raw_string_literal) + (rune_literal)] @font-lock-string-face) + + :language 'go + :feature 'type + '([(package_identifier) (type_identifier)] @font-lock-type-face) + + :language 'go + :feature 'property + '((selector_expression field: (field_identifier) @font-lock-property-use-face) + (keyed_element (_ (identifier) @font-lock-property-use-face))) + + :language 'go + :feature 'variable + '((identifier) @font-lock-variable-use-face) + + :language 'go + :feature 'escape-sequence + :override t + '((escape_sequence) @font-lock-escape-face) + + :language 'go + :feature 'error + :override t + '((ERROR) @font-lock-warning-face))))) + (defvar-keymap go-ts-mode-map :doc "Keymap used in Go mode, powered by tree-sitter" :parent prog-mode-map @@ -348,7 +356,7 @@ go-ts-mode (append "{}()" electric-indent-chars)) ;; Font-lock. - (setq-local treesit-font-lock-settings go-ts-mode--font-lock-settings) + (setq-local treesit-font-lock-settings (go-ts-mode--font-lock-settings)) (setq-local treesit-font-lock-feature-list '(( comment definition) ( keyword string type) -- 2.51.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 05 04:58:55 2025 Received: (at 79363) by debbugs.gnu.org; 5 Sep 2025 08:58:56 +0000 Received: from localhost ([127.0.0.1]:51269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uuSHW-0002ra-5q for submit@debbugs.gnu.org; Fri, 05 Sep 2025 04:58:55 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:41994) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uuSHS-0002rE-A7 for 79363@debbugs.gnu.org; Fri, 05 Sep 2025 04:58:51 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45dd7b15a64so4074315e9.0 for <79363@debbugs.gnu.org>; Fri, 05 Sep 2025 01:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757062723; x=1757667523; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=dgrrcAko5GntSu8/7Mb1OzMeUa8SIrvSo3gHqWrxs70=; b=bQyKZGRK71gSwod0NXKMRr8o7MIi1cSVx6EpjwI7ytYH+43VBdj1ZDio5GXdXxDMuc 0xdKaCkEvAttvOIhOE/Z0njj8pmvN8gkW8QA0PSYllqS5BMh6pzi5g/tEbeGmeP8vkYk 7qOxqy5eIu2x1MnMDANMdcira1OlLBPFOpPZ+FOA+zdwTpYxvFKjbgllu+tNwY3uGTfv bdumlexY7p3WrFwAwguzTodMTRyiUI6pAcOHivzLBQKGLoQbFc/9pliIRizkPIPw1AaX WtZaekD1iG/+Uum6bIOFmcFnMaBpjEjL1wAiiI6zRacxP92SFZvjqV5Mngkl1lcah8Wq gx2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062723; x=1757667523; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dgrrcAko5GntSu8/7Mb1OzMeUa8SIrvSo3gHqWrxs70=; b=JqN5hbmL1nZb0qi8yzbk7ewAogCVlxluXjLHSeKQ2lVrONp2Dz9GKC7b8d69F34E/G okCF8jgkGPrsli7SNz9HmupMTuFH80iVTPzzXLyYAQXGZoAzoxTCJ1+rjuAyC0Be4ZQk XxscilcFpPwtHakJqGYl5rkqaNpQTFTeIIOUQnJ7cH2ntcOZMYToDedcebHd65s9OXEg KYxoR1Ws9dJ57R71pFf+UV6ZU1zog9TD/iKBv3lP8cLfhkjtoXqla8zBz7yBZpFCPxd+ aJ81/OQmZzGCjtXuF8sCyhHl4x7m8YfBpF9aX9O5/zcVvLFCQSvlZhDrcAU3ti706isd q0mw== X-Gm-Message-State: AOJu0YyLpFPrWpjC+M4dwyd4pN2uBDHd5JOS9kPAx2nBrpdLxLvfPBwZ kOvjk02udmrTy7y96tLhtFR0bEXsm6qG3k1TzG90huvtBTtVpEKTme7J2rcobg== X-Gm-Gg: ASbGncuBDgCIMxkwCW/bFvqvtWEnu8qSVIFVE/1zViOvy6/l+RinEIxHL7OdVx18TCz LxrUbHOydkube2Q0WoSd/c03+MXYHJ7tzt+nsC/+Q+R/MVsaaP4BCT0kUZmTkvohIkEPFHtMmzD v+Sq3iWZtcWdC7guhWOp9/QtGOzuiOlfI9OVpjU32CEZ1gmWHD0rFmV18IuAosW31VCr1AYaQ30 vBTVDysY0T6TiFx6F6rXHvvsw3zdSHzu/wVT0I8tytJZvlik7Yc5qszlG53xYI93ZKgssLmilfz 6vWRpREQ7HNH0sNj8QXH50x0Pc1TgRq7P2oPHgQl+RKXyYGrVVvMFd1TU/pgxxU1bIQyBgQ65W1 iBJxz9PYkLByJi7pl9FUqzQ== X-Google-Smtp-Source: AGHT+IHyxkmsuXaLkbBt2y5g2XJ5cMmVEAr439Bt5rwWJM8A9CSBCeEAElPPsTz7oXTTy+S57+15Tg== X-Received: by 2002:a05:600c:4695:b0:45d:5c71:769d with SMTP id 5b1f17b1804b1-45dd5b3c3bfmr22153005e9.8.1757062723399; Fri, 05 Sep 2025 01:58:43 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f0d32a2sm439516375e9.9.2025.09.05.01.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:58:42 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pop4b6v.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> Date: Fri, 05 Sep 2025 10:58:41 +0200 Message-ID: <87jz2dcm2m.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Fix tree-sitter grammar installation issues in elixir-ts-mode and heex-ts-mode. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-grammar-installation-in-elixir-ts-mode-and-heex-.patch >From 4fc9de002a41588fc2a717f9bc480dd63777f6ff Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 3 Sep 2025 15:22:16 +0200 Subject: [PATCH] Fix grammar installation in elixir-ts-mode and heex-ts-mode Fix tree-sitter grammar installation issues in elixir-ts-mode and heex-ts-mode (Bug#79363). * lisp/progmodes/elixir-ts-mode.el (elixir-ts--font-lock-settings): Check that tree-sitter is available. (elixir-ts-mode): If the user answers "no" to installing the heex tree-sitter grammar, do not ask again. Group heex settings. * lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Ensure that elixir tree-sitter grammar is installed. --- lisp/progmodes/elixir-ts-mode.el | 442 +++++++++++++++---------------- lisp/progmodes/heex-ts-mode.el | 2 +- 2 files changed, 220 insertions(+), 224 deletions(-) diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 042275996308..b6828a3d09c8 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -371,216 +371,216 @@ elixir-ts--indent-rules 0))))) (defvar elixir-ts--font-lock-settings - (treesit-font-lock-rules - :language 'elixir - :feature 'elixir-definition - `((call target: (identifier) @target-identifier - (arguments - (call target: (identifier) @font-lock-function-name-face - (arguments))) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments (identifier) @font-lock-function-name-face) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments - (call target: (identifier) @font-lock-function-name-face - (arguments ((identifier)) @font-lock-variable-name-face))) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments - (binary_operator - left: (call target: (identifier) @font-lock-function-name-face))) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments (identifier) @font-lock-function-name-face) - (do_block) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments - (call target: (identifier) @font-lock-function-name-face - (arguments ((identifier)) @font-lock-variable-name-face))) - (do_block) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (call target: (identifier) @target-identifier - (arguments - (binary_operator - left: (call target: (identifier) @font-lock-function-name-face - (arguments ((identifier)) @font-lock-variable-name-face)))) - (do_block) - (:match ,elixir-ts--definition-keywords-re @target-identifier)) - (unary_operator - operator: "@" - (call (arguments - (binary_operator - left: (call target: (identifier) @font-lock-function-name-face)))))) - - :language 'elixir - :feature 'elixir-comment - :override t - '((comment) @font-lock-comment-face - ((identifier) @font-lock-comment-face - (:match "^_[a-z]\\|^_$" @font-lock-comment-face))) - - :language 'elixir - :feature 'elixir-variable - `((call target: (identifier) - (arguments - (binary_operator - (call target: (identifier) - (arguments ((identifier) @font-lock-variable-use-face)))))) - (call target: (identifier) - (arguments - (call target: (identifier) - (arguments ((identifier)) @font-lock-variable-use-face)))) - (dot left: (identifier) @font-lock-variable-use-face operator: "." )) - - :language 'elixir - :feature 'elixir-doc - `((unary_operator - operator: "@" @elixir-ts-comment-doc-attribute - operand: (call - target: (identifier) @elixir-ts-comment-doc-identifier - ;; Arguments can be optional, so adding another - ;; entry without arguments. - ;; If we don't handle then we don't apply font - ;; and the non doc fortification query will take specify - ;; a more specific font which takes precedence. - (arguments - [ - (string) @font-lock-doc-face - (charlist) @font-lock-doc-face - (sigil) @font-lock-doc-face - (boolean) @font-lock-doc-face - (keywords) @font-lock-doc-face - ])) - (:match ,elixir-ts--doc-keywords-re - @elixir-ts-comment-doc-identifier)) - (unary_operator - operator: "@" @elixir-ts-comment-doc-attribute - operand: (call - target: (identifier) @elixir-ts-comment-doc-identifier) - (:match ,elixir-ts--doc-keywords-re - @elixir-ts-comment-doc-identifier))) - - :language 'elixir - :feature 'elixir-string - '((interpolation - "#{" @font-lock-escape-face - "}" @font-lock-escape-face) - (string (quoted_content) @font-lock-string-face) - (quoted_keyword (quoted_content) @font-lock-string-face) - (charlist (quoted_content) @font-lock-string-face) - ["\"" "'" "\"\"\""] @font-lock-string-face) - - :language 'elixir - :feature 'elixir-sigil - `((sigil - (sigil_name) @elixir-ts-sigil-name - (quoted_content) @font-lock-string-face - ;; HEEx and Surface templates will handled by - ;; heex-ts-mode if its available. - (:match "^[^HF]$" @elixir-ts-sigil-name)) - @font-lock-string-face - (sigil - (sigil_name) @font-lock-regexp-face - (:match "^[rR]$" @font-lock-regexp-face)) - @font-lock-regexp-face - (sigil - "~" @font-lock-string-face - (sigil_name) @font-lock-string-face - quoted_start: _ @font-lock-string-face - quoted_end: _ @font-lock-string-face)) - - :language 'elixir - :feature 'elixir-operator - `(["!"] @font-lock-negation-char-face - ["%"] @font-lock-bracket-face - ["," ";"] @font-lock-operator-face - ["(" ")" "[" "]" "{" "}" "<<" ">>"] @font-lock-bracket-face) - - :language 'elixir - :feature 'elixir-data-type - '((alias) @font-lock-type-face - (atom) @elixir-ts-atom - (keywords (pair key: (keyword) @elixir-ts-keyword-key)) - [(keyword) (quoted_keyword)] @elixir-ts-atom - [(boolean) (nil)] @elixir-ts-atom - (unary_operator operator: "@" @elixir-ts-attribute - operand: [ - (identifier) @elixir-ts-attribute - (call target: (identifier) - @elixir-ts-attribute) - (boolean) @elixir-ts-attribute - (nil) @elixir-ts-attribute - ]) - (operator_identifier) @font-lock-operator-face) - - :language 'elixir - :feature 'elixir-keyword - `(,elixir-ts--reserved-keywords-vector - @font-lock-keyword-face - (binary_operator - operator: _ @font-lock-keyword-face - (:match ,elixir-ts--reserved-keywords-re @font-lock-keyword-face)) - (binary_operator operator: _ @font-lock-operator-face) - (call - target: (identifier) @font-lock-keyword-face - (:match ,elixir-ts--definition-keywords-re @font-lock-keyword-face)) - (call - target: (identifier) @font-lock-keyword-face - (:match ,elixir-ts--kernel-keywords-re @font-lock-keyword-face))) - - :language 'elixir - :feature 'elixir-function-call - '((call target: (identifier) @font-lock-function-call-face) - (unary_operator operator: "&" @font-lock-operator-face - operand: (binary_operator - left: (identifier) - @font-lock-function-call-face - operator: "/" right: (integer))) - (call - target: (dot right: (identifier) @font-lock-function-call-face)) - (unary_operator operator: "&" @font-lock-variable-use-face - operand: (integer) @font-lock-variable-use-face) - (unary_operator operator: "&" @font-lock-operator-face - operand: (list))) - - :language 'elixir - :feature 'elixir-string-escape - :override t - `((escape_sequence) @font-lock-escape-face) - - :language 'elixir - :feature 'elixir-number - '([(integer) (float)] @font-lock-number-face) - - :language 'elixir - :feature 'elixir-variable - '((binary_operator left: (identifier) @font-lock-variable-use-face) - (binary_operator right: (identifier) @font-lock-variable-use-face) - (arguments ( (identifier) @font-lock-variable-use-face)) - (tuple (identifier) @font-lock-variable-use-face) - (list (identifier) @font-lock-variable-use-face) - (pair value: (identifier) @font-lock-variable-use-face) - (body (identifier) @font-lock-variable-use-face) - (unary_operator operand: (identifier) @font-lock-variable-use-face) - (interpolation (identifier) @font-lock-variable-use-face) - (do_block (identifier) @font-lock-variable-use-face) - (rescue_block (identifier) @font-lock-variable-use-face) - (catch_block (identifier) @font-lock-variable-use-face) - (else_block (identifier) @font-lock-variable-use-face) - (after_block (identifier) @font-lock-variable-use-face) - (access_call target: (identifier) @font-lock-variable-use-face) - (access_call "[" key: (identifier) @font-lock-variable-use-face "]")) - - :language 'elixir - :feature 'elixir-builtin - :override t - `(((identifier) @font-lock-builtin-face - (:match ,elixir-ts--builtin-keywords-re - @font-lock-builtin-face)))) - + (when (treesit-available-p) + (treesit-font-lock-rules + :language 'elixir + :feature 'elixir-definition + `((call target: (identifier) @target-identifier + (arguments + (call target: (identifier) @font-lock-function-name-face + (arguments))) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments (identifier) @font-lock-function-name-face) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments + (call target: (identifier) @font-lock-function-name-face + (arguments ((identifier)) @font-lock-variable-name-face))) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments + (binary_operator + left: (call target: (identifier) @font-lock-function-name-face))) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments (identifier) @font-lock-function-name-face) + (do_block) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments + (call target: (identifier) @font-lock-function-name-face + (arguments ((identifier)) @font-lock-variable-name-face))) + (do_block) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (call target: (identifier) @target-identifier + (arguments + (binary_operator + left: (call target: (identifier) @font-lock-function-name-face + (arguments ((identifier)) @font-lock-variable-name-face)))) + (do_block) + (:match ,elixir-ts--definition-keywords-re @target-identifier)) + (unary_operator + operator: "@" + (call (arguments + (binary_operator + left: (call target: (identifier) @font-lock-function-name-face)))))) + + :language 'elixir + :feature 'elixir-comment + :override t + '((comment) @font-lock-comment-face + ((identifier) @font-lock-comment-face + (:match "^_[a-z]\\|^_$" @font-lock-comment-face))) + + :language 'elixir + :feature 'elixir-variable + `((call target: (identifier) + (arguments + (binary_operator + (call target: (identifier) + (arguments ((identifier) @font-lock-variable-use-face)))))) + (call target: (identifier) + (arguments + (call target: (identifier) + (arguments ((identifier)) @font-lock-variable-use-face)))) + (dot left: (identifier) @font-lock-variable-use-face operator: "." )) + + :language 'elixir + :feature 'elixir-doc + `((unary_operator + operator: "@" @elixir-ts-comment-doc-attribute + operand: (call + target: (identifier) @elixir-ts-comment-doc-identifier + ;; Arguments can be optional, so adding another + ;; entry without arguments. + ;; If we don't handle then we don't apply font + ;; and the non doc fortification query will take specify + ;; a more specific font which takes precedence. + (arguments + [ + (string) @font-lock-doc-face + (charlist) @font-lock-doc-face + (sigil) @font-lock-doc-face + (boolean) @font-lock-doc-face + (keywords) @font-lock-doc-face + ])) + (:match ,elixir-ts--doc-keywords-re + @elixir-ts-comment-doc-identifier)) + (unary_operator + operator: "@" @elixir-ts-comment-doc-attribute + operand: (call + target: (identifier) @elixir-ts-comment-doc-identifier) + (:match ,elixir-ts--doc-keywords-re + @elixir-ts-comment-doc-identifier))) + + :language 'elixir + :feature 'elixir-string + '((interpolation + "#{" @font-lock-escape-face + "}" @font-lock-escape-face) + (string (quoted_content) @font-lock-string-face) + (quoted_keyword (quoted_content) @font-lock-string-face) + (charlist (quoted_content) @font-lock-string-face) + ["\"" "'" "\"\"\""] @font-lock-string-face) + + :language 'elixir + :feature 'elixir-sigil + `((sigil + (sigil_name) @elixir-ts-sigil-name + (quoted_content) @font-lock-string-face + ;; HEEx and Surface templates will handled by + ;; heex-ts-mode if its available. + (:match "^[^HF]$" @elixir-ts-sigil-name)) + @font-lock-string-face + (sigil + (sigil_name) @font-lock-regexp-face + (:match "^[rR]$" @font-lock-regexp-face)) + @font-lock-regexp-face + (sigil + "~" @font-lock-string-face + (sigil_name) @font-lock-string-face + quoted_start: _ @font-lock-string-face + quoted_end: _ @font-lock-string-face)) + + :language 'elixir + :feature 'elixir-operator + `(["!"] @font-lock-negation-char-face + ["%"] @font-lock-bracket-face + ["," ";"] @font-lock-operator-face + ["(" ")" "[" "]" "{" "}" "<<" ">>"] @font-lock-bracket-face) + + :language 'elixir + :feature 'elixir-data-type + '((alias) @font-lock-type-face + (atom) @elixir-ts-atom + (keywords (pair key: (keyword) @elixir-ts-keyword-key)) + [(keyword) (quoted_keyword)] @elixir-ts-atom + [(boolean) (nil)] @elixir-ts-atom + (unary_operator operator: "@" @elixir-ts-attribute + operand: [ + (identifier) @elixir-ts-attribute + (call target: (identifier) + @elixir-ts-attribute) + (boolean) @elixir-ts-attribute + (nil) @elixir-ts-attribute + ]) + (operator_identifier) @font-lock-operator-face) + + :language 'elixir + :feature 'elixir-keyword + `(,elixir-ts--reserved-keywords-vector + @font-lock-keyword-face + (binary_operator + operator: _ @font-lock-keyword-face + (:match ,elixir-ts--reserved-keywords-re @font-lock-keyword-face)) + (binary_operator operator: _ @font-lock-operator-face) + (call + target: (identifier) @font-lock-keyword-face + (:match ,elixir-ts--definition-keywords-re @font-lock-keyword-face)) + (call + target: (identifier) @font-lock-keyword-face + (:match ,elixir-ts--kernel-keywords-re @font-lock-keyword-face))) + + :language 'elixir + :feature 'elixir-function-call + '((call target: (identifier) @font-lock-function-call-face) + (unary_operator operator: "&" @font-lock-operator-face + operand: (binary_operator + left: (identifier) + @font-lock-function-call-face + operator: "/" right: (integer))) + (call + target: (dot right: (identifier) @font-lock-function-call-face)) + (unary_operator operator: "&" @font-lock-variable-use-face + operand: (integer) @font-lock-variable-use-face) + (unary_operator operator: "&" @font-lock-operator-face + operand: (list))) + + :language 'elixir + :feature 'elixir-string-escape + :override t + `((escape_sequence) @font-lock-escape-face) + + :language 'elixir + :feature 'elixir-number + '([(integer) (float)] @font-lock-number-face) + + :language 'elixir + :feature 'elixir-variable + '((binary_operator left: (identifier) @font-lock-variable-use-face) + (binary_operator right: (identifier) @font-lock-variable-use-face) + (arguments ( (identifier) @font-lock-variable-use-face)) + (tuple (identifier) @font-lock-variable-use-face) + (list (identifier) @font-lock-variable-use-face) + (pair value: (identifier) @font-lock-variable-use-face) + (body (identifier) @font-lock-variable-use-face) + (unary_operator operand: (identifier) @font-lock-variable-use-face) + (interpolation (identifier) @font-lock-variable-use-face) + (do_block (identifier) @font-lock-variable-use-face) + (rescue_block (identifier) @font-lock-variable-use-face) + (catch_block (identifier) @font-lock-variable-use-face) + (else_block (identifier) @font-lock-variable-use-face) + (after_block (identifier) @font-lock-variable-use-face) + (access_call target: (identifier) @font-lock-variable-use-face) + (access_call "[" key: (identifier) @font-lock-variable-use-face "]")) + + :language 'elixir + :feature 'elixir-builtin + :override t + `(((identifier) @font-lock-builtin-face + (:match ,elixir-ts--builtin-keywords-re + @font-lock-builtin-face))))) "Tree-sitter font-lock settings.") (defvar elixir-ts--font-lock-feature-list @@ -737,16 +737,6 @@ elixir-ts-mode #'elixir-ts--electric-pair-string-delimiter 'append t) (when (treesit-ensure-installed 'elixir) - ;; The HEEx parser has to be created first for elixir to ensure elixir - ;; is the first language when looking for treesit ranges. - ;; (In Emacs 31 this requirement is removed.) - (when (treesit-ensure-installed 'heex) - ;; Require heex-ts-mode only when we load elixir-ts-mode - ;; so that we don't get a tree-sitter compilation warning for - ;; elixir-ts-mode. - (require 'heex-ts-mode) - (treesit-parser-create 'heex)) - (setq-local treesit-primary-parser (treesit-parser-create 'elixir)) @@ -764,8 +754,7 @@ elixir-ts-mode ;; Navigation. (setq-local treesit-thing-settings - `((elixir ,@elixir-ts--thing-settings) - (heex ,@heex-ts--thing-settings))) + `((elixir ,@elixir-ts--thing-settings))) (setq-local treesit-defun-type-regexp '("call" . elixir-ts--defun-p)) @@ -773,6 +762,9 @@ elixir-ts-mode ;; Embedded Heex. (when (treesit-ensure-installed 'heex) + (require 'heex-ts-mode) + (treesit-parser-create 'heex) + (setq-local treesit-range-settings (append elixir-ts--range-rules ;; Leave only local parsers from heex @@ -791,7 +783,11 @@ elixir-ts-mode (setq-local treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list treesit-font-lock-feature-list - heex-ts--font-lock-feature-list))) + heex-ts--font-lock-feature-list)) + + (setq-local treesit-thing-settings + (append treesit-thing-settings + `((heex ,@heex-ts--thing-settings))))) (treesit-major-mode-setup) diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index 2b8b75c444e2..e9626e32f331 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el @@ -235,7 +235,7 @@ heex-ts-mode (setq-local treesit-font-lock-feature-list heex-ts--font-lock-feature-list) - (when (treesit-ready-p 'elixir) + (when (treesit-ensure-installed 'elixir) (require 'elixir-ts-mode) (treesit-parser-create 'elixir) -- 2.51.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 07 13:47:55 2025 Received: (at 79363) by debbugs.gnu.org; 7 Sep 2025 17:47:55 +0000 Received: from localhost ([127.0.0.1]:45633 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uvJUY-0006Dt-6d for submit@debbugs.gnu.org; Sun, 07 Sep 2025 13:47:54 -0400 Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]:47212) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uvJUR-0006DP-SA for 79363@debbugs.gnu.org; Sun, 07 Sep 2025 13:47:49 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4cKcx54W5Bz9sTb; Sun, 7 Sep 2025 19:47:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1757267257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zsbNQlPlLSMVJF5oFZPyvXoLx5wXBwEajfzq+FP8kKU=; b=ao0oeGR1esf79Xn85EWiCoGt00TwisWvWUtCbQezbJ8fXDl6J+Y+XvIdLkbGgiATJG5J9b rFLRr3SChQQ456Tagi+0g9NNAbX81O6A9oPe6zYleNBf+BxpbcJYzp1l7WnxXEEo0mZJWh V/ES/eyGYW5f4OElK/JHBu7PKaJlWXz2aRzzXTf13ihvi93aWEXCLLV1VJRJebvjy3/tVQ NitC3pRsNj5YE1DHBxx1WIPIovQuMWRzKIVzVTD7bwh8z/OQfdn8Eli67tPeiPp13LsYjT fcgYxh9/ALkdZEPiCOc35qBZPxJUIw6OIt9nvQ6a6Tv6CsVMNm/2EnpYZ4agbA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: Roi Martin Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <871pop4b6v.fsf@mail.linkov.net> Organization: LINKOV.NET References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> Date: Sun, 07 Sep 2025 20:47:27 +0300 Message-ID: <874iteduo5.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4cKcx54W5Bz9sTb X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Thanks, now all 3 patches are pushed. Are there other ts-modes that need the same fix? I see that treesit-admin--generate-compatibility-report reports a warning for javascript: Warning (treesit-font-lock-rules-mismatch): Emacs cannot compile every font-lock rules because a mismatch between the grammar and the rules. This is most likely due to a mismatch between the font-lock rules defined by the major mode and the tree-sitter grammar. This error can be fixed by either downgrading the grammar (tree-sitter-javascript) on your system, or upgrading the major mode package. The following are the temporarily disabled features: - `definition' for javascript. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 07 14:39:27 2025 Received: (at 79363) by debbugs.gnu.org; 7 Sep 2025 18:39:27 +0000 Received: from localhost ([127.0.0.1]:45786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uvKIQ-00034C-PL for submit@debbugs.gnu.org; Sun, 07 Sep 2025 14:39:27 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:52470) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uvKIL-00033f-22 for 79363@debbugs.gnu.org; Sun, 07 Sep 2025 14:39:22 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3df15fdf0caso2923943f8f.0 for <79363@debbugs.gnu.org>; Sun, 07 Sep 2025 11:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757270352; x=1757875152; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=VpJ75rnRN2fdxMqKG0qdYURu87QjgdFg8v0C+vr6D60=; b=KcVn1jSYs1Bz2an0yD4XvYvKd3tpzvQfqt4VZ0gNQLgOtbTJ8wUQDUsj7Wn7FbefLi P7DKNJk8iPHzgy6TjBI1Owj9vFdjTq4Pu9xcVD4xoys/js9fv5m43NpPignsIM/ZYIDi 6Y1VX93xLPJe4R+Ol3GB6Ks2xBnKX0UQ9gjCpsMR9aN0vkkRjT7wmIOeLDHClC3gvVY2 WTk9au558DfrFwiQYyFYITWFFEw5DI7LDOFVEQC+I+rimHCJTu1dntlckPhAudYIlE9o rrUwm13sUJg+7uWDEn0eahDOfDLauVW7VdoylR2ogLX8/p8krkqMYHKJ+ojvhtCve/Lh dXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757270352; x=1757875152; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VpJ75rnRN2fdxMqKG0qdYURu87QjgdFg8v0C+vr6D60=; b=F+ZyzNIC54V2C9NAFOyPH4duyGsJKIsKljQqDrt7hGlOcNzqQO0HwfinklLzvRoodY pY0uM9ctmtC8L8wdYQSj6MSmYldYtjbTACApdxh3HcA1eQkBQJeYJ6mRhUyTfznXHACM 1A9TzB//rcd2cP/MRKSgGXTlcXRRRwJRl2iF8TzkKENasmccp26Up9WJlL4wRpeuBxBM 0V6emQHXeM0cdHGee1BIXsW6GYeC8fPTTON8bJDpAXSuMIHyLTS5hbpmsnvWxYG0PN4W MO3ME6v5U5TMGUkNaceUkGthECrspJmBbey3dW3xhAZU7iA0EwKohOMGMrZ8vwz4LkED o2tw== X-Gm-Message-State: AOJu0YzTQC3QKYgQMhK05/KCuUtwRl3439ZjF7/AZToF1uRslmxMr15+ epWORXhqDyes7iPU2leBb0nFPU0cUo+j53ArHCwlTZj75VaQ4YS33pS8 X-Gm-Gg: ASbGncugJWdmF8broWtBBAaq3MGqQztoG2D5ZuClePVhFkmZfMnXVAE2b6PQWBja9mU 2IZAUFqkZxJjZpLD4yUtpjouZ5tgV1qBmqB5j1WXExhKE9jJnWhM+VKmnuMEBEhRJvb+GuHbIC6 RYKxET0SNyWIen+IdP9QolRCXKo7Lqsn7pgeAEHdQcWmeY3kezr/gjWWSp2KSi5TNDqT7x+hw4D IZR4Tz5QtpK3MLc1123q6zBH9Npv+bbki+dL8YqpKcpEjpHMdEjKfQavXp1NFjdpaIiYWblmbV9 kS9yO7K3cI6rWtXav4o7ql8iKVybsEkGrHw1ir8k+135rqV8nrJ3ODscULCdrp6f7lRY0mnv7kf M92NwVR4WJ0Jv1oqv6W9TDw== X-Google-Smtp-Source: AGHT+IHzvOPittQb9R2uZ1Kc/yNnfTv8VsbDf2OXDsr/iyMKJugi8WNP7W6NJb9PUAtj+LjNq/lfUw== X-Received: by 2002:a05:6000:1ac6:b0:3e5:25c2:9637 with SMTP id ffacd0b85a97d-3e6428d7c38mr3597014f8f.17.1757270352271; Sun, 07 Sep 2025 11:39:12 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d9f3c36a78sm23156149f8f.48.2025.09.07.11.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Sep 2025 11:39:11 -0700 (PDT) From: Roi Martin To: Juri Linkov Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <874iteduo5.fsf@mail.linkov.net> References: <87a53deu5z.fsf@gmail.com> <871pop4b6v.fsf@mail.linkov.net> <874iteduo5.fsf@mail.linkov.net> Date: Sun, 07 Sep 2025 20:39:10 +0200 Message-ID: <87ecsicdkh.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > Thanks, now all 3 patches are pushed. Thanks. > Are there other ts-modes that need the same fix? I have not finished reviewing all modes, so probably yes. I was waiting for this first batch to be installed in master before continuing to send new patches. I'll send the remaining ones in the next few days. Roi From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 09 03:39:07 2025 Received: (at 79363) by debbugs.gnu.org; 9 Sep 2025 07:39:07 +0000 Received: from localhost ([127.0.0.1]:56728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uvswU-0006OU-A2 for submit@debbugs.gnu.org; Tue, 09 Sep 2025 03:39:06 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:45259) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uvswO-0006NV-Nz for 79363@debbugs.gnu.org; Tue, 09 Sep 2025 03:39:02 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2570bf605b1so18590275ad.2 for <79363@debbugs.gnu.org>; Tue, 09 Sep 2025 00:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757403533; x=1758008333; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bBfrCf3Q10XCmU886s6ISeo5DMYlbtE+Ey2mVEZj7R0=; b=FUAt+xvBq9suwMyWbbkmybhQ19Sl4dzDgfchvdydFxEh6LbqsMTuv2MwrHe/lq2ovM mkZ2VWMvv4Ty+t4AnDg52aBJvHdFXW0iY2EsiUIDRHTAOhocRTpDVWRECdaHbPqosOtk NKC3XduxhUL67U4H8913TSwZMs+Tc/g/3YDruumasKWE09aA/vYNtbxc++7Fw5zd6m+n i+2/LOAwekZITb9Zdyw8M9hyN1ZbhnxfvlRfGBzRDX2ri65WMUsySNSkvTLSrEVok5gN RSgF1ibegiGvlsCJt0/uPBow6ajIPU3EWa5kW1Irh6QWdu9tGv8mPmHX1HAkBITam40k bBPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757403533; x=1758008333; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bBfrCf3Q10XCmU886s6ISeo5DMYlbtE+Ey2mVEZj7R0=; b=XvJzKcP+reA+YcutRM3uGeQ8eXJV7XjkOYo7xPF4jt+JyImywf5wQLUQ/VQr5bVMli oD8jxyFj7EoLZ7+OFR1iBr8Yxc1h7JH9ePwdmnmqDm7ffQLOp5RgRJCdfxF8wJdAEbuM +PjmyrLQrd74/uI1jVqkox9HPDnnyWgA4z8bnjOU/7n3zdrV47B+we1Oue+oP+Py/rBm oHBhFUon41NDY0M1uZILkJAG17gW74jC5w94L39cGKppPU46w/zKcBOQSLVlyB4h/k2o ebuyrF357X2U1URbppDSCv7rh+dAuEnj0ZBa/wjsov5qeeTyAnnBMafGjWrnWd+bXF33 Slwg== X-Gm-Message-State: AOJu0YzYZ6Vr9KBhTn573R3xIYleRgfE+vWoYdaepwQodpwvEHYUrDmk UcfIM0mgwbUbBQ892Plh8BxZDCdI1y4TXdHXbrXAf0X4jEbpVsBe/B0R X-Gm-Gg: ASbGncuCJwph4Ld6uPFwAnQADvHT+EXbOpSX3oIIL1dGoR2VPM7FF5S9gDzLtMJodGf Ngrm/DnJgb6WV5P+1AFRfJrlbyKCgJfgxkCvDvm8YcsogzqpLY4bbb7M/5E9BKl5tZGz8Xti5JQ MkswzZVieJyj1+d5GREE/u6hBofHVM1bMflJ0N9z01GiN8JO+PsKxk1eCd2v7ONDEZDkrv1FSqZ 6JKw1FQ0LdFIB3Ep29GfzQT9ODtJZ3Jtg50hlY/jabujp0sRtFiOJDelsY9jwbzMuXcLyGl61Hu 4labhSquFIhctrneGVy0bgIyzXNqhHri4qj1+mjmJDwg0B+05+Md0LaE1P4LQYH++7QhGykqWzR hBrV85SNjALvKFglPHxYKBpB5OUG9dCM5Hn9lzSyv14NhjLZvzHgvuWri3UPBWCDZL7C+NUj16+ kLP0cwbQ== X-Google-Smtp-Source: AGHT+IHyRPhNAynKXp7J/w0p9NwpIjPP8pqiJ7ZCGuQj14buTe+dK6GyVVAg//bxXGmLfeknK1KyBQ== X-Received: by 2002:a17:902:f788:b0:24b:15b3:224f with SMTP id d9443c01a7336-25166d5326cmr129894725ad.0.1757403533399; Tue, 09 Sep 2025 00:38:53 -0700 (PDT) Received: from smtpclient.apple (c-24-4-247-194.hsd1.ca.comcast.net. [24.4.247.194]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-24b273e4ad5sm187183465ad.25.2025.09.09.00.38.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Sep 2025 00:38:52 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed From: Yuan Fu In-Reply-To: <87a53deu5z.fsf@gmail.com> Date: Tue, 9 Sep 2025 00:38:41 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <51F87F1F-10CB-42D0-9B91-316F7F6F85F1@gmail.com> References: <87a53deu5z.fsf@gmail.com> To: Roi Martin X-Mailer: Apple Mail (2.3826.700.81) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Sep 1, 2025, at 2:31=E2=80=AFPM, Roi Martin = wrote: >=20 > Steps to reproduce: >=20 > 1. Run > emacs -Q --init-directory=3D/tmp/go-ts-mode-bug > 2. Eval > (setopt treesit-enabled-modes '(go-ts-mode)) > 3. Open .go file > 4. Answer y to the question > Tree-sitter grammar for `go' is missing; install it? (y or n) > 5. go-ts-mode emits the following warning and definitions are not > highlighted correctly. >=20 > =E2=9B=94 Warning (treesit-font-lock-rules-mismatch): Emacs cannot = compile > every font-lock rules because a mismatch between the grammar and = the > rules. This is most likely due to a mismatch between the = font-lock > rules defined by the major mode and the tree-sitter grammar. >=20 > This error can be fixed by either downgrading the grammar > (tree-sitter-go) on your system, or upgrading the major mode = package. > The following are the temporarily disabled features: >=20 > - `definition' for go. >=20 > In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.49, cairo version 1.18.2) > Repository revision: 3c94ae5a37eac0191fe5d8bd85164b190ac10244 > Repository branch: master >=20 > I took a quick look and I think this is caused by the following issue: >=20 > 1. `go-ts-mode--font-lock-settings' depends on the following = functions: >=20 > (defun go-ts-mode--iota-query-supported-p () > "Return t if the iota query is supported by the tree-sitter-go = grammar." > (ignore-errors > (or (treesit-query-string "" '((iota) = @font-lock-constant-face) 'go) t))) >=20 > (defun go-ts-mode--method-elem-supported-p () > "Return t if Go grammar uses `method_elem' instead of = `method_spec'." > (ignore-errors > (or (treesit-query-string "" '((method_elem) @cap) 'go) t))) >=20 > 2. In this sceneario we don't have the Go grammar installed yet. So, > `treesit-query-string' returns a `not-found' error. > 3. Because of the previous error, = `go-ts-mode--method-elem-supported-p' > returns `nil'. Thus, the "definition" rule uses "method_spec" which > is not supported by the default grammar (commit > "12fe553fdaaa7449f764bc876fd777704d4fb752"). >=20 > (defvar go-ts-mode--font-lock-settings > (treesit-font-lock-rules > ... > :language 'go > :feature 'definition > `(... > (,(if (go-ts-mode--method-elem-supported-p) > 'method_elem > 'method_spec) > name: (field_identifier) @font-lock-function-name-face) >=20 > Please, take this analysis with a pinch of salt. I'm not familiar = with > the code base. But I hope it makes sense. >=20 > Roi Thanks for the analysis! Does that mean once the grammar is installed, = and you restart Emacs, go-ts-mode would work as normal? We do need to fix how we=E2=80=99re defining font-lock rules, the test = should be done when major mode is enabled, not when the package is = loaded. I thought about this problem and wanted to come up with some = generic solution, such as letting treesit-font-lock-rules support a = predicate function/query for font-lock-rules, or define rules in a = fallback list. I didn=E2=80=99t come up with a very satisfying solution = and the progress kind of stalled. Anyway, now it seems I need to put = some thought into this and come up with something soon. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 09 04:25:03 2025 Received: (at 79363) by debbugs.gnu.org; 9 Sep 2025 08:25:03 +0000 Received: from localhost ([127.0.0.1]:57085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uvtew-0001G2-WF for submit@debbugs.gnu.org; Tue, 09 Sep 2025 04:25:03 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:47521) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uvtet-0001F9-5q for 79363@debbugs.gnu.org; Tue, 09 Sep 2025 04:25:00 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45decc9e83eso6047225e9.3 for <79363@debbugs.gnu.org>; Tue, 09 Sep 2025 01:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757406291; x=1758011091; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mk7em9kNeQxSgyuP5s+otl1KBpeBXqesgVYL56kx6wY=; b=ar7xlzxjjgNrNuNzeDxC3XVfG5pL6cUVA/eq4UB/YfjuMQH2oDn/VqamJbytE3mk46 wTVNRpu43HOAEk3qI2afopDJoDu59r1Ek9Gwmi9zFDxm90WfPPAUMmQXyXZmceNqY6nc k5eRwoCOA/txTGXkXVwuFrO0BQ2GB8bBAvga76yTFMfZ5JvW9ma1KA0vXNPYZSVFn7L5 vQ/6bau9sM+w9tcIX9m9rEBkYagBwG/fGtVKFqVnLSaPHu2B4A/JLpcYLd9W5A39B519 YMkG07WFuNmPFqeGzQDoykL//fj5aLErWcdixtSjrp3Dmgzrpk8raWAaCWYAD7Wv6S5m 6fBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757406291; x=1758011091; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mk7em9kNeQxSgyuP5s+otl1KBpeBXqesgVYL56kx6wY=; b=n9Irlux28X8rxAXbKvB4La9vA2HLyKrrb2yW2Bfs6NtM/eTYK6+bWB3CQzXDhJRAm5 wze+PJPLY7ONkMEagFsbtW3E2qWAFwyoN4zF3TJxEJ3AFRT0HqW7192AMLq9gwi9GKlv yZluzWYZ1LbHoU5RsUp4nIAELvp17ejju/bpApGtoAfYHkA2+JzpAEiHCyiNeT8zQ5g2 mTx3hC9vxylpytdGG7SB0mLw4wirrEnsD4M7anT+sHbHJb5kc/8UYWR1qsGukkUhPSpB Ub1vJ6D7Z15zdQ9PFyPjmQxtRPDWIece0hgFFdtgWcZjbPioRag9qcs4rKezj4T8OHGI +vUA== X-Gm-Message-State: AOJu0YxcQYtAVH6Wua67Cdeqqvon57fvf3Fylxqpp28aOdZb0nrIHZN5 tauEuLemhn1959jr4UtcrFM7/VVmWkkdrMukDB3B5BhSkVcuM4hurawYDWGaHg== X-Gm-Gg: ASbGncuR3b7fQHMhLV/5t/5xk8QvX4ayHs9wSEn9ctKIC7EYhrtuSoiWeOHJSkh9nxg xK8AhaM4l3i+j9GlOX9BvoB5rAaSRbOx08hsVlL2bnBzxGj8f0VLxfPpb2cYrvZhbBeF7gotp+7 RVHFIw9DJx/09FT8A6pMbsvIN6VsP5XY51XyfVV3DTMDZcXgA3QZQrg0ZwaGXYly4TmY994/W2f bdJ8ob0ZWRGMT/vMZVWVoaUqb7jG/006+hV0/6V4hXpLqvYGbQwTcJhDuSO3E9/GyN2L6hrCMm5 Xdb9pvktFybhe27ZcUyYbYL0G3jQ04QEui3V+E1il6FzL29W94pFATAF59BLbEYMVbzxQrNE3fJ 2ZqxlAyoHt9HkilNX3foTqQ== X-Google-Smtp-Source: AGHT+IHwNioxFw3VK7F8vFtagweeu18MBz1gau9Q9FyUS6H8idV2y7sbndqb4F+TNnGSGXbozpke+w== X-Received: by 2002:a05:600c:540c:b0:45b:5f99:191c with SMTP id 5b1f17b1804b1-45dddff012cmr99544705e9.12.1757406291212; Tue, 09 Sep 2025 01:24:51 -0700 (PDT) Received: from localhost ([84.79.192.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e75223f5d7sm1596495f8f.53.2025.09.09.01.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 01:24:50 -0700 (PDT) From: Roi Martin To: Yuan Fu Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed In-Reply-To: <51F87F1F-10CB-42D0-9B91-316F7F6F85F1@gmail.com> References: <87a53deu5z.fsf@gmail.com> <51F87F1F-10CB-42D0-9B91-316F7F6F85F1@gmail.com> Date: Tue, 09 Sep 2025 10:24:49 +0200 Message-ID: <87bjnkc9ta.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu writes: > Thanks for the analysis! Does that mean once the grammar is installed, > and you restart Emacs, go-ts-mode would work as normal? Yes, that is correct. > We do need to fix how we=E2=80=99re defining font-lock rules, the test sh= ould > be done when major mode is enabled, not when the package is loaded. I > thought about this problem and wanted to come up with some generic > solution, such as letting treesit-font-lock-rules support a predicate > function/query for font-lock-rules, or define rules in a fallback > list. I didn=E2=80=99t come up with a very satisfying solution and the > progress kind of stalled. Anyway, now it seems I need to put some > thought into this and come up with something soon. After discussing it with Juri, I've sent a few patches that fix some of the affected tree-sitter modes. You can read the conversation in the issue: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79363 However, I'm working on more patches, so you might want to check the ones I've already sent. Feedback is more than welcome. Thanks! Roi From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 10 03:10:01 2025 Received: (at 79363) by debbugs.gnu.org; 10 Sep 2025 07:10:02 +0000 Received: from localhost ([127.0.0.1]:35615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uwExt-0003zC-5j for submit@debbugs.gnu.org; Wed, 10 Sep 2025 03:10:01 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:44046) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uwExp-0003yV-IQ for 79363@debbugs.gnu.org; Wed, 10 Sep 2025 03:09:58 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-77238a3101fso4661044b3a.0 for <79363@debbugs.gnu.org>; Wed, 10 Sep 2025 00:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757488190; x=1758092990; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YhsBuyqVxzscOmMu1UqaggQGmHpBKbYjJWLgXdy0GYU=; b=R2kcXqnN7kFxQDUA5SPBWtG2+TBh4kuoHiId7jKA0p37Cu1IIuhFC7kCwl6rbetiKY Us3Z95A0Nh5TBZq2KSrDsXiTdkHY24uR9L18iBb4CEep/1PMifb9Opt/OC45592xaKdf ZskiNlZ+oXpWIiEBJtpWF1zbLbX5z69p9eujOzTUPk2IhOh8aUYl/tyrpfKcwuWgTOfz UGyWIxwOa7+A5jNaH8eIR7VVSSKAR9k0zSL0p+KUNj06GcB/7KwuxN+PyW/W3S/53Gez BY3DlB/Us+WhzMpLH/BP/M1bVlfdgO4FMBvxjCbhR1jjP2ClrQUaBV5WSyg0JRPrP/xE ihww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757488190; x=1758092990; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YhsBuyqVxzscOmMu1UqaggQGmHpBKbYjJWLgXdy0GYU=; b=B233kt3FOWKzSCORhC8EYBBuAIl3QqtWiKoO/7xjTG734PCwUJ9DZWb9hw1RW2WqDj sDhI7X6rgi1RjUF2opvKaqUZZSrsnx76Zwu/Sh9bXuwhRSjNoYOJmgHh9QSSBh7GnMbr QAAVwUBiTrNr1/xWNketpndeZZ22FDWmoKro1P5YTqyl1guE4cpwy0EhLBtzNmwCX5m4 RNUervIbMxFDJ98h8SWOVxBVOafK66a3DlbQY6gs3CHHEoXFdMQ71yYb3G4GBZmbOvuH h4KKQfrIHvlgH+bvLt+doPLfGTJ0SlYdRQYC8UATnOZbedY+Zs3BXjXaZa0Um5bVZzDg A6Zw== X-Gm-Message-State: AOJu0YyGkaEshsn5RJg5jMaMYKe+X8qkHnZl8O7neB8FHRsBnKlG/uer 1S4ykX+o9SfnzA5OoG2XDCLRW2yGU5wBL1Z7gjNEpaWwcXz53q1GExHfByw6FBez X-Gm-Gg: ASbGncvxdDV05ZiN1npgkcUg7Azf+XGGAdWvOoBS98z9NQos+iFH4DLPsM4IAEdcNxl paZUJwUARUf2Rx9CZqXJLnv9azbYVsngT4w9doV1lNht/FOsBbiOyMH09NIoPGxtpLEXm1S0tMx zzbkDPOyW0RJn+OalDNsDvV3tbo0sp97Glfq/1oxhEvIR1yQjSCIrKoJMaw2G9s+bqbgY83FjuW ArDN6Bg80CqOPXXeICsKHQAipItnx0aWI0IwaqyzKQc3uqAtD9zCAJrarDPZS1jSlQGT2fxAs6o oG7pkauJvhMv9kULyst0jYXh0xTj4JlEAsYBmw7klgFLwLju7TUbXJu7MZdal5S3p/dinvweLA1 738yVruyuxQnvn7wOjz3mdaueQsjSJbUWkG7g+TvVwYRoicFw/ykSDtZVlubwh1KEtmD4b4ele3 AH7j9TFg== X-Google-Smtp-Source: AGHT+IFbwjS1dF4MegLnP10GZisYXRaY+iEwUENGPmLDek/T/S49yHlE9p2g2viscc19mFaRGj3lig== X-Received: by 2002:a05:6a20:3d0a:b0:24a:a45d:7a26 with SMTP id adf61e73a8af0-25345a4498dmr21070008637.48.1757488190264; Wed, 10 Sep 2025 00:09:50 -0700 (PDT) Received: from smtpclient.apple (c-24-4-247-194.hsd1.ca.comcast.net. [24.4.247.194]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7746612b701sm4090799b3a.29.2025.09.10.00.09.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2025 00:09:49 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed From: Yuan Fu In-Reply-To: <87bjnkc9ta.fsf@gmail.com> Date: Wed, 10 Sep 2025 00:09:38 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <2703C06A-8EB4-4203-974D-E263804B3D75@gmail.com> References: <87a53deu5z.fsf@gmail.com> <51F87F1F-10CB-42D0-9B91-316F7F6F85F1@gmail.com> <87bjnkc9ta.fsf@gmail.com> To: Roi Martin X-Mailer: Apple Mail (2.3826.700.81) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Sep 9, 2025, at 1:24=E2=80=AFAM, Roi Martin = wrote: >=20 > Yuan Fu writes: >=20 >> Thanks for the analysis! Does that mean once the grammar is = installed, >> and you restart Emacs, go-ts-mode would work as normal? >=20 > Yes, that is correct. >=20 >> We do need to fix how we=E2=80=99re defining font-lock rules, the = test should >> be done when major mode is enabled, not when the package is loaded. I >> thought about this problem and wanted to come up with some generic >> solution, such as letting treesit-font-lock-rules support a predicate >> function/query for font-lock-rules, or define rules in a fallback >> list. I didn=E2=80=99t come up with a very satisfying solution and = the >> progress kind of stalled. Anyway, now it seems I need to put some >> thought into this and come up with something soon. >=20 > After discussing it with Juri, I've sent a few patches that fix some = of > the affected tree-sitter modes. You can read the conversation in the > issue: >=20 > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79363 >=20 > However, I'm working on more patches, so you might want to check the > ones I've already sent. Feedback is more than welcome. >=20 > Thanks! >=20 > Roi Apologies, apparently I didn=E2=80=99t get any of the messages between = you and Juri. I=E2=80=99ve cursed at my mail client and will read the = conversation on the archive :-) Yuan= From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 10 03:20:13 2025 Received: (at 79363) by debbugs.gnu.org; 10 Sep 2025 07:20:14 +0000 Received: from localhost ([127.0.0.1]:35671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uwF7l-0004Wk-AC for submit@debbugs.gnu.org; Wed, 10 Sep 2025 03:20:13 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:45249) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uwF7h-0004VL-3S for 79363@debbugs.gnu.org; Wed, 10 Sep 2025 03:20:09 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2570bf605b1so32215565ad.2 for <79363@debbugs.gnu.org>; Wed, 10 Sep 2025 00:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757488803; x=1758093603; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xej8MYwKRjiEDRWrP29gyHlt8qISyUn5WHZCc1bNBgI=; b=cFEamXe+SR89V0PmBNx9tsBQJD/32rpYwK06HUgX80pZ3PaL8i2V8a7bnyYQfxNQtw lj4BgI2AdI5pWrGW2LR43EEvrdN90rEaRUzm71e4KxgRP7ebv3Eo4C2oaR3mIJR4RLZT MdMWKKE8vvwryabGLnnCzTEdY3K7K8evOyG8vl6ln1EFyoILS5UrOnzNrGRCHSJPPtXA +OOZ7VFNPl/MthF6LqD2hvLDf2yVRsOeZ+nENZVWw3p9ApSNgVNUqfZWJQyuh0ZUQ0iF Gxo9vnaGqTRZiRPqg16Vp+pZCVQWEyALN083AV7mBEN/d0r6UeEEov994HkS9LBXR5u1 ETHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757488803; x=1758093603; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xej8MYwKRjiEDRWrP29gyHlt8qISyUn5WHZCc1bNBgI=; b=tOy5lsvwKHeQQ05XkWaY0JXPx637esXpFsYQuvfkC9jaTKg8isKydc6Zvbm7ylN+E8 3IZiG5Xfqvn9OhcziFMElt4eG5INIyF64EcernKHFrix6clTO9XxaiV/pNEQopuAtS1O OWG7dRCkkK5t8MQWaS1IIgOUV6CNWCB/gK3V/42vCWELUIumZipe2fyGSJrgZUSm5D29 vS9x0nluCOd+eI7bLwsUjNlRw67T0WZSAuFp7hV+7c1lTJCE+INAW4BAXIrYE5Hf94PG iktejEo+yl5zc/ufX9FxpiWK+5ZM2Gg8XT8W9xgSq+IuHJhS95pRVidIAqIxltaTfYaL +TJA== X-Gm-Message-State: AOJu0Yy5zVZEJ1+9eBtl9A3zK8xM2jGz9lUJU8K4+q1rXW8Mvmf9Q2+Q DrCbNUvYr74bxKBwZYbs9aNwp9ZBY0Mu+JNl32kqrWJWqf17ia31xkOv X-Gm-Gg: ASbGncsDRIGdUz6H3lm+dDEYWaEnwVCcCbROlvoxMTnnF+jNpJWRxU3LUPqSThH1kjW p/+FELgDyazVJd5BYTWRrmISumxt22Q1Mw2hIc5ZMRiGGSpERcvITKhtTbv+OQNmntmR1YthVA+ 6Og58T2CN65JUh2Ud4PeyIP/rIsFI/gHYEJO1nORjAx7cJidmS6ncuHY33ZHHeVYN6coQ7R//KZ ZQFSRQISdZMp3CQK8Xpz2LQdosGUtqDE1RuyPTGlHNemttK6fqOMYfpY/TBBufYAcc9jHy1MgS9 ADb+UWI+le8RAnJMMZqae6j7Yu0WsvvPbOBUVM2g9HytVSeNcQiJcohOM3SMFnHbskHHT3vS/S5 8nz5Vm+0ekmTEDeTTv4VtvZ1+5YoarfQVQAXzmog8xwGAEryn0wl7KnXPVLSWXGkET3BcOW3t0c siuR0YZA== X-Google-Smtp-Source: AGHT+IFNWMszV3phii+r7rknD/Kbz3w6khqxjlec2aAnW6VW/mdD1GnZ6/psR0Nky7JxIzGcTEAMrg== X-Received: by 2002:a17:902:ce90:b0:240:3c51:1063 with SMTP id d9443c01a7336-2516e2c0d9emr189698225ad.23.1757488802481; Wed, 10 Sep 2025 00:20:02 -0700 (PDT) Received: from smtpclient.apple (c-24-4-247-194.hsd1.ca.comcast.net. [24.4.247.194]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-25a2a344af8sm17542115ad.78.2025.09.10.00.20.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2025 00:20:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: bug#79363: 31.0.50; Font locking issue in go-ts-mode when tree-sitter grammar is automatically installed From: Yuan Fu In-Reply-To: <2703C06A-8EB4-4203-974D-E263804B3D75@gmail.com> Date: Wed, 10 Sep 2025 00:19:50 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <474BCCA7-D7F6-4CFE-883E-A63928828CA0@gmail.com> References: <87a53deu5z.fsf@gmail.com> <51F87F1F-10CB-42D0-9B91-316F7F6F85F1@gmail.com> <87bjnkc9ta.fsf@gmail.com> <2703C06A-8EB4-4203-974D-E263804B3D75@gmail.com> To: Roi Martin X-Mailer: Apple Mail (2.3826.700.81) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79363 Cc: 79363@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Sep 10, 2025, at 12:09=E2=80=AFAM, Yuan Fu = wrote: >=20 >=20 >=20 >> On Sep 9, 2025, at 1:24=E2=80=AFAM, Roi Martin = wrote: >>=20 >> Yuan Fu writes: >>=20 >>> Thanks for the analysis! Does that mean once the grammar is = installed, >>> and you restart Emacs, go-ts-mode would work as normal? >>=20 >> Yes, that is correct. >>=20 >>> We do need to fix how we=E2=80=99re defining font-lock rules, the = test should >>> be done when major mode is enabled, not when the package is loaded. = I >>> thought about this problem and wanted to come up with some generic >>> solution, such as letting treesit-font-lock-rules support a = predicate >>> function/query for font-lock-rules, or define rules in a fallback >>> list. I didn=E2=80=99t come up with a very satisfying solution and = the >>> progress kind of stalled. Anyway, now it seems I need to put some >>> thought into this and come up with something soon. >>=20 >> After discussing it with Juri, I've sent a few patches that fix some = of >> the affected tree-sitter modes. You can read the conversation in the >> issue: >>=20 >> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79363 >>=20 >> However, I'm working on more patches, so you might want to check the >> ones I've already sent. Feedback is more than welcome. >>=20 >> Thanks! >>=20 >> Roi >=20 > Apologies, apparently I didn=E2=80=99t get any of the messages between = you and Juri. I=E2=80=99ve cursed at my mail client and will read the = conversation on the archive :-) >=20 > Yuan I read the thread and it looks good to me. Thanks for working on it! Yuan=