From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs Subject: bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition Date: Fri, 28 Jul 2023 22:59:27 +0200 Message-ID: <4516186.LvFx2qVVIh@fedora> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2307625.ElGaqSPkdT" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35758"; mail-complaints-to="usenet@ciao.gmane.io" To: 64922@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 28 23:16:56 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qPUpU-00097f-46 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 28 Jul 2023 23:16:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPUZB-0000IK-G6; Fri, 28 Jul 2023 17:00:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qPUZ9-0000GD-VT for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 17:00:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qPUZ9-0001vv-G0 for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 17:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qPUZ9-0006gi-1U for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 17:00:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Jul 2023 21:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64922 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169057798125647 (code B ref -1); Fri, 28 Jul 2023 21:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Jul 2023 20:59:41 +0000 Original-Received: from localhost ([127.0.0.1]:46202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qPUYm-0006fa-J3 for submit@debbugs.gnu.org; Fri, 28 Jul 2023 16:59:41 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:49282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qPUYk-0006fM-ER for submit@debbugs.gnu.org; Fri, 28 Jul 2023 16:59:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qPUYe-0007xt-UR for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 16:59:32 -0400 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qPUYd-0001hy-2b for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 16:59:32 -0400 Original-Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fb4146e8ceso25745125e9.0 for ; Fri, 28 Jul 2023 13:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690577969; x=1691182769; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=h/D9aikAIZgg7gi/MdcMvz5aTJGQ4DoRA9hb8c2S+Ts=; b=pTa2sawB3kG9kqus+28wkRqOh8N4aqPQcx+GE/VERJwmaz6EQbFqFRiZyvyKjsou8N TIERFtsosLqrg2S3w3Rc3ELniiPqL77pMQtDvBfUC3zr8SN4wZT6te6ZHPhOEdqtKKot 6DBoCfAutCUe54MLKB+E7Wlr0T5JoPFqh/izCddyRotXFbvTdkUWe5dBWp/fFvT/uNxW sX+lAKds4fW3sYLWAOCK6Dusfi42jrVVL1vhmlyhD9MP+VwWfruPowIrmFVf5BPZWCCW vfSs/Gu18AUWz56bSPs18qcN5AME+aNASWg3wxXGbsh81TDUe/lYjYRzB6AJNXNH+n6S WgVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690577969; x=1691182769; 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=h/D9aikAIZgg7gi/MdcMvz5aTJGQ4DoRA9hb8c2S+Ts=; b=arNbjUDvBiuwipaumdITM+bfoFgw9ij1mhMoQgH6+z8zUZSr933TZ3R5dc8DADLA5N TOgh0ClP+wCZMoRSwMOV6vq/mPtIwo8NNXrDuNX3LKVFgCBI0kb7pcEC2cfvWahULc4c Ez7xHgd9PXcZd42omxbnlifnO5loQurUI29DIDddx73DOzH9LN2CaENdmG/gFvuqnTnp ezGIJ9f/vfCPFEB1/EN27hWwqB+nVhrPcMkZ6cVJ+sjTkBuNLSPJ+N997mXxKrpHXSMp 62ubL7+i7mEMaQnjD+AoNApOrUXubyIKIGJbK6vUrzNdqUsHKGfohuI80AApo7PIrvSn ZtAQ== X-Gm-Message-State: ABy/qLaY5j2Y6ZvzBpXNyn8tOg0AzlBYBaQGJy8iRoZxSSDEBMXQM2iv YSmWID0Z5qWEcNcNtbVYFg/fKsTZx1s= X-Google-Smtp-Source: APBJJlHXy5tAsxcTzC64ouvBvNigYMqVFBpHk5wtfdtfXXpZsPfNB0JNsZeiUCW+RxWBjwOl3soYiA== X-Received: by 2002:a5d:608a:0:b0:314:415:cbf5 with SMTP id w10-20020a5d608a000000b003140415cbf5mr2645516wrt.51.1690577968871; Fri, 28 Jul 2023 13:59:28 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id p9-20020a5d48c9000000b0031433443265sm5714474wrs.53.2023.07.28.13.59.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 13:59:28 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=v.pupillo@gmail.com; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266300 Archived-At: This is a multi-part message in MIME format. --nextPart2307625.ElGaqSPkdT Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi, a recent commit (commit fe9b5e022950d53cb23959b76c240e1da27ff0a5) changed the definition of the cmake grammar, now there is a new node argument_list used to wrap nodes of type argument. This causes the following error: Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error "Structure error at" 19 "((foreach_command ((argument) @font-lock-constant- face (#match \"\\\\(?:^\\\\(?:I\\\\(?:N\\\\|TEMS\\\\)\\\\|LISTS\\\\|RANGE\\\\| ZIP_LISTS\\\\)$\\\\)\" @font-lock-constant-face)))) ((if_command ((argument) @font-lock-constant-face (#match \"\\\\(?:^\\\\(?:AND\\\\|COMMAND\\\\|DEFINED\ \\\|E\\\\(?:QUAL\\\\|XISTS\\\\)\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\ (?:_EQUAL\\\\)?\\\\|MATCHES\\\\|NOT\\\\|OR\\\\|PATH_EQUAL\\\\|STR\\\\(?:EQUAL\ \\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\\|VERSION_\\ \\(?:EQUAL\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\ \)$\\\\)\" @font-lock-constant-face))))" "Debug the query with `treesit-query- validate'") The attached patch supports both the old and the new grammar. Thanks. Vincenzo --nextPart2307625.ElGaqSPkdT Content-Disposition: attachment; filename="0001-Updated-CMake-support-due-to-changes-in-tree-sitter-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Updated-CMake-support-due-to-changes-in-tree-sitter-.patch" >From 33a53c86b38624dcfe88aca24f6f1f94ab339463 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Fri, 28 Jul 2023 22:37:02 +0200 Subject: [PATCH] Updated CMake support due to changes in tree-sitter-cmake A recent change in tree-sitter-cmake grammar support for CMake (commit fe9b5e0), now put arguments are wrapped in a new argument_list node. To support the old and new version of the grammar, a new function was added on which string syntax highlighting now depends. * lisp/progmodes/cmake-ts-mode.el: (cmake-ts-mode--font-lock-compatibility-fe9b5e0): indent helper function for handle different tree-sitter-cmake version * lisp/progmodes/cmake-ts-mode.el: (cmake-ts-mode--font-lock-settings): use the new function to handle the new argument_list node. --- lisp/progmodes/cmake-ts-mode.el | 54 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index 9d35d8077bd..9fcd8a7a2ab 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el @@ -31,6 +31,7 @@ (eval-when-compile (require 'rx)) (declare-function treesit-parser-create "treesit.c") +(declare-function treesit-query-capture "treesit.c") (declare-function treesit-induce-sparse-tree "treesit.c") (declare-function treesit-node-child "treesit.c") (declare-function treesit-node-start "treesit.c") @@ -87,6 +88,42 @@ "VERSION_GREATER_EQUAL" "VERSION_LESS" "VERSION_LESS_EQUAL") "CMake if conditions for tree-sitter font-locking.") +(defun cmake-ts-mode--font-lock-compatibility-fe9b5e0 () + "Indent rules helper, to handle different releases of tree-sitter-cmake. +Check if a node type is available, then return the right indent rules." + ;; handle commit fe9b5e0 + (condition-case nil + (progn (treesit-query-capture 'cmake '((argument_list) @capture)) + `(((foreach_command + ((argument_list) @font-lock-constant-face + (:match ,(rx-to-string + `(seq bol + (or ,@cmake-ts-mode--foreach-options) + eol)) + @font-lock-constant-face)))) + ((if_command + ((argument_list) @font-lock-constant-face + (:match ,(rx-to-string + `(seq bol + (or ,@cmake-ts-mode--if-conditions) + eol)) + @font-lock-constant-face)))))) + (error + `(((foreach_command + ((argument) @font-lock-constant-face + (:match ,(rx-to-string + `(seq bol + (or ,@cmake-ts-mode--foreach-options) + eol)) + @font-lock-constant-face)))) + ((if_command + ((argument) @font-lock-constant-face + (:match ,(rx-to-string + `(seq bol + (or ,@cmake-ts-mode--if-conditions) + eol)) + @font-lock-constant-face)))))))) + (defvar cmake-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'cmake @@ -95,21 +132,8 @@ :language 'cmake :feature 'builtin - `(((foreach_command - ((argument) @font-lock-constant-face - (:match ,(rx-to-string - `(seq bol - (or ,@cmake-ts-mode--foreach-options) - eol)) - @font-lock-constant-face)))) - ((if_command - ((argument) @font-lock-constant-face - (:match ,(rx-to-string - `(seq bol - (or ,@cmake-ts-mode--if-conditions) - eol)) - @font-lock-constant-face))))) - + (cmake-ts-mode--font-lock-compatibility-fe9b5e0) + :language 'cmake :feature 'comment '([(bracket_comment) (line_comment)] @font-lock-comment-face) -- 2.41.0 --nextPart2307625.ElGaqSPkdT--